Ejemplo n.º 1
0
        public Core.Piece BuildPiece(ilf.pgn.Data.Piece piece)
        {
            if (piece == null)
            {
                return(null);
            }

            var color = piece.Color == Color.White ? PieceColor.White : PieceColor.Black;

            switch (piece.PieceType)
            {
            case ilf.pgn.Data.PieceType.King:
                return(new King(color));

            case ilf.pgn.Data.PieceType.Queen:
                return(new Queen(color));

            case ilf.pgn.Data.PieceType.Rook:
                return(new Rook(color));

            case ilf.pgn.Data.PieceType.Bishop:
                return(new Bishop(color));

            case ilf.pgn.Data.PieceType.Knight:
                return(new Knight(color));

            case ilf.pgn.Data.PieceType.Pawn:
                return(new Pawn(color));
            }

            return(null);
        }
Ejemplo n.º 2
0
        private string PieceToString(Piece p)
        {
            if (p == null) return "   ";

            var str="";
            switch (p.PieceType)
            {
                case PieceType.Pawn:
                    str = " p ";
                    break;
                case PieceType.Knight:
                    str = " n ";
                    break;
                case PieceType.Bishop:
                    str = " b ";
                    break;
                case PieceType.Rook:
                    str = " r ";
                    break;
                case PieceType.Queen:
                    str = " q ";
                    break;
                case PieceType.King:
                    str = " k ";
                    break;
            }

            if (p.Color == Color.White)
                return str.ToUpper();

            return str;
        }