using System.Collections; using System.Collections.Generic; namespace DCGO.CardEffects.P { public class P_154 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region All Turns if (timing == EffectTiming.WhenRemoveField) { List removedPermanents = new List(); ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Add as bottom source to prevent deletion", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] When another of your Digimon with [Knightmon] in its text would leave the battle area by an opponent's effect, by placing this Digimon as its bottom digivolution card, it doesn't leave."; } bool IsKnightmon(Permanent permanent) { if(CardEffectCommons.IsOwnerPermanent(permanent, card)) { if (permanent != card.PermanentOfThisCard()) return permanent.TopCard.HasText("Knightmon"); } return false; } bool CanSelectPermanentCondition(Permanent permanent) { return removedPermanents.Contains(permanent); } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsKnightmon)) { if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card))) { return true; } } } return false; } bool CanActivateCondition(Hashtable hashtable) { removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(IsKnightmon); return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { if (permanent != null) { yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List() { new Permanent[] { card.PermanentOfThisCard(), permanent } }, false, activateClass).PlacePermanentToDigivolutionCards()); if (CardEffectCommons.IsExistOnBattleArea(card)) { if (permanent.DigivolutionCards.Contains(card)) { permanent.willBeRemoveField = false; permanent.HideHandBounceEffect(); permanent.HideDeckBounceEffect(); permanent.HideWillRemoveFieldEffect(); } } } } } } #endregion #region Blocker - ESS if (timing == EffectTiming.None) { cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null)); } #endregion return cardEffects; } } }