public static void RunGame()
        {
            var game      = new Game();
            var lastGamer = State.Ball;

            while (game.GameIsOver() == false)
            {
                for (int i = 1; i <= 9; i = i + 3)
                {
                    Console.Write(GetExibition(i, game)); Console.Write("|"); Console.Write($"{GetExibition(i + 1, game)}"); Console.Write("|"); Console.Write($"{GetExibition(i + 2, game)}");
                    Console.WriteLine();
                    Console.Write("-------"); Console.Write("|"); Console.Write("-------"); Console.Write("|"); Console.Write("-------");
                    Console.WriteLine();
                }

                Console.WriteLine("Write your choice...");
                var key   = int.Parse(Console.ReadKey().KeyChar.ToString());
                var gamer = lastGamer == State.Cross ? State.Ball : State.Cross;
                game.FillBox(key, gamer);
                lastGamer = gamer;
                Console.WriteLine();
            }

            var winner = game.GetWinner();

            if (winner.HasValue)
            {
                Console.WriteLine($"And the Winner is {game.GetWinner()}");
            }
            else
            {
                Console.WriteLine($"It's a Draw! ");
                Console.WriteLine($"Deu Velha Boy! ");
            }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine(GetPrintableState());

            while (g.GetWinner() == Winner.GameIsUnfinished)
            {
                int index = int.Parse(Console.ReadLine());
                g.MakeMove(index);

                Console.WriteLine();
                Console.WriteLine(GetPrintableState());
            }
            Console.WriteLine($"Result: {g.GetWinner()}");
            Console.ReadLine();
        }