using System; using System.Collections; using System.Collections.Generic; // Release of the Sealed Knight! namespace DCGO.CardEffects.P { public class P_204 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Main if (timing == EffectTiming.OptionSkill) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Trash 1 [X Antibody]/[Chronicle] from hand, draw 2", CanUseCondition, card); activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[Main] By trashing 1 card with the [X Antibody] or [Chronicle] trait from your hand, (Draw 2 cards from your deck). Then, place this card in the battle area."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card); } bool CanSelectHandCondition(CardSource cardSource) { return cardSource.HasXAntibodyTraits || cardSource.HasChronicleTraits; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCondition)) { bool discarded = false; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); int discardCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectHandCondition)); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectHandCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: discardCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: afterSelectCardCoroutine, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); IEnumerator afterSelectCardCoroutine(List selectedCards) { if (selectedCards.Count > 0) discarded = true; yield return null; } yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate()); if (discarded) { yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw()); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass)); } } } } #endregion #region All Turns - Delay if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("1 [Grademon]/[Chronicle] digimon digivoles into [Alphamon]/ level 6 or lower [Chronicle] digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[All Turns] When Digimon attack players, . 1 of your [Grademon] or Digimon with the [Chronicle] trait may digivolve into [Alphamon] or a level 6 or lower Digimon card with the [Chronicle] trait in the hand without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanDeclareOptionDelayEffect(card) && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanentCondition); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnField(card); } bool AttackingPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) && GManager.instance.attackProcess.AttackingPermanent == permanent // if DefendingPermanent is null, it means the attack is a player attack && GManager.instance.attackProcess.DefendingPermanent == null; } bool CanSelectPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && (permanent.TopCard.EqualsCardName("Grademon") || permanent.TopCard.HasChronicleTraits); } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null)); IEnumerator SuccessProcess() { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { Permanent selectedPermanent = null; SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition)); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve", "The opponent is selecting 1 Digimon to digivolve"); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); if (selectedPermanent != null) { bool CanSelectCardCondition(CardSource cardSource) { return cardSource.IsDigimon && (cardSource.EqualsCardName("Alphamon") || (cardSource.Level <= 6 && cardSource.HasChronicleTraits)) && cardSource.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass); } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard( targetPermanent: selectedPermanent, cardCondition: CanSelectCardCondition, payCost: false, reduceCostTuple: null, fixedCostTuple: null, ignoreDigivolutionRequirementFixedCost: -1, isHand: true, activateClass: activateClass, successProcess: null)); } } } } } #endregion #region Security Effect if (timing == EffectTiming.SecuritySkill) { CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: "Trash 1 [X Antibody]/[Chronicle] from hand, draw 2"); } #endregion return cardEffects; } } }