Beispiel #1
0
        private static void GameLoop(DiceGame diceGame)
        {
            diceGame.StartGame();
            Console.WriteLine($"First roll is: {diceGame.CurrentRoll}");

            while (true)
            {
                Console.Write($"Press UP to guess higher and DOWN to guess lower: ");
                var  guess  = Console.ReadKey();
                bool result = false;
                switch (guess.Key)
                {
                case ConsoleKey.UpArrow:
                    result = diceGame.GuessHigher();
                    break;

                case ConsoleKey.DownArrow:
                    result = diceGame.GuessLower();
                    break;

                default:
                    WriteLine("\nYou have to press UP or DOWN", ConsoleColor.DarkYellow);
                    continue;
                }

                Console.WriteLine($"\nLast roll was: {diceGame.CurrentRoll}");

                if (!diceGame.IsRunning)
                {
                    break;
                }

                if (result)
                {
                    WriteLine("You guessed right!", ConsoleColor.Green);
                }
                else
                {
                    WriteLine("Result was same as last", ConsoleColor.Yellow);
                }
            }
        }
Beispiel #2
0
 public void SetUp()
 {
     _diceGame = new DiceGame(new FakeDice(6, 1));
     _diceGame.StartGame();
     _diceGame.GuessLower();
 }