Example #1
0
        /// <summary>
        /// Handles a fight between two Heroes. When the fight is lost, the game ends. When the fight is won, the player gets a random item and levels up.
        /// </summary>
        /// <param name="hero">The opponent</param>
        private static void Fight(Hero hero, Hero opponent, double herosLuck, double opponentsLuck)
        {
            GameWriter.OpponentDescriptionMessage(opponent.GetType().Name, opponent.DPS);

            GameWriter.PressKeyToContinue();

            if (hero.DPS * herosLuck < opponent.DPS * opponentsLuck)
            {
                GameWriter.GameLostMessage();
                GameWriter.EndGameMessage(hero.Name);
                Environment.Exit(0);
                return;
            }

            GameWriter.GameWonMessage();

            GameWriter.PressKeyToContinue();

            hero.LevelUp(1);
            GameWriter.LevelUpMessage(hero.Level);

            GameWriter.PressKeyToContinue();

            HandleFoundItem(hero);
        }