/// <summary> /// Moves a piece in a desired direction. /// </summary> /// <param name="piece">The piece to be moved.</param> /// <param name="destinationSquare">The destination square.</param> /// <returns>A boolean representing the success of the move.</returns> public bool MovePiece(Piece piece, BoardSquare destinationSquare) { bool result; result = GetIsSquareAvailable(destinationSquare); if (result) { destinationSquare.PutPiece(piece); } return(result); }
/// <summary> /// Get the square in a given direction in relation to a game piece. /// Returns NULL if no square exists in that position. /// </summary> /// <param name="piece">The game's piece to use.</param> /// <param name="direction">The direction in relation to the game's piece.</param> /// <returns>The square in that position. NULL if no square exists.</returns> public BoardSquare GetBoardSquareByDirection(Piece piece, Direction direction) { Coord pos; BoardSquare square = null; pos = GetNewCoordinates(piece, direction); if (GetIsPositionValid(pos)) { square = Rows[pos.Row].Squares[pos.Column]; } return(square); }
/// <summary> /// Sets the reference to the current location of this piece. /// </summary> /// <param name="square">The current square this piece is at.</param> public void SetBoardSquareReference(BoardSquare square) { BoardSquare = square; }
/// <summary> /// Checks to see if square is available to receive a game piece. /// </summary> /// <param name="square">The square to check.</param> /// <returns>A boolean value representing if the square is available.</returns> private bool GetIsSquareAvailable(BoardSquare square) { return(square.Piece == null); }