Commiting wrongly on this branch to cherry-pick
This commit is contained in:
parent
21ec72f499
commit
7f83c6f01f
|
@ -52,6 +52,9 @@ public class Pattern {
|
||||||
maxUp = 0,
|
maxUp = 0,
|
||||||
maxDown = 0;
|
maxDown = 0;
|
||||||
for (Item i: parts) {
|
for (Item i: parts) {
|
||||||
|
if (i.hasID(-1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (maxLeft < -i.getPosX()) {
|
if (maxLeft < -i.getPosX()) {
|
||||||
maxLeft = -i.getPosX();
|
maxLeft = -i.getPosX();
|
||||||
}
|
}
|
||||||
|
@ -72,7 +75,10 @@ public class Pattern {
|
||||||
for (Item k: parts) {
|
for (Item k: parts) {
|
||||||
int posX = i + k.getPosX();
|
int posX = i + k.getPosX();
|
||||||
int posY = j + k.getPosY();
|
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;
|
continue inner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +88,22 @@ public class Pattern {
|
||||||
return set;
|
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.
|
* Replaces a part of the Pattern.
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class PatternGenerator {
|
||||||
// Replace one item with the new 0-one.
|
// Replace one item with the new 0-one.
|
||||||
newP.replaceItem(x, newI);
|
newP.replaceItem(x, newI);
|
||||||
// Add the support.
|
// 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.
|
// Add the pattern to the set.
|
||||||
ret.add(newP);
|
ret.add(newP);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue