public void addPiece(Piece p) { if (p.getColor() == PieceColor.BLACK) { this.blackPieces++; } else { this.redPieces++; } board.addPieceToCell(p); }
public static Board deepCopy(Board b) { Board newB = new Board(b.getHeight(), b.getWidth()); for (int y = 0; y < newB.getHeight(); y++) { for (int x = 0; x < newB.getWidth(); x++) { Piece p = b.getCellContents(y, x); if (p != null) { newB.addPieceToCell(new Piece(p)); } } } return newB; }
public static Board deepCopy(Board b) { Board newB = new Board(b.getHeight(), b.getWidth()); for (int y = 0; y < newB.getHeight(); y++) { for (int x = 0; x < newB.getWidth(); x++) { Piece p = b.getCellContents(y, x); if (p != null) { newB.addPieceToCell(new Piece(p)); } } } return(newB); }