using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.BT11 { public class BT11_064 : 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("Greymon"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null)); } if (timing == EffectTiming.None) { ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect($"Reduce Digivolution Cost", CanUseCondition, card); changeCostClass.SetUpChangeCostClass( changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); cardEffects.Add(changeCostClass); bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { 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 -= cardSource.CardColors.Count; } } } 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.HasGreymonName; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } } if (timing == EffectTiming.WhenPermanentWouldBeDeleted || timing == EffectTiming.WhenReturntoHandAnyone || timing == EffectTiming.WhenReturntoLibraryAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Prevent this Digimon from being deleted or returned to hand or deck by effects", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); activateClass.SetIsInheritedEffect(true); activateClass.SetHashString("Substitute_BT11_064"); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] When this Digimon with [Greymon] or [Omnimon] in its name would be deleted or returned to your hand or deck by an effect, by placing 1 [X Antibody] from this Digimon's digivolution cards at the bottom of its owner's deck, prevent this Digimon from leaving play."; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource.CardNames.Contains("X Antibody")) { return true; } if (cardSource.CardNames.Contains("XAntibody")) { return true; } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)) { if (CardEffectCommons.IsByEffect(hashtable, null)) { if (card.PermanentOfThisCard().TopCard.HasGreymonName) { return true; } if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon")) { return true; } } } } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1) { bool returnedToLibrary = false; List selectedCards = new List(); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 digivolution card to return to the bottom of deck.", maxCount: 1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: card.PermanentOfThisCard().DigivolutionCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: null); selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to return to the bottom of deck.", "The opponent is selecting 1 digivolution card to return to the bottom of deck."); selectCardEffect.SetNotShowCard(); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (selectedCards.Count >= 1) { yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass( card.PermanentOfThisCard(), selectedCards, CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards()); returnedToLibrary = true; } if (returnedToLibrary) { if (CardEffectCommons.IsExistOnBattleArea(card)) { Permanent selectedPermanent = card.PermanentOfThisCard(); selectedPermanent.willBeRemoveField = false; selectedPermanent.HideDeleteEffect(); selectedPermanent.HideHandBounceEffect(); selectedPermanent.HideDeckBounceEffect(); } } } } } } return cardEffects; } } }