Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Piece TRules(Piece p, boolean[][] board) {
- int destCol = -1;
- int curColHeight = -1;
- // checks for -_-
- for (int col = 1; col < MAXCOL; col++) {
- curColHeight = colHeight(board, col);
- if (curColHeight + 1 == colHeight(board, col - 1) &&
- curColHeight + 1 == colHeight(board, col + 1)) {
- p = rotateTo(p, 0);
- p = moveTo(p, col);
- p = p.drop();
- return p;
- }
- }
- // checks for _-
- for (int col = 0; col < MAXCOL; col++) {
- curColHeight = colHeight(board, col);
- if (curColHeight + 1 == colHeight(board, col + 1)) {
- p = rotateTo(p, 3);
- p = moveTo(p, col);
- p = p.drop();
- return p;
- }
- }
- // checks for -_
- for (int col = 1; col <= MAXCOL; col++) {
- curColHeight = colHeight(board, col);
- if (curColHeight + 1 == colHeight(board, col - 1)) {
- p = rotateTo(p, 1);
- p = moveTo(p, col);
- p = p.drop();
- return p;
- }
- }
- // the entire line must be straight at this point //!!! or sections of 2
- p = rotateTo(p, 2);
- p = moveTo(p, 0);
- p = p.drop();
- return p;
- }
Add Comment
Please, Sign In to add comment