Successfully detects matches in vertical and horizontal directions
This commit is contained in:
parent
63bf02aa4c
commit
6ed1928bf3
BIN
Meteo_Engine.jar
BIN
Meteo_Engine.jar
Binary file not shown.
@ -125,21 +125,21 @@ public class Board {
|
|||||||
for (int y=0;y<blocks.maxBlockHeight;y++) {
|
for (int y=0;y<blocks.maxBlockHeight;y++) {
|
||||||
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
||||||
List<Block> blockList = blocks.getSortedBlocksOnRow(y);
|
List<Block> blockList = blocks.getSortedBlocksOnRow(y);
|
||||||
List<Block> markedBlocks = FindMatches(blockList,width);
|
List<Block> markedBlocks = FindMatches(blockList,width,true);
|
||||||
if (markedBlocks.size()>0) { //Ignite these blocks.
|
if (markedBlocks.size()>0) { //Ignite these blocks.
|
||||||
System.out.println("Marked: "+markedBlocks);
|
System.out.println("Marked: "+markedBlocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x=0;x<width;x++) {
|
for (int x=0;x<width;x++) {
|
||||||
List<Block> blockList = blocks.getSortedBlocksOnCol(x);
|
List<Block> blockList = blocks.getSortedBlocksOnCol(x);
|
||||||
List<Block> markedBlocks = FindMatches(blockList,blocks.maxBlockHeight);
|
List<Block> markedBlocks = FindMatches(blockList,blocks.maxBlockHeight,false);
|
||||||
if (markedBlocks.size()>0) { //Ignite these blocks.
|
if (markedBlocks.size()>0) { //Ignite these blocks.
|
||||||
System.out.println("Marked: "+markedBlocks);
|
System.out.println("Marked: "+markedBlocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private List<Block> FindMatches(List<Block> blockList, int maxSearch) {
|
private List<Block> FindMatches(List<Block> blockList, int maxSearch, boolean searchingRows) {
|
||||||
BlockState col = BlockState.IGNITED;
|
BlockState col = BlockState.IGNITED;
|
||||||
int matches=0;
|
int matches=0;
|
||||||
List<Block> markedBlocks = new ArrayList<Block>();
|
List<Block> markedBlocks = new ArrayList<Block>();
|
||||||
@ -147,7 +147,7 @@ public class Board {
|
|||||||
for (int i=0;i<maxSearch;i++) {
|
for (int i=0;i<maxSearch;i++) {
|
||||||
if (blockList.isEmpty()) {break;}
|
if (blockList.isEmpty()) {break;}
|
||||||
Block currentBlock = blockList.get(0);
|
Block currentBlock = blockList.get(0);
|
||||||
if (currentBlock.x==i) {
|
if (searchingRows&¤tBlock.x==i||(!searchingRows&¤tBlock.y==i)) {
|
||||||
if (col!=BlockState.IGNITED&¤tBlock.state==col) {
|
if (col!=BlockState.IGNITED&¤tBlock.state==col) {
|
||||||
matches++;
|
matches++;
|
||||||
tempMarkedBlocks.add(blockList.remove(0));
|
tempMarkedBlocks.add(blockList.remove(0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user