using System; using System.Collections; using System.Collections.Generic; using System.Linq; // Entermon namespace DCGO.CardEffects.BT22 { public class BT22_035 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Static Effects #region Sup. Appmon Alternative Digivolution Requirement if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.HasSuperAppTraits; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region App Fusion (Mediamon & Dreammon) if (timing == EffectTiming.None) { cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List() { "Mediamon", "Dreammon" }, card)); } #endregion #region Link Condition if (timing == EffectTiming.None) { static bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.HasAppmonTraits; } cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card)); } #endregion #region Link if (timing == EffectTiming.OnDeclaration) { cardEffects.Add(CardEffectFactory.LinkEffect(card)); } #endregion #region Alliance if (timing == EffectTiming.OnAllyAttack) { cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #endregion #region OP/WD Shared Effects bool SharedIsAppMon(CardSource cardSource) { return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 4 && cardSource.HasAppmonTraits && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false); } IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { bool canUseHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SharedIsAppMon); bool canUseSources = card.PermanentOfThisCard().DigivolutionCards.Filter(SharedIsAppMon).Count > 0; if (canUseHand || canUseSources) { #region Select Card Location if (canUseHand && canUseSources) { List> selectionElements = new List>() { new SelectionElement(message: $"From hand", value : true, spriteIndex: 0), new SelectionElement(message: $"From digivolution sources", value : false, spriteIndex: 1), }; string selectPlayerMessage = "From which area do you select a card?"; string notSelectPlayerMessage = "The opponent is choosing from which area to select a card."; GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage); } else { GManager.instance.userSelectionManager.SetBool(canUseHand); } yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect()); #endregion bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue; CardSource cardForLinking = null; IEnumerator SelectCardCoroutine(CardSource cardSource) { cardForLinking = cardSource; yield return null; } #region Select Card from Hand or Sources if (fromHand) { SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SharedIsAppMon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link."); yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate()); } else { SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: SharedIsAppMon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to link.", maxCount: 1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.DigivolutionCards, customRootCardList: card.PermanentOfThisCard().DigivolutionCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link."); selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card"); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); } #endregion if (cardForLinking != null) yield return ContinuousController.instance.StartCoroutine( card.PermanentOfThisCard().AddLinkCard(cardForLinking, activateClass)); } } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Link a level 4 or lower digimon from hand or sources", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[On Play] You may link 1 level 4 or lower Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && (CardEffectCommons.HasMatchConditionOwnersHand(card, SharedIsAppMon) || card.PermanentOfThisCard().DigivolutionCards.Filter(SharedIsAppMon).Count > 0); } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass)); } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Link a level 4 or lower digimon from hand or sources", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && (CardEffectCommons.HasMatchConditionOwnersHand(card, SharedIsAppMon) || card.PermanentOfThisCard().DigivolutionCards.Filter(SharedIsAppMon).Count > 0); } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass)); } } #endregion #region Your Turn if (timing == EffectTiming.WhenLinked) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 4 cost or lower [Appmon] card", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("BT22_035_WL"); cardEffects.Add(activateClass); string EffectDiscription() { return "[Your Turn] [Once Per Turn] When this Digimon gets linked, you may play 1 play cost 4 or lower card with the [Appmon] trait from your hand without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenLinked(hashtable, IsEntermon, null); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsAppMonCard); } bool IsEntermon(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent == card.PermanentOfThisCard(); } bool IsAppMonCard(CardSource cardSource) { return CardEffectCommons.IsExistOnHand(cardSource) && cardSource.HasPlayCost && cardSource.BasePlayCostFromEntity <= 4 && cardSource.HasAppmonTraits; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsAppMonCard)) { CardSource selectedCard = null; #region Select Appmon in Hand int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsAppMonCard)); SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsAppMonCard, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play."); selectHandEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCard = cardSource; yield return null; } #endregion if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true)); } } } #endregion #region Link Effect if (timing == EffectTiming.WhenLinked) { int dpMinus = card.Owner.GetBattleAreaDigimons().Count(x => x.TopCard.HasAppmonTraits) * 4000; ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect($"-4000 DP for each Digimon with [Appmon] trait", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); activateClass.SetIsLinkedEffect(true); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Linking] To 1 of your opponent's Digimon, give -4000 DP for the turn for each of your Digimon with the [Appmon] trait."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card); } bool CanActivateCondition(Hashtable hashtable) { dpMinus = card.Owner.GetBattleAreaDigimons().Count(x => x.TopCard.HasAppmonTraits) * 4000; return CardEffectCommons.IsExistOnField(card) && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon) && dpMinus != 0; } bool IsOpponentDigimon(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon)) { Permanent selectedPermament = null; #region Select Permanent int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsOpponentDigimon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermament = permanent; yield return null; } selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to {dpMinus}K DP", $"The opponent is selecting 1 Digimon to {dpMinus}K DP"); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); #endregion if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine( CardEffectCommons.ChangeDigimonDP(selectedPermament, -dpMinus, EffectDuration.UntilEachTurnEnd, activateClass)); } } } #endregion return cardEffects; } } }