/// <summary> /// Returns a PieceManager from given position. /// </summary> /// <param name="x">Horizontal coordinate.</param> /// <param name="y">Vertical coordinate.</param> /// <returns>PieceManager from given position.</returns> public IPieceManager GetPiece(int x, int y) { Piece p = board.GetPiece(new Point(x, y)); if (p is null) { return(new EmptyPieceManager(x, y, game)); } return(new PieceManager(p, game)); }
/// <summary> /// Checks whether Piece can be moved to given position. /// </summary> /// <param name="position">Movement destination.</param> /// <returns></returns> public virtual bool canMoveTo(Point position) { if (!this.board.CoordinateIsInRange(position)) { return(false); } if (pretendMoveAndCheckIfKingIsChecked(position)) { return(false); } if (CanAchieve(position, MoveSet) && board.GetPiece(position) == null) { return(true); } if (CanAchieve(position, KillSet) && board.GetPiece(position) != null) { if (board.GetPiece(position).Color != this.Color) { return(true); } } return(false); }