using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.EX4 { public class EX4_008 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.ContainsCardName("Guilmon") && targetPermanent.TopCard.HasLevel && targetPermanent.Level == 3; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null)); } if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Both players trash the top 2 cards of their decks and return 1 card from trash to hand", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] Trash the top 2 cards of both players' decks. Then, you may return 1 [Guilmon] or 1 card with [Growlmon] or [Gallantmon] in its name from your trash to your hand."; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource.CardNames.Contains("Guilmon")) { return true; } if (cardSource.ContainsCardName("Growlmon")) { return true; } if (cardSource.ContainsCardName("Gallantmon")) { return true; } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.LibraryCards.Count >= 1) >= 1) { return true; } if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer) { if (player.LibraryCards.Count >= 1) { IAddTrashCardsFromLibraryTop addTrashCard = new IAddTrashCardsFromLibraryTop(2, player, activateClass); addTrashCard.SetNotShowCards(); yield return ContinuousController.instance.StartCoroutine(addTrashCard.AddTrashCardsFromLibraryTop()); if (player.isYou) { ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent().ShowCardEffect2(addTrashCard.discardedCards, "Your Discarded Cards", true, true)); } else { ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent().ShowCardEffect(addTrashCard.discardedCards, "Opponent's Discarded Cards", true, true)); } } } if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)) { int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition)); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: null, afterSelectCardCoroutine: null, message: "Select 1 card to add to your hand.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.AddHand, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); } } } if (timing == EffectTiming.OnDestroyedAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Return 1 card from trash to hand", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); activateClass.SetIsInheritedEffect(true); cardEffects.Add(activateClass); string EffectDiscription() { return "[On Deletion] You may return 1 [Guilmon] or 1 card with [Growlmon] or [Gallantmon] in its name from your trash to your hand."; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource.CardNames.Contains("Guilmon")) { return true; } if (cardSource.ContainsCardName("Growlmon")) { return true; } if (cardSource.ContainsCardName("Gallantmon")) { return true; } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.CanActivateOnDeletion(card, activateClass)) { if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)) { int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition)); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: null, afterSelectCardCoroutine: null, message: "Select 1 card to add to your hand.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.AddHand, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); } } } return cardEffects; } } }