示例#1
0
        public void EvolvePokemon(PokemonCard basePokemon, PokemonCard evolution, bool ignoreAllChecks = false)
        {
            if (!ignoreAllChecks && !ActivePlayer.Id.Equals(basePokemon.Owner.Id) || !ActivePlayer.Id.Equals(evolution.Owner.Id))
            {
                GameLog.AddMessage("Evolution stopped by epic 1337 anti-cheat");
                return;
            }

            if (!ignoreAllChecks && GetAllPassiveAbilities().Any(ability => ability.ModifierType == PassiveModifierType.StopEvolutions))
            {
                GameLog.AddMessage("Evolution stopped by ability");
                return;
            }

            if (!ignoreAllChecks && (!basePokemon.CanEvolve() || !basePokemon.CanEvolveTo(evolution)))
            {
                return;
            }

            GameLog.AddMessage($"Evolving {basePokemon.GetName()} to {evolution.GetName()}");

            if (ActivePlayer.ActivePokemonCard.Id.Equals(basePokemon.Id))
            {
                basePokemon.Evolve(evolution);
                ActivePlayer.ActivePokemonCard = evolution;
                evolution.EvolvedThisTurn      = true;
            }
            else
            {
                basePokemon.Evolve(evolution);
                evolution.EvolvedThisTurn = true;
                ActivePlayer.BenchedPokemon.ReplaceWith(basePokemon, evolution);
            }

            bool triggerEnterPlay = false;

            if (ActivePlayer.Hand.Contains(evolution))
            {
                ActivePlayer.Hand.Remove(evolution);
                triggerEnterPlay = true;
            }

            evolution.RevealToAll();

            SendEventToPlayers(new PokemonEvolvedEvent
            {
                TargetPokemonId = basePokemon.Id,
                NewPokemonCard  = evolution
            });

            if (triggerEnterPlay)
            {
                TriggerAbilityOfType(TriggerType.EnterPlay, evolution);
            }

            PushGameLogUpdatesToPlayers();
        }