Пример #1
0
        private void MainBattleLoop()
        {
            while (true)
            {
                Displayer.DisplayCurrentPokemonInfo(Trainer1CurrentPoke, Trainer2CurrentPoke);
                if (!Trainer1CurrentPoke.IsTrapped && !Trainer1CurrentPoke.Recharging && !Trainer1CurrentPoke.TwoTurnMove && !Trainer1CurrentPoke.Biding &&
                    !Trainer1CurrentPoke.Dancing && !Trainer2CurrentPoke.IsTrapped && !Trainer1CurrentPoke.Biding)
                {
                    SelectAction();
                }

                if (WhoGoesFirst())
                {
                    ExecuteAttack(Trainer1CurrentPoke, Trainer2CurrentPoke, Trainer1);
                    ExecuteAttack(Trainer2CurrentPoke, Trainer1CurrentPoke, Trainer2);
                }
                else
                {
                    ExecuteAttack(Trainer2CurrentPoke, Trainer1CurrentPoke, Trainer2);
                    ExecuteAttack(Trainer1CurrentPoke, Trainer2CurrentPoke, Trainer1);
                }

                Trainer1CurrentPoke.ClickTurn();
                Trainer2CurrentPoke.ClickTurn();
                Trainer1.UpdateTurn();
                Trainer2.UpdateTurn();

                if (!Trainer1CurrentPoke.IsAlive)
                {
                    if (Trainer1.RemainingPokemon == 0)
                    {
                        Displayer.RelayMessage("And there goes the battle..");
                        Displayer.RelayMessage("Trainer 1 is out of pokemon!");
                        return;
                    }

                    Trainer1.PokeDied();
                    while (!PickSwitch())
                    {
                        ;
                    }
                    Trainer1.FinishSwitch();
                }

                if (!Trainer2CurrentPoke.IsAlive)
                {
                    Trainer2.PokeDied();

                    if (Trainer2.RemainingPokemon == 0)
                    {
                        Displayer.RelayMessage("And there goes the battle..");
                        Displayer.RelayMessage("Trainer 2 is out of pokemon!");
                        return;
                    }

                    Trainer2CurrentPoke = Trainer2.Party.First(p => p.IsAlive == true);
                    Trainer2.Switch(Trainer2.Party.IndexOf(Trainer2CurrentPoke), Trainer2CurrentPoke);
                    Displayer.RelayMessage($"The Foe threw out {Trainer2CurrentPoke.Name}");
                    Trainer2.FinishSwitch();
                }
                Displayer.ClearScreen();
            }
        }