Beispiel #1
0
        public static void ChallengeRival(PokemonTrainer userTrainer)
        {
            List <string> userChoices = new List <string>();

            for (int i = 1; i < 11; i++)
            {
                double timePassed      = .25 * Math.Pow(i, 1.9);
                int    yearsPassed     = (int)timePassed;
                int    remainingMonths = (int)((timePassed - yearsPassed) * 12);
                string monthName       = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(remainingMonths + 1);

                userChoices.Add($"Bary Yoke in {monthName}, {2000 + yearsPassed}");
            }

            int userInputIndex = Menu.GetUserInputIndex(userChoices, true);

            if (userInputIndex == -1)
            {
                return;
            }

            RivalTrainer rival = new RivalTrainer("Bary Yoke", userInputIndex + 1);

            rival.SetPokemons(userTrainer.StarterPokemon);
            rival.Introduction(userTrainer);
            Battle.FightTrainer(userTrainer, rival);
        }
Beispiel #2
0
        public static void FightTrainer(PokemonTrainer userTrainer, RivalTrainer opponentTrainer)
        {
            int nextPokemonIndex = 1;

            List <string> menuChoices = new List <string> {
                "Attack", "Change Popokenom", "Item", "Run"
            };

            Console.WriteLine($"{opponentTrainer.Name}: My {opponentTrainer.StarterPokemon} will beat your {userTrainer.StarterPokemon} for sure.");
            while (!opponentTrainer.AllPokemonsFainted() && !userTrainer.AllPokemonsFainted())
            {
                if (userTrainer.PokemonOut.Hp == 0)
                {
                    ChangePokemon(userTrainer, false);
                }
                if (opponentTrainer.PokemonOut.Hp == 0)
                {
                    Console.WriteLine($"{opponentTrainer.PokemonOut.Name} fainted.");
                    userTrainer.PokemonOut.GainExp(opponentTrainer.PokemonOut.ExpReleased);
                    Console.WriteLine($"{opponentTrainer.Name}: You did well, {opponentTrainer.PokemonOut.Name}.");
                    opponentTrainer.SwapPokemons(0, nextPokemonIndex++);
                    Console.WriteLine($"{opponentTrainer.Name}: {opponentTrainer.PokemonOut.Name}, let's catch up the slack!");
                }

                int userInputIndex = Menu.GetUserInputIndex(menuChoices, false);
                switch (userInputIndex)
                {
                case 0:
                    Attack(userTrainer.PokemonOut, opponentTrainer.PokemonOut);
                    break;

                case 1:
                    Pokemon initialPokemon = userTrainer.PokemonOut;
                    ChangePokemon(userTrainer, true);
                    if (initialPokemon == userTrainer.PokemonOut)
                    {
                        break;
                    }
                    OpponentMightAttack(userTrainer.PokemonOut, opponentTrainer.PokemonOut);
                    break;

                case 2:
                    InteractWithItems(userTrainer.PokemonOut, userTrainer, opponentTrainer.PokemonOut);
                    break;

                case 3:
                    Console.WriteLine($"{opponentTrainer.Name}: You can't run away from me, {userTrainer.Name}.");
                    break;
                }
            }
            if (opponentTrainer.AllPokemonsFainted())
            {
                Console.WriteLine($"{opponentTrainer.Name}: I'll have you next time.");
                userTrainer.Money += opponentTrainer.MoneyRewarded;
                Console.WriteLine($"{userTrainer.Name} earned ${opponentTrainer.MoneyRewarded}.");
            }
        }