Exemplo n.º 1
0
        public bool ChecktestWhite(GameBoard _Game)
        {
            int  i;
            King Kingmover1 = new King("White");

            for (i = 0; i < _Game.White.Count; i++)
            {
                if (_Game.White[i].GetType().ToString().Contains("King"))
                {
                    Kingmover1 = (King)_Game.White[i];
                    break;
                }
            }
            Coordinate _Next = Kingmover1.Current;
            string     typecheck;

            for (i = 0; i < _Game.Black.Count; i++)
            {
                typecheck = _Game.Black[i].GetType().ToString();
                if (_Game.Black[i].Current.X == 99)
                {
                    continue;
                }
                switch (typecheck)
                {
                case "Chess.Pawn":
                    Pawn Pawnmover = new Pawn("a");
                    Pawnmover = (Pawn)_Game.Black[i];
                    if (Pawnmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.Bishop":
                    Bishop Bishopmover = new Bishop("a");
                    Bishopmover = (Bishop)_Game.Black[i];
                    if (Bishopmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.Queen":
                    Queen Queenmover = new Queen("a");
                    Queenmover = (Queen)_Game.Black[i];
                    if (Queenmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.Knight":
                    Knight Knightmover = new Knight("a");
                    Knightmover = (Knight)_Game.Black[i];
                    if (Knightmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }

                    break;

                case "Chess.Castle":
                    Castle Castlemover = new Castle("a");
                    Castlemover = (Castle)_Game.Black[i];
                    if (Castlemover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.King":
                    King Kingmover2 = new King("a");
                    Kingmover2 = (King)_Game.Black[i];
                    if (Kingmover2.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool MatetestforWhite(GameBoard Game, Empty Emptyspace, Check Checker)
        {
            Coordinate CurrentCoord = new Coordinate();
            Coordinate NextCoord    = new Coordinate();

            for (int i = 0; i < Game.White.Count; i++)
            {
                string typecheck = Game.White[i].GetType().ToString();

                CurrentCoord.X = Game.White[i].Current.X;
                CurrentCoord.Y = Game.White[i].Current.Y;
                for (byte j = 0; j < 8; j++)
                {
                    NextCoord.X = j;
                    for (byte k = 0; k < 8; k++)
                    {
                        NextCoord.Y = k;
                        switch (typecheck)
                        {
                        case "Chess.Pawn":
                            Pawn Pawnmover = new Pawn("WHITE");
                            Pawnmover = (Pawn)Game.Chessboard[CurrentCoord.X, CurrentCoord.Y];
                            if (Pawnmover.isMovable(Game, NextCoord))
                            {
                                Game.Chessboard[CurrentCoord.X, CurrentCoord.Y].Move(Game, CurrentCoord, NextCoord, Emptyspace);
                                if (!(Checker.Checktest(Game, NextCoord)))
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                }
                                else
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                    return(true);
                                }
                            }

                            break;

                        case "Chess.Bishop":

                            Bishop Bishopmover = new Bishop("a");
                            Bishopmover = (Bishop)Game.Chessboard[CurrentCoord.X, CurrentCoord.Y];
                            if (Bishopmover.isMovable(Game, NextCoord))
                            {
                                Game.Chessboard[CurrentCoord.X, CurrentCoord.Y].Move(Game, CurrentCoord, NextCoord, Emptyspace);
                                if (!(Checker.Checktest(Game, NextCoord)))
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                }
                                else
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                    return(true);
                                }
                            }
                            break;

                        case "Chess.Queen":

                            Queen Queenmover = new Queen("a");
                            Queenmover = (Queen)Game.Chessboard[CurrentCoord.X, CurrentCoord.Y];
                            if (Queenmover.isMovable(Game, NextCoord))
                            {
                                Game.Chessboard[CurrentCoord.X, CurrentCoord.Y].Move(Game, CurrentCoord, NextCoord, Emptyspace);
                                if (!(Checker.Checktest(Game, NextCoord)))
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                }
                                else
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                    return(true);
                                }
                            }
                            break;

                        case "Chess.Knight":

                            Knight Knightmover = new Knight("a");
                            Knightmover = (Knight)Game.Chessboard[CurrentCoord.X, CurrentCoord.Y];
                            if (Knightmover.isMovable(Game, NextCoord))
                            {
                                Game.Chessboard[CurrentCoord.X, CurrentCoord.Y].Move(Game, CurrentCoord, NextCoord, Emptyspace);
                                if (!(Checker.Checktest(Game, NextCoord)))
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                }
                                else
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                    return(true);
                                }
                            }
                            break;

                        case "Chess.Castle":

                            Castle Castlemover = new Castle("a");
                            Castlemover = (Castle)Game.Chessboard[CurrentCoord.X, CurrentCoord.Y];
                            if (Castlemover.isMovable(Game, NextCoord))
                            {
                                Game.Chessboard[CurrentCoord.X, CurrentCoord.Y].Move(Game, CurrentCoord, NextCoord, Emptyspace);
                                if (!(Checker.Checktest(Game, NextCoord)))
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                }
                                else
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                    return(true);
                                }
                            }
                            break;

                        case "Chess.King":

                            King Kingmover = new King("a");
                            Kingmover = (King)Game.Chessboard[CurrentCoord.X, CurrentCoord.Y];
                            if (Kingmover.isMovable(Game, NextCoord))
                            {
                                Game.Chessboard[CurrentCoord.X, CurrentCoord.Y].Move(Game, CurrentCoord, NextCoord, Emptyspace);
                                if (!(Checker.Checktest(Game, NextCoord)))
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                }
                                else
                                {
                                    Game.LastmoveReverser(Game, CurrentCoord, NextCoord, Emptyspace);
                                    return(true);
                                }
                            }


                            break;
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public bool ChecktestforRookBlack(GameBoard _Game, byte _X, byte _Y)
        {
            int i;

            for (i = 0; i < _Game.White.Count; i++)
            {
                Coordinate _Next     = new Coordinate(_X, _Y);
                string     typecheck = _Game.White[i].GetType().ToString();
                switch (typecheck)
                {
                case "Chess.Pawn":
                    Pawn Pawnmover = new Pawn("a");
                    Pawnmover = (Pawn)_Game.White[i];
                    if (Pawnmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.Bishop":
                    Bishop Bishopmover = new Bishop("a");
                    Bishopmover = (Bishop)_Game.White[i];
                    if (Bishopmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.Queen":
                    Queen Queenmover = new Queen("a");
                    Queenmover = (Queen)_Game.White[i];
                    if (Queenmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.Knight":
                    Knight Knightmover = new Knight("a");
                    Knightmover = (Knight)_Game.White[i];
                    if (Knightmover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }

                    break;

                case "Chess.Castle":
                    Castle Castlemover = new Castle("a");
                    Castlemover = (Castle)_Game.White[i];
                    if (Castlemover.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;

                case "Chess.King":
                    King Kingmover2 = new King("a");
                    Kingmover2 = (King)_Game.White[i];
                    if (Kingmover2.isMovable(_Game, _Next))
                    {
                        return(true);
                    }
                    break;
                }
            }

            return(false);
        }
Exemplo n.º 4
0
        public void Run(GameBoard Game, Coordinate Current, Coordinate Next, Check Checker, Empty Emptyspace)
        {
            string typecheck;

            typecheck = Game.Chessboard[Current.X, Current.Y].GetType().ToString();

            switch (typecheck)
            {
            case "Chess.Pawn":
                Pawn Pawnmover = new Pawn("WHITE");
                Pawnmover = (Pawn)Game.Chessboard[Current.X, Current.Y];
                if (Pawnmover.isMovable(Game, Next))
                {
                    Game.Chessboard[Current.X, Current.Y].Move(Game, Current, Next, Emptyspace);
                    if (!(Checker.Checktest(Game, Next)))
                    {
                        Game.LastmoveReverser(Game, Current, Next, Emptyspace);
                    }
                    else
                    {
                        anyChanges = true;
                    }
                }

                break;

            case "Chess.Bishop":

                Bishop Bishopmover = new Bishop("a");
                Bishopmover = (Bishop)Game.Chessboard[Current.X, Current.Y];
                if (Bishopmover.isMovable(Game, Next))
                {
                    Game.Chessboard[Current.X, Current.Y].Move(Game, Current, Next, Emptyspace);
                    if (!(Checker.Checktest(Game, Next)))
                    {
                        Game.LastmoveReverser(Game, Current, Next, Emptyspace);
                    }
                    else
                    {
                        anyChanges = true;
                    }
                }
                break;

            case "Chess.Queen":

                Queen Queenmover = new Queen("a");
                Queenmover = (Queen)Game.Chessboard[Current.X, Current.Y];
                if (Queenmover.isMovable(Game, Next))
                {
                    Game.Chessboard[Current.X, Current.Y].Move(Game, Current, Next, Emptyspace);
                    if (!(Checker.Checktest(Game, Next)))
                    {
                        Game.LastmoveReverser(Game, Current, Next, Emptyspace);
                    }
                    else
                    {
                        anyChanges = true;
                    }
                }
                break;

            case "Chess.Knight":

                Knight Knightmover = new Knight("a");
                Knightmover = (Knight)Game.Chessboard[Current.X, Current.Y];
                if (Knightmover.isMovable(Game, Next))
                {
                    Game.Chessboard[Current.X, Current.Y].Move(Game, Current, Next, Emptyspace);
                    if (!(Checker.Checktest(Game, Next)))
                    {
                        Game.LastmoveReverser(Game, Current, Next, Emptyspace);
                    }
                    else
                    {
                        anyChanges = true;
                    }
                }
                break;

            case "Chess.Castle":

                Castle Castlemover = new Castle("a");
                Castlemover = (Castle)Game.Chessboard[Current.X, Current.Y];
                if (Castlemover.isMovable(Game, Next))
                {
                    Game.Chessboard[Current.X, Current.Y].Move(Game, Current, Next, Emptyspace);
                    if (!(Checker.Checktest(Game, Next)))
                    {
                        Game.LastmoveReverser(Game, Current, Next, Emptyspace);
                    }
                    else
                    {
                        anyChanges = true;
                    }
                }
                break;

            case "Chess.King":

                King Kingmover = new King("a");
                Kingmover = (King)Game.Chessboard[Current.X, Current.Y];
                if (Kingmover.isMovable(Game, Next))
                {
                    Game.Chessboard[Current.X, Current.Y].Move(Game, Current, Next, Emptyspace);
                    if (!(Checker.Checktest(Game, Next)))
                    {
                        Game.LastmoveReverser(Game, Current, Next, Emptyspace);
                    }
                    else
                    {
                        anyChanges = true;
                    }
                }

                else if (Kingmover.Rooktest1(Game, Current, Next, Emptyspace) && Checker.Checktest(Game, Current))
                {
                    Game.Chessboard[Current.X, Current.Y].Rookmover1(Game, Current, Next, Emptyspace);
                    anyChanges = true;
                }

                else if (Kingmover.Rooktest2(Game, Current, Next, Emptyspace) && Checker.Checktest(Game, Current))
                {
                    Game.Chessboard[Current.X, Current.Y].Rookmover2(Game, Current, Next, Emptyspace);
                    anyChanges = true;
                }

                break;
            }
            if (CommonProperties.enPassantfinder + 1 > Game.White.Count || CommonProperties.enPassantfinder + 1 > Game.Black.Count)
            {
                CommonProperties.enPassantfinder = 0;
            }
            if (Game.White[CommonProperties.enPassantfinder].enPassantchecker == 2)
            {
                Game.White[CommonProperties.enPassantfinder].enPassantchecker -= 1;
            }
            else if (Game.White[CommonProperties.enPassantfinder].enPassantchecker == 1)
            {
                Game.White[CommonProperties.enPassantfinder].enPassantchecker -= 1;
            }
            if (Game.Black[CommonProperties.enPassantfinder].enPassantchecker == 2)
            {
                Game.Black[CommonProperties.enPassantfinder].enPassantchecker -= 1;
            }
            else if (Game.Black[CommonProperties.enPassantfinder].enPassantchecker == 1)
            {
                Game.Black[CommonProperties.enPassantfinder].enPassantchecker -= 1;
            }
        }