Beispiel #1
0
        public void Play()
        {
            if (isOver)
            {
                isOver = false;
                nbGame++;
                Player = (Player != '1') ? '1' : '2';
                grid.Reset();
            }

            while (!isOver)
            {
                grid.GetNextMove(Player);

                isOver = grid.IsFull() || grid.CheckWin(Player);

                Player = (Player != '1') ? '1' : '2';
            }

            Console.Clear();
            grid.Print();
            Console.WriteLine();
            int winner = grid.GetWinner();

            if (winner == 1)
            {
                Console.WriteLine("Player 1 wins !");
            }
            else if (winner == 2)
            {
                Console.WriteLine("Player 2 wins !");
            }
            else
            {
                Console.WriteLine("Draw");
            }
        }