Commiting wrongly on this branch to cherry-pick
This commit is contained in:
parent
6f55dde659
commit
479cd7f975
|
@ -52,6 +52,9 @@ public class Pattern {
|
|||
maxUp = 0,
|
||||
maxDown = 0;
|
||||
for (Item i: parts) {
|
||||
if (i.hasID(-1)) {
|
||||
continue;
|
||||
}
|
||||
if (maxLeft < -i.getPosX()) {
|
||||
maxLeft = -i.getPosX();
|
||||
}
|
||||
|
@ -72,7 +75,10 @@ public class Pattern {
|
|||
for (Item k: parts) {
|
||||
int posX = i + k.getPosX();
|
||||
int posY = j + k.getPosY();
|
||||
if (!k.hasID(board[posX][posY])) {
|
||||
if ((!isOnBoard(new Position(posX, posY)) &&
|
||||
!k.hasID(-1)) ||
|
||||
(isOnBoard(new Position(posX, posY)) &&
|
||||
!k.hasID(board[posX][posY]))) {
|
||||
continue inner;
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +88,22 @@ public class Pattern {
|
|||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given position on the Board.
|
||||
*
|
||||
* @param pos The position to check.
|
||||
* @return Whether the position is on the board.
|
||||
*/
|
||||
private boolean isOnBoard(Position pos) {
|
||||
if (pos.getPosX() < 0 ||
|
||||
pos.getPosX() > Game.GAME_COLUMNS - 1 ||
|
||||
pos.getPosY() < 0 ||
|
||||
pos.getPosY() > Game.GAME_ROWS - 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a part of the Pattern.
|
||||
*
|
||||
|
|
|
@ -68,7 +68,7 @@ public class PatternGenerator {
|
|||
// Replace one item with the new 0-one.
|
||||
newP.replaceItem(x, newI);
|
||||
// Add the support.
|
||||
newP.addItem(new Item(x.getPosX(), x.getPosY() + 1, new int[]{1, 2}));
|
||||
newP.addItem(new Item(x.getPosX(), x.getPosY() + 1, new int[]{-1, 1, 2}));
|
||||
// Add the pattern to the set.
|
||||
ret.add(newP);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue