Exemplo n.º 1
0
        public void Start()
        {
            Grid grid     = new Grid();
            bool gameOver = false;

            grid.GameOverReached += (sender, e) =>
            {
                Console.WriteLine(Environment.NewLine + "Draw!");
            };

            while (!gameOver)
            {
                Console.Clear();
                grid.PlaceMarker();
                gameOver = grid.isGameOver();
                grid.Round++;
            }

            Console.Clear();
            grid.PrintGrid();
            if (grid.gameWon)
            {
                Console.WriteLine("Game over! Player {0} won", grid.ActivePlayer);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Grid        gameGrid = new Grid();
            GameControl Game     = new GameControl(gameGrid);
            Human       human    = new Human("X");
            Computer    computer = new Computer("O", gameGrid);
            //Human human2 = new Human("O");

            Queue <Player> Turn = new Queue <Player>();

            Turn.Enqueue(human);
            //Turn.Enqueue(human2);
            Turn.Enqueue(computer);

            while (Game.isRunning == true)
            {
                if (Turn.Count == 0)
                {
                    Turn.Enqueue(human);
                    //Turn.Enqueue(human2);
                    Turn.Enqueue(computer);
                }

                var activePlayer = Turn.Dequeue();

                while (!Game.CheckInput(activePlayer.getChoice))
                {
                    activePlayer.Input();
                }

                gameGrid.UpdateGrid(Game.getGridSelection, activePlayer.getPlayerMarker);


                gameGrid.PrintGrid();
                Console.WriteLine(activePlayer.getChoice);

                if (Game.CheckCondition())
                {
                    Game.isRunning = false;
                }
                else if (human.getChoice == "Quit")
                {
                    Game.isRunning = false;
                }
            }

            Console.ReadLine();
        }