// performs the castling procedure // moves the kingside rook as the standard makeMove algorithm in the player class handles the king piece as that is the primary piece involved in the move and is the piece that is clicked to perform the castle move. public void PerformCastle(Rook kingsideRook, King movingKing, Square targetPosition, Board gameBoard) { // sets the target position for the rook Square rookTargetPosition = gameBoard.getSquares()[targetPosition.X + 1, targetPosition.Y]; //creates a move object for the rook and populates it Move aMove = new Move(); aMove.initialPosition = kingsideRook.getPosition(); aMove.finalPosition = rookTargetPosition; aMove.PieceMoved = kingsideRook; if (kingsideRook.getMoveCount() == 0) { aMove.castled = true; } if (BoardAdmin.game1.getTurn() == BoardAdmin.game1.getPlayer1().getPlayerColour()) { aMove.PlayerMoved = BoardAdmin.game1.getPlayer1(); } else { aMove.PlayerMoved = BoardAdmin.game1.getPlayer2(); } //sets properties of kingside rook piece BoardAdmin.game1.addTomoveHistory(aMove); // adds the move object to the list of moves for the game history kingsideRook.getPosition().occ = false; kingsideRook.setPosition(rookTargetPosition); kingsideRook.getPosition().occ = true; kingsideRook.IncrementMoveCount(1); }
private void button1_Click(object sender, EventArgs e) { if (CheckTargetPosition() == true && BlackRook1.checkValidMove(textBox1.Text, generateBoardPositions()) == true) { BlackRook1.setPosition(textBox1.Text); updateView(); } }