using System; using System.Collections; using System.Collections.Generic; using System.Linq; // Destromon public class P_094 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region DigiXros if (timing == EffectTiming.None) { AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass(); addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card); addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros); addDigiXrosConditionClass.SetNotShowUI(true); cardEffects.Add(addDigiXrosConditionClass); bool CanUseCondition(Hashtable hashtable) { return true; } DigiXrosCondition GetDigiXros(CardSource cardSource) { if (cardSource == card) { List elements = new List(); DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Snatchmon"); bool CanSelectCardCondition(CardSource cardSource) { return cardSource != null && cardSource.Owner == card.Owner && cardSource.IsDigimon && cardSource.CardNames_DigiXros.Contains("Snatchmon"); } elements.Add(element); DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "Vemmon"); bool CanSelectCardCondition1(CardSource cardSource) { return cardSource != null && cardSource.Owner == card.Owner && cardSource.IsDigimon && cardSource.CardNames_DigiXros.Contains("Vemmon"); } for (int i = 0; i < 4; i++) { elements.Add(element1); } DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 1); return digiXrosCondition; } return null; } } #endregion #region Deletion Play Cost Calculation and Update int maxCost() { int maxCost = 3; if (CardEffectCommons.IsExistOnBattleArea(card)) { maxCost += card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("Vemmon")); } return maxCost; } #endregion #region Shared OP/WD string SharedEffectName() => $"Delete Digimon and/or Tamer(s) up to play cost of 3 + 1 per [Vemmon] in digivolution sources."; // for when we get it to update when we add sources to stack - $"Delete Digimon and/or Tamer(s) up to play cost of {maxCost()}." string SharedEffectDescription(string tag) => $"[{tag}] Delete your opponent's Digimon and Tamers with a total play cost of 3. For every [Vemmon] in this Digimon's digivolution cards, increase the maximum play cost you can choose by this effect by 1."; bool SharedCanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && card.Owner.Enemy.GetBattleAreaPermanents().Count(SharedCanSelectPermanentCondition) >= 1; } bool SharedCanSelectPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) && (permanent.IsDigimon || permanent.IsTamer) && permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= maxCost(); } IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { if (card.Owner.Enemy.GetBattleAreaPermanents().Count(SharedCanSelectPermanentCondition) == 1) { List targetPermanent = card.Owner.Enemy.GetBattleAreaPermanents().Filter(SharedCanSelectPermanentCondition); yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(targetPermanent, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy()); } else if (card.Owner.Enemy.GetBattleAreaPermanents().Count(SharedCanSelectPermanentCondition) >= 1) { List selectedPermanents = new List(); int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(SharedCanSelectPermanentCondition); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SharedCanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList, canEndSelectCondition: CanEndSelectCondition, maxCount: maxCount, canNoSelect: false, canEndNotMax: true, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); bool CanEndSelectCondition(List permanents) { if (permanents.Count <= 0) { return false; } int sumCost = 0; foreach (Permanent permanent1 in permanents) { sumCost += permanent1.TopCard.GetCostItself; } if (sumCost > maxCost()) { return false; } return true; } bool CanTargetCondition_ByPreSelecetedList(List permanents, Permanent permanent) { int sumCost = 0; foreach (Permanent permanent1 in permanents) { sumCost += permanent1.TopCard.GetCostItself; } sumCost += permanent.TopCard.GetCostItself; if (sumCost > maxCost()) { return false; } return true; } } } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card); activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play")); cardEffects.Add(activateClass); bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerOnPlay(hashtable, card); } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card); activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving")); cardEffects.Add(activateClass); bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } } #endregion #region Inherited Effect: Switch Attack Target if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Return 2 [Vemmon] from [Galacticmon]'s digivolution cards to the deck bottom to switch attack target to this Digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetIsInheritedEffect(true); activateClass.SetHashString("SwitchAttackTarget_P_094"); cardEffects.Add(activateClass); string EffectDiscription() { return "[Opponent's Turn] [Once Per Turn] When an opponent's Digimon attacks, by placing 2 [Vemmon] from 1 of your [Galacticmon]'s digivolution cards at the bottom of their owners' decks, switch the target of attack to this Digimon."; } bool CanSelectCardCondition(CardSource cardSource) { return cardSource.CardNames.Contains("Vemmon"); } bool CanSelectPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && permanent.TopCard.CardNames.Contains("Galacticmon") && permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 2; } bool PermanentCondition(Permanent permanent) { return CardEffectCommons.IsOpponentPermanent(permanent, card); } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.IsOpponentTurn(card) && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { Permanent selectedPermanent = null; if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { 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 [Galacticmon].", "The opponent is selecting 1 [Galacticmon]."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } } if (selectedPermanent != null) { List selectedCards = new List(); if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 2) { int maxCount = 2; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => false, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 2 [Vemmon] that will return to the bottom of 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: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: selectedPermanent.DigivolutionCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select digivolution cards to return to the bottom of deck.", "The opponent is selecting digivolution cards to return to the bottom of deck."); selectCardEffect.SetNotShowCard(); yield return StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (selectedCards.Count >= 1) { yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass(selectedPermanent, selectedCards, CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards()); if (selectedCards.Count == 2 && CardEffectCommons.IsExistOnBattleArea(card)) { yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard())); } } } } } } #endregion return cardEffects; } }