using System.Collections; using System.Collections.Generic; using System.Linq; using System; //DarkKnightmon namespace DCGO.CardEffects.EX10 { public class EX10_031 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Alternate Digivolution Requirement if (timing == EffectTiming.None) { static bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.HasText("Knightmon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #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) { DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "SkullKnightmon"); bool CanSelectCardCondition(CardSource cardSource) { if (cardSource != null) { if (cardSource.Owner == card.Owner) { if (cardSource.IsDigimon) { if (cardSource.CardNames_DigiXros.Contains("SkullKnightmon")) { return true; } } } } return false; } DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "DeadlyAxemon"); bool CanSelectCardCondition1(CardSource cardSource) { if (cardSource != null) { if (cardSource.Owner == card.Owner) { if (cardSource.IsDigimon) { if (cardSource.CardNames_DigiXros.Contains("DeadlyAxemon")) { return true; } } } } return false; } List elements = new List() { element, element1 }; DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 1); return digiXrosCondition; } return null; } } #endregion #region Shared OP/WD bool SharedPermamentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card); } IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { if (CardEffectCommons.HasMatchConditionPermanent(SharedPermamentCondition)) { Permanent selectedPermament = null; SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SharedPermamentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, 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 gain De-Digivolve immunity & 3K DP", "The opponent is selecting 1 Digimon to gain De-Digivolve immunity & 3K DP"); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); if (selectedPermament != null) { bool CanUseImmunityCondition(Hashtable hashtable1) { return selectedPermament.TopCard != null; } bool PermanentImmunityCondition(Permanent permanent) { return permanent == selectedPermament; } ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass(); immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by ", CanUseImmunityCondition, selectedPermament.TopCard); immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition); selectedPermament.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP( targetPermanent: selectedPermament, changeValue: 3000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass )); } } } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Gain immunity to De-Digivolve & gain 3k DP", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[On Play] Until your opponent's turn ends, their effects don't affect 1 of your Digimon, and it gets +3000 DP."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerOnPlay(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionPermanent(SharedPermamentCondition); } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Gain immunity to De-Digivolve & gain 3k DP", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] Until your opponent's turn ends, their effects don't affect 1 of your Digimon, and it gets +3000 DP."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionPermanent(SharedPermamentCondition); } } #endregion #region All Turns - OPT if (timing == EffectTiming.WhenPermanentWouldBeDeleted) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play a Digimon from digivolution cards", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); activateClass.SetHashString("PlayDigimon_EX10_031"); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, you may play 1 play cost 4 or lower card from its digivolution cards without paying the cost."; } bool CanSelectCardCondition(CardSource cardSource) { return cardSource.IsDigimon && cardSource.HasPlayCost && cardSource.GetCostItself <= 4 && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.DigivolutionCards); } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)) { 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) { Permanent selectedPermanent = card.PermanentOfThisCard(); 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 card to play.", maxCount: 1, 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 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play."); selectCardEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true)); } } #endregion #region ESS if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Change attack target to this card", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("BT22_061_ChangeAttackTarget"); activateClass.SetIsInheritedEffect(true); cardEffects.Add(activateClass); string EffectDiscription() { return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOpponentTurn(card) && CanBeSwitched(); } bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card); bool CanBeSwitched() { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(GManager.instance.attackProcess.AttackingPermanent, card) && GManager.instance.attackProcess.IsAttacking && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CanBeSwitched()) yield return ContinuousController.instance.StartCoroutine( GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard())); } } #endregion return cardEffects; } } }