Пример #1
0
        public static void FightPokemon(PokemonTrainer userTrainer, Pokemon opponent)
        {
            List <string> menuChoices = new List <string> {
                "Attack", "Change Popokenom", "Item", "Run"
            };

            while (opponent.Hp > 0 && !userTrainer.AllPokemonsFainted())
            {
                if (userTrainer.PokemonOut.Hp == 0)
                {
                    ChangePokemon(userTrainer, false);
                }

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

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

                case 2:
                    InteractWithItems(userTrainer.PokemonOut, userTrainer, opponent);
                    // Opponent faints when it fails to break out of Pokeball.
                    if (opponent.Hp == 0)
                    {
                        return;
                    }
                    break;

                case 3:
                    if (Run(userTrainer.PokemonOut, opponent))
                    {
                        return;
                    }
                    ;
                    break;
                }
            }
            if (opponent.Hp == 0)
            {
                Console.WriteLine($"{opponent.Name} fainted.");
                userTrainer.PokemonOut.GainExp(opponent.ExpReleased);
            }
            else
            {
                Console.WriteLine($"{userTrainer.PokemonOut.Name} fainted.");
            }
        }
Пример #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}.");
            }
        }