Ejemplo n.º 1
0
        public Board()
        {
            // Initialize
            WhitePieces = new List <Piece>();
            BlackPieces = new List <Piece>();

            // White Pieces
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(0, 0), ChessColor.White, PieceType.Rook));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(1, 0), ChessColor.White, PieceType.Knight));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(2, 0), ChessColor.White, PieceType.Bishop));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(3, 0), ChessColor.White, PieceType.Queen));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(4, 0), ChessColor.White, PieceType.King));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(5, 0), ChessColor.White, PieceType.Bishop));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(6, 0), ChessColor.White, PieceType.Knight));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(7, 0), ChessColor.White, PieceType.Rook));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(0, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(1, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(2, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(3, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(4, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(5, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(6, 1), ChessColor.White, PieceType.Pawn));
            WhitePieces.Add(PieceFactory.CreatePiece(new Position(7, 1), ChessColor.White, PieceType.Pawn));

            // Black Pieces
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(0, 7), ChessColor.Black, PieceType.Rook));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(1, 7), ChessColor.Black, PieceType.Knight));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(2, 7), ChessColor.Black, PieceType.Bishop));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(3, 7), ChessColor.Black, PieceType.Queen));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(4, 7), ChessColor.Black, PieceType.King));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(5, 7), ChessColor.Black, PieceType.Bishop));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(6, 7), ChessColor.Black, PieceType.Knight));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(7, 7), ChessColor.Black, PieceType.Rook));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(0, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(1, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(2, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(3, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(4, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(5, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(6, 6), ChessColor.Black, PieceType.Pawn));
            BlackPieces.Add(PieceFactory.CreatePiece(new Position(7, 6), ChessColor.Black, PieceType.Pawn));
        }
Ejemplo n.º 2
0
        // TODO: Create UI Popup To Allow Player To Select Promotion Type
        private void CheckPawnPromotion()
        {
            int y;

            if (CurrentPlayer == ChessColor.White)
            {
                // Promotion Row For White
                y = 7;
            }
            else
            {
                // Promotion Row For Black
                y = 0;
            }

            for (int x = 0; x < GlobalConstants.BoardLength; ++x)
            {
                if (Board.GetPieceAt(x, y) != null && Board.GetPieceAt(x, y).Type == PieceType.Pawn)
                {
                    Board.GetPieceList(CurrentPlayer).Remove(Board.GetPieceAt(x, y));
                    Board.GetPieceList(CurrentPlayer).Add(PieceFactory.CreatePiece(new Position(x, y), CurrentPlayer, PieceType.Queen));
                }
            }
        }
Ejemplo n.º 3
0
 public Move(Piece moved, Position origin, Position destination)
 {
     this.Moved       = PieceFactory.CopyPiece(moved);
     this.Origin      = origin;
     this.Destination = destination;
 }
Ejemplo n.º 4
0
 public void CaptureUndo(Piece moved, Piece captured, Position destination)
 {
     RemovePieceAt(destination);
     AddPieceToBoard(PieceFactory.CopyPiece(moved));
     AddPieceToBoard(PieceFactory.CopyPiece(captured));
 }
Ejemplo n.º 5
0
 public void NormalUndo(Piece moved, Position origin, Position destination)
 {
     RemovePieceAt(destination);
     AddPieceToBoard(PieceFactory.CopyPiece(moved));
 }