Exemplo n.º 1
0
        public void TestPossibleMoves()
        {
            ChessBoard board = new ChessBoard();

            board.SetDefaultChessBoard();
            Assert.IsTrue(FIDEnotation.CheckIfArePossibleMoves(board, true));
            Assert.IsTrue(FIDEnotation.CheckIfArePossibleMoves(board, false));
        }
Exemplo n.º 2
0
        //TO DO drawns

        static void Main(string[] args)
        {
            ChessBoard gameboard = new ChessBoard();

            gameboard.SetDefaultChessBoard();
            DefaultInfo.SetDefaultValues();
            string        notation  = "";
            List <string> gamestory = new List <string>();
            string        move      = "";
            // Code Review: Назва локальної змінної повинна починатися з малої літери.
            int NumberOfMoves = 1;
            int rows          = 20;
            int rowwidth      = 20;

            //Draw.DrawChessBoard(gameboard);
            Console.Title = "Dan's True Chess Game";
            do
            {
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                if (DefaultInfo.IsWhiteMove)
                {
                    if (!FIDEnotation.CheckIfArePossibleMoves(gameboard, true))
                    {
                        if (!WhiteKing.IsSafe(gameboard))
                        {
                            DefaultInfo.BlackWin = true;
                        }
                        break;
                    }
                    WhiteMove(ref gameboard, ref notation, ref move);
                }
                else
                {
                    if (!FIDEnotation.CheckIfArePossibleMoves(gameboard, false))
                    {
                        if (!BlackKing.IsSafe(gameboard))
                        {
                            DefaultInfo.WhiteWin = true;
                        }

                        break;
                    }
                    BlackMove(ref gameboard, ref notation, gamestory, ref move, ref NumberOfMoves);
                }
            }while (true);

            if (DefaultInfo.WhiteWin)
            {
                gamestory[gamestory.Count] += "+";
                move = " ";
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                Console.WriteLine("White win!");
            }
            if (DefaultInfo.BlackWin)
            {
                gamestory[gamestory.Count - 1] += "+";
                move = " ";
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                Console.WriteLine("Black win!");
            }
            else
            {
                gamestory[gamestory.Count] += "=";
                move = " ";
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                Console.WriteLine("Draw");
            }
        }