using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.BT14 { public class BT14_044 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); if (timing == EffectTiming.OnStartMainPhase) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Opponent's 1 Digimon gains effect", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[Start of Your Main Phase] 1 of your opponent's Digimon gains \"[All Turns] When this Digimon becomes suspended, lose 2 memory.\" until the end of their turn."; } bool CanSelectPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card); } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { return true; } } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1) { int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { Permanent selectedPermanent = permanent; if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent().CreateDebuffEffect(selectedPermanent)); } if (selectedPermanent != null) { ActivateClass activateClass1 = new ActivateClass(); activateClass1.SetUpICardEffect("Memory -2", CanUseCondition2, selectedPermanent.TopCard); activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1()); activateClass1.SetEffectSourcePermanent(selectedPermanent); CardEffectCommons.AddEffectToPermanent( targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnTappedAnyone); CardEffectCommons.AddEffectToPermanent( targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: PermanentEffectFactory.AddDetailClass(selectedPermanent, "[All Turns] When this Digimon becomes suspended, lose 2 memory.", true, activateClass), timing: EffectTiming.None); string EffectDiscription1() { return "[All Turns] When this Digimon becomes suspended, lose 2 memory."; } bool CanUseCondition2(Hashtable hashtable1) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)) { if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable1, (permanent) => permanent == selectedPermanent)) { if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass)) { return true; } } } return false; } bool CanActivateCondition1(Hashtable hashtable1) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)) { return true; } return false; } IEnumerator ActivateCoroutine1(Hashtable _hashtable1) { yield return ContinuousController.instance.StartCoroutine(selectedPermanent.TopCard.Owner.AddMemory(-2, activateClass)); } } } } } } ActivateClass activateClass2 = new ActivateClass(); activateClass2.SetUpICardEffect("Digivolution Cost -1", CanUseCondition2, card); activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, false, EffectDiscription2()); activateClass2.SetIsInheritedEffect(true); activateClass2.SetNotShowUI(true); activateClass2.SetIsBackgroundProcess(true); activateClass2.SetHashString("DigivolutionCost-1_BT14_044"); string EffectDiscription2() { return ""; } bool CanUseCondition2(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)) { List evoRootTops = CardEffectCommons.GetEvoRootTopsFromEnterFieldHashtable( hashtable, permanent => permanent.cardSources.Contains(card)); if (evoRootTops != null) { if (!evoRootTops.Contains(card)) { if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer)) { return true; } } } } } } return false; } bool CanActivateCondition2(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card); } IEnumerator ActivateCoroutine2(Hashtable _hashtable) { yield return null; } if (timing == EffectTiming.OnEnterFieldAnyone) { cardEffects.Add(activateClass2); } if (timing == EffectTiming.None) { ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect($"Digivolution Cost -1", CanUseCondition, card); changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); changeCostClass.SetIsInheritedEffect(true); cardEffects.Add(changeCostClass); bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn)) { if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer)) { return true; } } } } return false; } int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List targetPermanents) { if (CardSourceCondition(cardSource)) { if (RootCondition(root)) { if (PermanentsCondition(targetPermanents)) { Cost -= 1; } } } return Cost; } bool PermanentsCondition(List targetPermanents) { if (targetPermanents != null) { if (targetPermanents.Count(PermanentCondition) >= 1) { return true; } } return false; } bool PermanentCondition(Permanent targetPermanent) { return targetPermanent == card.PermanentOfThisCard(); } bool CardSourceCondition(CardSource cardSource) { return cardSource.Owner == card.Owner; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } } return cardEffects; } } }