コード例 #1
0
        protected string ConvertFigure(Chessman chessman)
        {
            switch (chessman?.GetType().Name)
            {
            case nameof(Bishop):
                return(Figure.Bishop);

            case nameof(King):
                return(Figure.King);

            case nameof(Queen):
                return(Figure.Queen);

            case nameof(Rook):
                return(Figure.Rook);

            case nameof(Pawn):
                return(Figure.Pawn);

            case nameof(Knight):
                return(Figure.Knight);

            default:
                return(null);
            }
        }
コード例 #2
0
        public void RemoveChessman(Chessman chessman)
        {
            var figures = chessman.GetColor() == Color.White ? _whiteFigures : _blackFigures;

            if (!figures.Remove(chessman))
            {
                throw new RemoveChessmanException($"{chessman.GetColor()} {typeof(Chessman)} not found on the board");
            }
        }
コード例 #3
0
 public void SetChessman(string location, Chessman chessman)
 {
     _board[location] = chessman;
 }