using System.Collections; using System.Collections.Generic; using System.Linq; //Sayo namespace DCGO.CardEffects.BT22 { public class BT22_102 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Start of Main Phase if (timing == EffectTiming.OnStartMainPhase) { cardEffects.Add(CardEffectFactory.Gain1MemoryTamerOpponentDigimonEffect(card)); } #endregion #region Your Turn if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Digivolve for a reduced cost", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[Your Turn] When one of your Digimon with 2 or more same-level cards in its stack attacks, by suspending this Tamer, digivolve it into a Digimon card with the [Night Claw], [Light Fang], [Galaxy] or [CS] trait in the trash with the digivolution cost reduced by 2."; } bool AttackingPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)) { return permanent.StackCards .Filter(x => !x.IsFlipped) .GroupBy(x => x.Level) .Any(g => g.Count() >= 2); } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanentCondition)) { return true; } } } return false; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.CanActivateSuspendCostEffect(card); } IEnumerator ActivateCoroutine(Hashtable _hashtable) { CardEffectCommons.EnforceLocationCheck(); yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap()); Permanent attackingPermanent = CardEffectCommons.GetAttackerFromHashtable(_hashtable); bool CanSelectDigivolveTarget(CardSource source) { return (source.HasLightFangOrNightClawTraits || source.HasGalaxyTraits || source.HasCSTraits) && source.CanPlayCardTargetFrame(attackingPermanent.PermanentFrame, true, activateClass, SelectCardEffect.Root.Trash); } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard( targetPermanent: attackingPermanent, cardCondition: CanSelectDigivolveTarget, payCost: true, reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null), fixedCostTuple: null, ignoreDigivolutionRequirementFixedCost: -1, isHand: false, activateClass: activateClass, successProcess: null)); } } #endregion #region Security if (timing == EffectTiming.SecuritySkill) { cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card)); } #endregion return cardEffects; } } }