private Board getCurrentBoard() { Board gameBoard = new Board(); for (int row = 0; row < 8; row++) { for (int col = 0; col < 8; col++) { StackPanel boardField = getBoardField(board, row, col); if (boardField.Children.Count > 0) { Button button = (Button)boardField.Children[0]; if (button.Name.Contains("Red")) { if (button.Name.Contains("Lady")) { gameBoard.AssignPiece(row, col, Board.FieldState.RED_LADY); gameBoard.increaseRedLadyCount(); } else { gameBoard.AssignPiece(row, col, Board.FieldState.RED); gameBoard.increaseRedCount(); } } else if (button.Name.Contains("Black")) { if (button.Name.Contains("Lady")) { gameBoard.AssignPiece(row, col, Board.FieldState.BLACK_LADY); gameBoard.increaseBlackLadyCount(); } else { gameBoard.AssignPiece(row, col, Board.FieldState.BLACK); gameBoard.increaseBlackCount(); } } else { gameBoard.AssignPiece(row, col, Board.FieldState.EMPTY); } } else { gameBoard.AssignPiece(row, col, Board.FieldState.INVALID); } } } return(gameBoard); }
private Board copyBoard(Board board) { Board copy = new Board(); for (int row = 0; row < 8; row++) { for (int col = 0; col < 8; col++) { copy.AssignPiece(row, col, board.GetPiece(row, col)); } } copy.setBlackCount(board.getBlackCount()); copy.setBlackLadyCount(board.getBlackLadyCount()); copy.setRedCount(board.getRedCount()); copy.setRedLadyCount(board.getRedLadyCount()); return(copy); }