/// <summary> /// Adds an <see cref="IChessPiece"/> to the board /// </summary> /// <param name="piece">An implementation of <see cref="IChessPiece"/> to add to the game board</param> /// <param name="xCoordinate">The X coordinate the piece takes up</param> /// <param name="yCoordinate">The Y coordinate the piece takes up</param> /// <returns>True if the piece was successfully added</returns> public bool Add(IChessPiece piece, int xCoordinate, int yCoordinate) { if (piece == null) { return(false); } if (m_pieceContainer == null) { m_pieceContainer = new ChessPieceContainer(); } if (!IsLegalBoardPosition(xCoordinate, yCoordinate) || !piece.IsValidStartingPosition(xCoordinate, yCoordinate) || !m_pieceContainer.HasCapacityFor(piece) || m_pieceContainer.GetPieceAtCoordinates(xCoordinate, yCoordinate) != null) { piece.XCoordinate = -1; piece.YCoordinate = -1; return(false); } m_pieceContainer.RegisterPiece(piece, xCoordinate, yCoordinate); return(true); }