Exemplo n.º 1
0
        //public void SetupBoard()
        //{
        //}
        private void GetUserInput()
        {
            do
            {

                Console.WriteLine("Player {0}, {1}'s, choose your tile position (1-9):", currentPlayerName, markChar);
                if (int.TryParse(Console.ReadLine(), out validatedInput)) //update to check if 1-9  && validatedInput >=1 && validatedInput<=9
                {
                    var result = _board.PlaceMark(validatedInput, markChar);

                    if (result == BoardPlacementResult.Invalid)
                    {
                        //Console.WriteLine("{0}! that was an invalid number, try another (1-9):", currentPlayerName);
                        Console.WriteLine("{0} that was an invalid number, press a key to continue", currentPlayerName);
                        Console.ReadLine();
                        continue;
                    }

                    if (result == BoardPlacementResult.Overlap)
                    {
                        Console.WriteLine("{0}! that tile has been already chosen, try a different one:", currentPlayerName);
                        Console.WriteLine("{0} press a key to continue", currentPlayerName);
                        Console.ReadLine();
                        continue;

                    }
                   if (result == BoardPlacementResult.OK)
                    {
                         Xplayerturn = !Xplayerturn;
                    }

                }
                else
                {
                    Console.WriteLine("That was not a valid input, try inputting a number (1-9)");
                    continue;
                }

               // DrawBoard();

                gameResult = GameDecisionMaker.EvaluateBoard(_board, markChar);
                if(gameResult == GameDecision.PlayOn )
                {
                    PlayerTurnKeeper();
                }

                DrawBoard();

            } while (gameResult == GameDecision.PlayOn);
            Console.ReadLine();
        }