private void RaisePieceTaken(Square square, ChessPiece pieceTaken) { var handler = this.PieceTaken; if (handler != null) { var eventArgs = new PieceTakenEventArgs(square, pieceTaken); handler(this, eventArgs); } }
private void RaiseMoveMade(BoardPosition from, BoardPosition to, ChessPiece chessPiece) { var handler = this.MoveMade; if (handler != null) { var eventArgs = new MoveMadeEventArgs(from, to, chessPiece); handler(this, eventArgs); } }
public PieceTakenEventArgs(Square square, ChessPiece pieceTaken) { this.Square = square; this.PieceTaken = pieceTaken; }
/// <summary> /// Add a chess piece to the board at a given position. /// </summary> /// <param name="boardPosition">The initial position at which to place the chess piece</param> /// <param name="chessPiece">The chess piece to be placed</param> public void SetInitialPosition(BoardPosition boardPosition, ChessPiece chessPiece) { Square square = GetSquare(boardPosition); if (square.ChessPiece != null) { var ex = new ChessBoardException(ExceptionReason.InitialPositionAlreadyOccupied); throw ex; } square.ChessPiece = chessPiece; chessPiece.BoardPosition = boardPosition; }
public MoveMadeEventArgs(BoardPosition from, BoardPosition to, ChessPiece chessPiece) { this.From = from; this.To = to; this.ChessPiece = chessPiece; }