Ejemplo n.º 1
0
        public NumPieces GetNumPieces()
        {
            NumPieces numPiece = 0;

            switch (Type)
            {
            case PieceType.Pawn:
                numPiece = (Color == Color.White) ? NumPieces.WhitePawn : NumPieces.BlackPawn;
                break;

            case PieceType.Knight:
                numPiece = (Color == Color.White) ? NumPieces.WhiteKnight : NumPieces.BlackKnight;
                break;

            case PieceType.Bishop:
                numPiece = (Color == Color.White) ? NumPieces.WhiteBishop : NumPieces.BlackBishop;
                break;

            case PieceType.Rook:
                numPiece = (Color == Color.White) ? NumPieces.WhiteRook : NumPieces.BlackRook;
                break;

            case PieceType.Queen:
                numPiece = (Color == Color.White) ? NumPieces.WhiteQueen : NumPieces.BlackQueen;
                break;

            case PieceType.King:
                numPiece = (Color == Color.White) ? NumPieces.WhiteKing : NumPieces.BlackKing;
                break;
            }

            return(numPiece);
        }
Ejemplo n.º 2
0
 public IPiece this[string positionString]
 {
     get
     {
         Position position = new Position(positionString);
         return(new Piece(Board[position.Row, position.Column]));
     }
     set
     {
         Piece     piece    = new Piece(value);
         NumPieces numPiece = piece.GetNumPieces();
         SetPiece(positionString, numPiece);
     }
 }
Ejemplo n.º 3
0
        public static void GetMoveList(Board board, int row, int column, NumPieces piece, Color color, MoveList moveList)
        {
            switch (piece)
            {
            case NumPieces.BlackKing:
            case NumPieces.WhiteKing:
                King.GetMoveList(board, row, column, color, moveList);
                break;

            case NumPieces.BlackRook:
            case NumPieces.WhiteRook:
                Rook.GetMoveList(board, row, column, color, moveList);
                break;
            }
        }
Ejemplo n.º 4
0
        public static bool ExecuteMove(Board board, Move move)
        {
            int startRow    = move.StartRow;
            int startColumn = move.StartColumn;
            int endRow      = move.EndRow;
            int endColumn   = move.EndColumn;

            NumPieces piece = board[startRow, startColumn];

            board[endRow, endColumn]     = piece;
            board[startRow, startColumn] = NumPieces.Empty;

            switch (piece)
            {
            case NumPieces.WhiteKing:
                King.MoveWhiteKing(board, endRow, endColumn);
                break;

            case NumPieces.BlackKing:
                King.MoveBlackKing(board, endRow, endColumn);
                break;

            case NumPieces.WhitePawn:
                break;

            case NumPieces.BlackPawn:
                break;

            case NumPieces.WhiteRook:
                Rook.MoveWhiteRook(board, startRow, startColumn);
                break;

            case NumPieces.BlackRook:
                Rook.MoveWhiteRook(board, startRow, startColumn);
                break;
            }

            return(true);
        }
Ejemplo n.º 5
0
        public Piece(NumPieces piece)
        {
            switch (piece)
            {
            case NumPieces.WhitePawn:
                Type  = PieceType.Pawn;
                Color = Color.White;
                break;

            case NumPieces.WhiteKnight:
                Type  = PieceType.Knight;
                Color = Color.White;
                break;

            case NumPieces.WhiteKing:
                Type  = PieceType.King;
                Color = Color.White;
                break;

            case NumPieces.WhiteQueen:
                Type  = PieceType.Queen;
                Color = Color.White;
                break;

            case NumPieces.WhiteBishop:
                Type  = PieceType.Bishop;
                Color = Color.White;
                break;

            case NumPieces.WhiteRook:
                Type  = PieceType.Rook;
                Color = Color.White;
                break;

            case NumPieces.BlackPawn:
                Type  = PieceType.Pawn;
                Color = Color.Black;
                break;

            case NumPieces.BlackKnight:
                Type  = PieceType.Knight;
                Color = Color.Black;
                break;

            case NumPieces.BlackKing:
                Type  = PieceType.King;
                Color = Color.Black;
                break;

            case NumPieces.BlackQueen:
                Type  = PieceType.Queen;
                Color = Color.Black;
                break;

            case NumPieces.BlackBishop:
                Type  = PieceType.Bishop;
                Color = Color.Black;
                break;

            case NumPieces.BlackRook:
                Type  = PieceType.Rook;
                Color = Color.Black;
                break;
            }
        }
Ejemplo n.º 6
0
        private void SetPiece(string positionString, NumPieces piece)
        {
            Position position = new Position(positionString);

            Board[position.Row, position.Column] = piece;
        }
Ejemplo n.º 7
0
        public IPiece GetPiece(Position position)
        {
            NumPieces numPiece = Board[position.Row, position.Column];

            return(new Piece(numPiece));
        }