using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.EX5 { public class EX5_018 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.CardNames.Contains("Garurumon"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null)); } if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Draw 2, trash 2 cards from hand and gain Memory +1", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] (Draw 2 cards from your deck). Then, trash 2 cards in your hand. If [Garurumon] or [X Antibody] is in this Digimon's digivolution cards, gain 1 memory."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.LibraryCards.Count >= 1) { return true; } if (card.Owner.HandCards.Count >= 1) { return true; } if (card.Owner.CanAddMemory(activateClass)) { if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Garurumon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1) { return true; } } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw()); if (card.Owner.HandCards.Count >= 1) { int discardCount = Math.Min(2, card.Owner.HandCards.Count); SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: (cardSource) => true, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: discardCount, canNoSelect: false, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); yield return StartCoroutine(selectHandEffect.Activate()); } if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Garurumon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1) { yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass)); } } } } if (timing == EffectTiming.WhenPermanentWouldBeDeleted) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Prevent this Digimon from being deleted", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("Substitute_EX5_018"); activateClass.SetIsInheritedEffect(true); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] [Once Per Turn] When this Digimon with [Garurumon]/[Omnimon] in its name would be deleted in battle, by returning 2 non-Digi-Egg cards from your trash to the bottom of the deck, prevent that deletion."; } bool CanSelectCardCondition(CardSource cardSource) { return !cardSource.IsDigiEgg; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)) { if (CardEffectCommons.IsByBattle(hashtable)) { return true; } } } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2) { if (card.PermanentOfThisCard().TopCard.HasGarurumonName) { return true; } if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon")) { return true; } } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { Permanent thisCardPermanent = card.PermanentOfThisCard(); if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2) { int maxCount = 2; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource), canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: null, afterSelectCardCoroutine: AfterSelectCardCoroutine, message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).", maxCount: maxCount, canEndNotMax: false, isShowOpponent: false, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetNotShowCard(); selectCardEffect.SetNotAddLog(); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator AfterSelectCardCoroutine(List cardSources) { if (cardSources.Count == 2) { yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources)); yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true)); if (thisCardPermanent.TopCard != null) { thisCardPermanent.willBeRemoveField = false; thisCardPermanent.HideDeleteEffect(); } } } } } } return cardEffects; } } }