diff --git a/src/model/Board.java b/src/model/Board.java index 2bd1142..184dc54 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -4,9 +4,8 @@ /** * The representation is a 8x8 grid where - * A[y][x] denotes the (x, y) indexed piece. - * It is swapped because we dereference by "row" first, - * which is "y". + * A[row][col] marks the position of the checker piece. + * Smoke starts at lower row and fire starts at higher row. * @author Ayamin * */ @@ -28,15 +27,18 @@ public Board() { movesSinceCapture = 0; init(); } - + + public boolean isValidSquare(int row, int col) { + return 0 <= row && row < BOARD_SIZE && + 0 <= col && col < BOARD_SIZE; + } + /** * Initialize the board putting checker pieces in their starting locations */ - private void init() - { + private void init() { for(int row = 0; row < 3; row++){ - for (int col = 0; col < 4; col++) - { + for (int col = 0; col < 4; col++) { Piece red_piece = new Piece(Color.RED, 2*col + (row % 2), row); Piece black_piece = new Piece(Color.BLACK, 2*col + (BOARD_SIZE - 1 - row) %2, BOARD_SIZE - 1 - row); representation[row][2*col+ (row % 2)] = red_piece; @@ -48,29 +50,23 @@ private void init() /** * Print the current board representation */ - public void print() - { - for(int row = 0; row < BOARD_SIZE; row++) - { - for (int col = 0; col < BOARD_SIZE; col++) - { + public void print() { + for(int row = 0; row < BOARD_SIZE; row++) { + for (int col = 0; col < BOARD_SIZE; col++) { if (!isOccupied(row, col)) System.out.print("| "); - else if (representation[row][col].getColor() == Color.RED) - { + else if (representation[row][col].getColor() == Color.RED) { if (representation[row][col].getType() == Type.NORMAL) System.out.print("|r"); else System.out.print("|R"); } - else - { + else { if(representation[row][col].getType() == Type.NORMAL) System.out.print("|b"); else System.out.print("|B"); } - } System.out.println("|"); } @@ -80,8 +76,7 @@ else if (representation[row][col].getColor() == Color.RED) * return true if square contains a piece * return false otherwise */ - public boolean isOccupied(int row, int col) - { + public boolean isOccupied(int row, int col) { return representation[row][col] != null; } @@ -99,7 +94,6 @@ public ArrayList getBlackPieces() { public void setBlackPieces(ArrayList black_pieces) { this.black_pieces = black_pieces; - } - + } } diff --git a/src/model/Player.java b/src/model/Player.java deleted file mode 100644 index ec0ae71..0000000 --- a/src/model/Player.java +++ /dev/null @@ -1,35 +0,0 @@ -package model; - -import java.util.ArrayList; - -public class Player { - private ArrayList pieces; - private Color assigned_color; - public final String name; - - public Player(String name, Color c) { - this.name = name; - this.pieces = new ArrayList(); - this.setAssignedColor(c); - } - - public void setPieces(ArrayList pieces) { - this.pieces = pieces; - } - - public ArrayList getPieces() { - return pieces; - } - - public String getName() { - return name; - } - - public Color getAssignedColor() { - return assigned_color; - } - - public void setAssignedColor(Color assigned_color) { - this.assigned_color = assigned_color; - } -}