using System.Collections; using System.Collections.Generic; using System; namespace DCGO.CardEffects.BT17 { public class BT17_067 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Alternate Digivolution if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.EqualsCardName("DoruGreymon"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region Trash - All Turns if (timing == EffectTiming.WhenPermanentWouldBeDeleted) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect( "Digivolve into [DoruGreymon] into [DexDoruGreymon] from your trash to prevent deletion", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription()); activateClass.SetHashString("DigivolveIntoDex_BT17_067"); cardEffects.Add(activateClass); string EffectDescription() { return "[All Turns] When one of your [DoruGreymon] would be deleted, by digivolving it into this card without paying the cost, prevent that deletion."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnTrash(card) && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition); } bool IsOwnerPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent.TopCard.EqualsCardName("DoruGreymon") && card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash); } bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent) { return IsOwnerPermanentCondition(permanent) && permanent.willBeRemoveField; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnTrash(card) && CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentCondition); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition)) { Permanent selectedPermanent = null; int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsOwnerPermanentToBeDeletedCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage( "Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard( targetPermanent: selectedPermanent, cardCondition: null, payCost: false, reduceCostTuple: null, fixedCostTuple: null, ignoreDigivolutionRequirementFixedCost: -1, isHand: false, activateClass: activateClass, successProcess: null, ignoreSelection: true)); selectedPermanent.willBeRemoveField = false; selectedPermanent.HideDeleteEffect(); } } } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Trash 1, Draw 1 and delete opponent's Digimon with play cost of 6 or less", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[When Digivolving] Trash 1 card in your hand. Then, . If [DoruGreymon] is in this Digimon's digivolution cards or this digivolved from the trash, delete 1 of your opponent's Digimon with a play cost of 6 or less instead."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool IsDoruCardCondition(CardSource cardSource) { return cardSource.IsDigimon && cardSource.EqualsCardName("DoruGreymon"); } bool TrashRootCondition(SelectCardEffect.Root root) { return root == SelectCardEffect.Root.Trash; } bool CanSelectOpponentPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 6; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && (card.Owner.HandCards.Count >= 1 || card.Owner.LibraryCards.Count >= 1 || CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition)); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (card.Owner.HandCards.Count >= 1) { SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: _ => true, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); yield return StartCoroutine(selectHandEffect.Activate()); } if (card.PermanentOfThisCard().DigivolutionCards.Some(IsDoruCardCondition) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, TrashRootCondition)) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition)) { int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectOpponentPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } } else { if (card.Owner.LibraryCards.Count >= 1) { yield return ContinuousController.instance.StartCoroutine( new DrawClass(card.Owner, 1, activateClass).Draw()); } } } } #endregion #region End of Attack - ESS if (timing == EffectTiming.OnEndAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Delete own Digimon to delete opponent's Digimon with as high or lower a level", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription()); activateClass.SetIsInheritedEffect(true); activateClass.SetHashString("DeleteDigimon_BT17_067"); cardEffects.Add(activateClass); string EffectDescription() { return "[End of Attack][Once per turn] You may choose 1 of your Digimon. Delete 1 of your chosen Digimon and 1 of your opponent's Digimon with as high or lower a level as that Digimon."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card); } bool CanSelectOwnPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectOwnPermanentCondition); } IEnumerator ActivateCoroutine(Hashtable hashtable) { List chosenPermanents = new List(); if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectOwnPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: AfterSelectPermanent, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent chosenPermanent) { chosenPermanents.Add(chosenPermanent); yield return null; } IEnumerator AfterSelectPermanent(List chosenPermanent) { bool CanSelectOpponentPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.TopCard.HasLevel && permanent.Level <= chosenPermanents[0].Level; } if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition)) { selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectOpponentPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } yield return ContinuousController.instance.StartCoroutine( CardEffectCommons.DeletePeremanentAndProcessAccordingToResult( targetPermanents: chosenPermanents, activateClass: activateClass, successProcess: null, failureProcess: null)); } } } } #endregion return cardEffects; } } }