using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; namespace DCGO.CardEffects.LM { public class LM_017 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); //Alternate Digivolution Requirement if (timing == EffectTiming.None) { static bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.HasText("Gammamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null)); } //Blast Digivolve if (timing == EffectTiming.OnCounterTiming) { cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null)); } #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Trash 1 card from your hand", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); bool CanSelectSharedCardCondition(CardSource cardSource) { if (CardEffectCommons.IsExistOnTrash(cardSource)) { return cardSource.HasText("Gammamon"); } return false; } string EffectDiscription() { return "[On Play] Trash 1 card in your hand. Then, you may place 1 card with [Gammamon] in its text from your trash as this Digimon's bottom digivolution card."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.HandCards.Count >= 1) { return true; } } return false; } bool CanActivateThenCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.TrashCards.Count >= 1) { if (card.Owner.TrashCards.Any(cardSource => cardSource.HasText("Gammamon"))) { return true; } } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { List selectedCards = 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: null, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to trash.", "The opponent is selecting 1 card to trash."); yield return StartCoroutine(selectHandEffect.Activate()); yield return StartCoroutine(ActivatePlacingSource()); } IEnumerator ActivatePlacingSource() { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Place a Card from hand to digivolution cards to get effects", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateThenCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); List selectedCards = new List(); selectCardEffect.SetUp( canTargetCondition: CanSelectSharedCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to place at the bottom of digivolution cards.", maxCount: 1, 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 StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (selectedCards.Count >= 1) { Permanent selectedPermanent = card.PermanentOfThisCard(); if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass)); } } } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Trash 1 card from your hand", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); bool CanSelectSharedCardCondition(CardSource cardSource) { if (CardEffectCommons.IsExistOnTrash(cardSource)) { return cardSource.HasText("Gammamon"); } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } string EffectDiscription() { return "[When Digivolving] Trash 1 card in your hand. Then, you may place 1 card with [Gammamon] in its text from your trash as this Digimon's bottom digivolution card."; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.HandCards.Count >= 1) { return true; } } return false; } bool CanActivateThenCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.TrashCards.Count >= 1) { if (card.Owner.TrashCards.Any(cardSource => cardSource.HasText("Gammamon"))) { return true; } } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { List selectedCards = 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: null, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to trash.", "The opponent is selecting 1 card to trash."); yield return StartCoroutine(selectHandEffect.Activate()); yield return StartCoroutine(ActivatePlacingSource()); } IEnumerator ActivatePlacingSource() { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Place a Card from hand to digivolution cards to get effects", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateThenCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); List selectedCards = new List(); selectCardEffect.SetUp( canTargetCondition: CanSelectSharedCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to place at the bottom of digivolution cards.", maxCount: 1, 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 StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (selectedCards.Count >= 1) { Permanent selectedPermanent = card.PermanentOfThisCard(); if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass)); } } } } #endregion #region All Turns if (timing == EffectTiming.OnAddDigivolutionCards) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Delete 1 Digimon, Play 1 Digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription()); activateClass.SetHashString("Delete_Play_LM_017"); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] [Once Per Turn] When an effect adds digivolution card to this Digimon, by deleting 1 level 4 or lower Digimon, you may play 1 level 4 or lower Digimon card from your trash without paying the cost."; } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)) { return permanent.IsDigimon && permanent.Level <= 4; } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.CanTriggerOnAddDigivolutionCard( hashtable: hashtable, permanentCondition: permanent => permanent == card.PermanentOfThisCard(), cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null, cardCondition: null)) { return true; } } return false; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card); } IEnumerator ActivateCoroutine(Hashtable _hashtable) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); List selectedCards = new List(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: true, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, maxCount: 1, canEndNotMax: false, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete.", "The opponent is selecting 1 digimon to delete."); yield return StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedCards.Add(permanent); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: selectedCards, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null)); yield return null; } IEnumerator SuccessProcess() { SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); List selectedCards = new List(); bool CanSelectCardCondition(CardSource cardSource) { if (CardEffectCommons.IsExistOnTrash(cardSource)) { if (cardSource.Owner == card.Owner) { return cardSource.IsDigimon && cardSource.Level <= 4; } } return false; } selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 Digimon card to play.", maxCount: 1, 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 Digimon to play.", "The opponent is selecting 1 Digimon card to play."); 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.Trash, activateETB: true)); } } } #endregion return cardEffects; } } }