Ejemplo n.º 1
0
 public static void EndOfRoundStats(UserPlayer user, AIPlayer computer, IMonsterable monster)
 {
     Console.WriteLine();
     Console.WriteLine("~~~~END OF ROUND STATISTICS~~~~");
     Console.WriteLine();
     Console.WriteLine("Your health: " + user.Health + " HP");
     Console.WriteLine("Your score: " + user.Score + " points");
     Console.WriteLine("Opponent's health: " + computer.Health + " HP");
     Console.WriteLine("Opponent's score: " + computer.Score + " points");
     Console.WriteLine("Monster's health: " + monster.Health + " HP");
 }
Ejemplo n.º 2
0
        public static bool PlayGame()
        {
            int        delayConstant  = 0; // 1000 (1 sec) default, reduce for testing purposes
            UserPlayer userPlayer     = new UserPlayer();
            AIPlayer   computerPlayer = new AIPlayer();

            Console.WriteLine();
            Console.WriteLine("Ready to start? [y/n]");
            string userInput = Console.ReadLine();

            if (userInput.Equals("y"))
            {
                try
                {
                    IMonsterable m = MonsterGenerator.GenerateMonster();
                    while (userPlayer.Health > 0 && computerPlayer.Health > 0 && m.Health > 0)
                    {
                        userPlayer.UserPicksTypeOfCard();
                        Thread.Sleep(delayConstant);
                        computerPlayer.AIPicksTypeOfCard();
                        Thread.Sleep(delayConstant);
                        m.PickPlayerToAttack(userPlayer, computerPlayer);

                        Thread.Sleep(delayConstant);
                        userPlayer.Attack(m);
                        Thread.Sleep(delayConstant);
                        computerPlayer.Attack(m);
                        Thread.Sleep(delayConstant);

                        Menus.EndOfRoundStats(userPlayer, computerPlayer, m);
                    }
                }
                catch (UserDiedException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("You lose!");
                    return(false);
                }
                catch (AIDiedException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("You win!");
                    return(true);
                }
                catch (UserKilled)
                {
                    Console.WriteLine("You killed the monster! You win!");
                    return(true);
                }
                catch (AIKilled)
                {
                    Console.WriteLine("Your opponent killed the monster! You lose!");
                    return(false);
                }
                catch (Exception)
                {
                    Console.WriteLine("An unhandled exception occurred");
                    Thread.Sleep(delayConstant);
                    CardDealer.ResetDealer();
                    PlayGame();
                }
            }
            else
            {
                Console.WriteLine("Sorry, this is not a game for quitters! ¯|_(ツ)_|¯");
                CardDealer.ResetDealer();
                PlayGame();
            }
            Console.ReadLine();
            return(false);
        }