Esempio n. 1
0
        public void RetreatActivePokemon(PokemonCard replacementPokemon, List <EnergyCard> payedEnergy, GameField game)
        {
            var retreatStoppers = GetAllPokemonCards().SelectMany(pokemon => pokemon.TemporaryAbilities.OfType <RetreatStopper>());

            if (!ActivePokemonCard.CanReatreat(game) || retreatStoppers.Any())
            {
                return;
            }

            foreach (var energyCard in payedEnergy)
            {
                ActivePokemonCard.DiscardEnergyCard(energyCard, game);
            }

            var oldActivePokemon = ActivePokemonCard;

            ActivePokemonCard = replacementPokemon;

            ClearAbilitiesWhenBenched(oldActivePokemon);

            ActivePokemonCard.DamageStoppers = ActivePokemonCard.DamageStoppers.Where(d => !d.LastsUntilDamageTaken).ToList();
            BenchedPokemon.ReplaceWith(replacementPokemon, oldActivePokemon);

            oldActivePokemon.ClearStatusEffects();

            game?.SendEventToPlayers(new PokemonBecameActiveEvent
            {
                NewActivePokemonId = replacementPokemon.Id,
                ReplacedPokemonId  = oldActivePokemon.Id
            });
        }