Add sorted block gets on row and col blocks
This commit is contained in:
parent
287d8d3912
commit
80ab9c9f23
BIN
Meteo_Engine.jar
BIN
Meteo_Engine.jar
Binary file not shown.
@ -2,8 +2,8 @@ package sig;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.awt.Color;
|
||||
|
||||
public class BlockClump {
|
||||
@ -77,6 +77,12 @@ public class BlockClump {
|
||||
public List<Block> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
public List<Block> getSortedBlocksOnRow(int row) {
|
||||
return getBlocks().stream().filter((block)->block.y==row).sorted((b1,b2)->b1.x-b2.x).collect(Collectors.toList());
|
||||
}
|
||||
public List<Block> getSortedBlocksOnCol(int col) {
|
||||
return getBlocks().stream().filter((block)->block.x==col).sorted((b1,b2)->b1.y-b2.y).collect(Collectors.toList());
|
||||
}
|
||||
private void updateBlockCollisionRangeWithBlock(Block b) {
|
||||
if (collisionColumnRanges[b.x][0]==-1||collisionColumnRanges[b.x][0]>b.y) {
|
||||
collisionColumnRanges[b.x][0]=b.y;
|
||||
|
@ -112,13 +112,10 @@ public class Board {
|
||||
//Start from one block and work our way across, seeing if we can make a match of 3 or more. Go to the next row, repeat. Then do the columns. Once all blocks marked for ignition, ignite them and send them.
|
||||
//Lowest block is used as the block clump starting point.
|
||||
for (int y=0;y<blocks.maxBlockHeight;y++) {
|
||||
for (int x=0;x<width;x++) {
|
||||
final int xx=x,yy=y;
|
||||
List<Block> bl = blocks.getBlocks().stream().filter((block)->block.x==xx&&block.y==yy).collect(Collectors.toList());
|
||||
if (bl.size()>0) {
|
||||
//System.out.println("Found a block at ("+x+","+y+")");
|
||||
}
|
||||
}
|
||||
System.out.println(blocks.getSortedBlocksOnRow(y));
|
||||
}
|
||||
for (int x=0;x<width;x++) {
|
||||
System.out.println(blocks.getSortedBlocksOnCol(x));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user