public static void flipPiecesDown(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Down for (int row = i + 1; row < 8; row++) { if (Game.board[row][j] == colorNum) break; else { GameUI.setColor(row, j, color); Game.setPieceFlip(row, j, colorNum); } } }
public static void flipPiecesUp(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Up for (int row = i - 1; row > -1; row--) { if (Game.board[row][j] == colorNum) break; else { GameUI.setColor(row, j, color); Game.setPieceFlip(row, j, colorNum); } } }
public static void flipPiecesLeft(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Left for (int column = j - 1; column > -1; column--) { if (Game.board[i][column] == colorNum) break; else { GameUI.setColor(i, column, color); Game.setPieceFlip(i, column, colorNum); } } }
public static void flipPiecesUpRight(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // up/right for (int row = i, column = j; row > -1 && column < 8; row--, column++) { if (Game.board[row][column] == colorNum) { break; } else { GameUI.setColor(row, column, color); Game.setPieceFlip(row, column, colorNum); } } }
public static void flipPiecesDownLeft(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // down/left for (int row = i, column = j; row < 8 && column > -1; row++, column--) { if (Game.board[row][column] == colorNum) { break; } else { GameUI.setColor(row, column, color); Game.setPieceFlip(row, column, colorNum); } } }
// Method to flip pieces, depending on what direction sent by canMove // Jean-Philippe Lebel public static void flipPiecesRight(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Right for (int column = j + 1; column < 8; column++) { // scans in the direction called, until it hits a piece of the same color, // breaking once it does. if (Game.board[i][column] == colorNum) break; // this is the same for all 8 directional methods. else { GameUI.setColor(i, column, color); Game.setPieceFlip(i, column, colorNum); } } }