using System.Collections; using System.Collections.Generic; using System; using System.Linq; using UnityEngine; namespace DCGO.CardEffects.EX6 { public class EX6_061 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region All Turns - When Played - Once per turn if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("By trashing 1 card in hand, return sources, then delete 1 digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("AllTurns_EX6_061"); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] [Once Per Turn] When an opponent's Digimon or one of your Digimon with the [Seven Great Demon Lords] trait is played, by trashing 1 card in your hand, return the bottom 3 digivolution cards of 1 of your opponent's Digimon to the bottom of the deck. Then, if your opponent has as many or less total Digimon and Tamers as you, delete 1 of your opponent's Digimon with no digivolution cards."; } bool PlayedDigimonConditions(Permanent permanent) { if (permanent.IsDigimon) { if (CardEffectCommons.IsOwnerPermanent(permanent, card)) { if (permanent.TopCard.ContainsTraits("Seven Great Demon Lords")) return true; } else { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card); } } return false; } bool SelectOpponentsDigimonCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card); } bool SelectOpponentsDigimonWithoutSourcesCondition(Permanent permanent) { if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && permanent.HasNoDigivolutionCards)) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)) { return true; } } return false; } bool PermanentCondition(Permanent permanent) { return (permanent.IsDigimon || permanent.IsTamer); } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.CanTriggerOnPlay(hashtable, card)) return true; if(CardEffectCommons.CanTriggerOnPermanentPlay(hashtable,PlayedDigimonConditions)) return true; return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if(card.Owner.HandCards.Count > 0) return true; } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { List discarded = new List(); SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: (cardSource) => true, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: AfterSelectionCoroutine, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator AfterSelectionCoroutine(List cardSources) { discarded = cardSources.Clone(); yield return null; } if (discarded.Count >=1) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); int suspendCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectOpponentsDigimonCondition)); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SelectOpponentsDigimonCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: suspendCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } IEnumerator SelectPermanentCoroutine(Permanent permanent) { List targetCards = new List(); for (int i = 0; i < 3; i++) { if (permanent.DigivolutionCards.Count >= i + 1) { int index = false ? i : permanent.DigivolutionCards.Count - 1 - i; CardSource trashTargetCard = permanent.DigivolutionCards[index]; targetCards.Add(trashTargetCard); } } yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass( permanent, targetCards, CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards()); } if (card.Owner.GetBattleAreaPermanents().Count(PermanentCondition) >= card.Owner.Enemy.GetBattleAreaPermanents().Count(PermanentCondition)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); int suspendCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectOpponentsDigimonWithoutSourcesCondition)); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SelectOpponentsDigimonWithoutSourcesCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: suspendCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } } } #endregion #region All Turns if (timing == EffectTiming.WhenRemoveField) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Place 1 7GDL from trash to bottom of [Gate of Deadly Sins]", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] When this Digimon would leave the battle area other than in battle, place 1 card with the [Seven Great Demon Lord] trait from your trash as the bottom digivolution cards of one of your [Gate of Deadly Sins] in your breeding area."; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)) { if (!CardEffectCommons.IsByBattle(hashtable)) { return true; } } } return false; } bool CanSelect7GDLinTrash(CardSource cardSource) { if (cardSource.CardTraits.Contains("SevenGreatDemonLords") || cardSource.CardTraits.Contains("Seven Great Demon Lords")) { return true; } return false; } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card)) { if (permanent.TopCard.CardNames.Contains("Gate of Deadly Sins")) { return true; } } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect7GDLinTrash)) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect7GDLinTrash)) { List selectedCards = new List(); int maxCount = 1; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelect7GDLinTrash, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => false, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to place at the bottom of digivolution cards.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards."); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (selectedCards.Count >= 1) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition, true)) { Permanent selectedPermanent = card.Owner.GetBreedingAreaPermanents()[0]; if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass)); } } } } } } #endregion return cardEffects; } } }