using System; using System.Collections; using System.Collections.Generic; using System.Linq; // Medusamon namespace DCGO.CardEffects.EX11 { public class EX11_012 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Rush if (timing == EffectTiming.None) { cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #region Progress if (timing == EffectTiming.None) { cardEffects.Add(CardEffectFactory.ProgressSelfStaticEffect(false, card, null)); } #endregion #region Shared WD / EOA string SharedEffectName = "Delete 1 digimon with equal or less DP. Bot deck 1 card from their trash to make Token"; string SharedEffectDescription(string tag) => $"[{tag}] You may delete 1 of your opponent's Digimon with as much or less DP as this Digimon. Then, by returning 1 card from your opponent's trash to the bottom of the deck, they play 1 [Petrification] Token. (Digimon/White/3000 DP/[Your Turn] This Digimon can't suspend. [On Deletion] Trash your top security card.)"; bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card); bool ValidOpponentDigimon(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.HasDP && permanent.DP <= card.PermanentOfThisCard().DP; } IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, ValidOpponentDigimon)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: ValidOpponentDigimon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } if (card.Owner.Enemy.TrashCards.Count > 0) { SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: _ => true, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select card to return to bottom of deck", maxCount: 1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: card.Owner.Enemy.TrashCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select a card to return to bottom of deck.", "The opponent is selecting a card to return to bottom of deck."); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(new List() { cardSource })); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPetrificationToken(activateClass)); } } } #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 End of Attack if (timing == EffectTiming.OnEndAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card); activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("End of Attack")); cardEffects.Add(activateClass); bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerOnAttack(hashtable, card); } } #endregion #region All Turns if (timing == EffectTiming.WhenRemoveField) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("By deleting a token, this does not leave", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription()); activateClass.SetHashString("EX11_012_WHEN_REMOVED"); cardEffects.Add(activateClass); string EffectDescription() => "[All Turns] When this Digimon would leave the battle area, by deleting 1 Token, it doesn't leave."; bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition); } bool CanSelectPermanentCondition(Permanent permanent) => permanent.IsToken; IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, 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 permanent) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null)); IEnumerator SuccessProcess() { Permanent thisPermanent = card.PermanentOfThisCard(); thisPermanent.willBeRemoveField = false; thisPermanent.HideDeleteEffect(); thisPermanent.HideHandBounceEffect(); thisPermanent.HideDeckBounceEffect(); thisPermanent.HideWillRemoveFieldEffect(); yield return null; } } } } } #endregion return cardEffects; } } }