Procházet zdrojové kódy

Create EX12_003.cs

x89rt2 před 2 měsíci
rodič
revize
3eff35a503
1 změnil soubory, kde provedl 232 přidání a 0 odebrání
  1. 232 0
      Assets/Scripts/CardEffect/EX12/Black/EX12_003.cs

+ 232 - 0
Assets/Scripts/CardEffect/EX12/Black/EX12_003.cs

@@ -0,0 +1,232 @@
+using System.Collections;
+using System.Collections.Generic;
+
+// Kapurimon
+namespace DCGO.CardEffects.EX12
+{
+    public class EX12_003 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Inherit
+            if (timing == EffectTiming.WhenRemoveField)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("May DNA 1 of the leaving Digimon and another Digimon into an [ME] in hand", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
+                activateClass.SetIsSkippable(true);
+                cardEffects.Add(activateClass);
+
+                string EffectDescription()
+                {
+                    return "[All Turns] When any of your [ME] trait Digimon would leave the battle area other than by your effects, 1 of them and any of your other Digimon may DNA digivolve into an [ME] trait Digimon card in the hand.";
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
+                        && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
+                        && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass)
+                        && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDNACondition)
+                        && CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard());
+                }
+
+                bool PermanentCondition(Permanent permanent)
+                {
+                    return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                        && permanent.TopCard.EqualsTraits("ME");
+                }
+
+                bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
+                {
+                    return PermanentCondition(permanent)
+                        && permanent.willBeRemoveField;
+                }
+
+                bool CanSelectDNACondition(CardSource cardSource)
+                {
+                    return cardSource.EqualsTraits("ME")
+                        && cardSource.jogressCondition.Count > 0;
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    CardSource selectedMEDNA = null;
+                    List<Permanent> allowedPermanents = new List<Permanent>();
+                    Permanent selectedPermanent1 = null;
+                    Permanent selectedPermanent2 = null;
+
+                    SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+
+                    selectHandEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: CanSelectDNACondition,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: 1,
+                        canNoSelect: false,
+                        canEndNotMax: false,
+                        isShowOpponent: true,
+                        selectCardCoroutine: SelectDNACoroutine,
+                        afterSelectCardCoroutine: null,
+                        mode: SelectHandEffect.Mode.Custom,
+                        cardEffect: activateClass);
+
+                    selectHandEffect.SetUpCustomMessage("Select 1 Digimon to DNA digivolve.",
+                        "The opponent is selecting 1 Digimon to DNA digivolve.");
+
+                    yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
+
+                    IEnumerator SelectDNACoroutine(CardSource cardSource)
+                    {
+                        selectedMEDNA = cardSource;
+                        yield return null;
+                    }
+
+                    if (selectedMEDNA != null)
+                    {
+                        JogressCondition dnaCondition = selectedMEDNA.jogressCondition[0];
+
+                        if (selectedMEDNA.jogressCondition.Count > 1)
+                        {
+                            #region select DNA condition
+                            SelectDNACondition selectDNACondition = GManager.instance.GetComponent<SelectDNACondition>();
+                            selectDNACondition.SetUp(selectedMEDNA.Owner, selectedMEDNA, SelectDNA);
+
+                            yield return ContinuousController.instance.StartCoroutine(selectDNACondition.Activate());
+
+                            IEnumerator SelectDNA(int dnaSelection)
+                            {
+                                dnaCondition = selectedMEDNA.jogressCondition[dnaSelection];
+
+                                yield return null;
+                            }
+                            #endregion
+                        }
+
+                        JogressConditionElement[] elements = (JogressConditionElement[])dnaCondition.elements.Clone();
+
+                        for (int i = 0; i < elements.Length; i++)
+                        {
+                            foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
+                            {
+                                if (elements[i].EvoRootCondition(permanent))
+                                {
+                                    allowedPermanents.Add(permanent);
+                                }
+                            }
+                        }
+
+                        #region Selecting First Permanent for DNA
+                        bool PermanentDNASelection1(Permanent permanent)
+                        {
+                            return IsOwnerPermanentToBeDeletedCondition(permanent)
+                                && allowedPermanents.Contains(permanent);
+                        }
+                        
+                        SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                        selectPermanentEffect.SetUp(
+                            selectPlayer: card.Owner,
+                            canTargetCondition: PermanentDNASelection1,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            maxCount: 1,
+                            canNoSelect: true,
+                            canEndNotMax: false,
+                            selectPermanentCoroutine: SelectPermanentCoroutine1,
+                            afterSelectPermanentCoroutine: null,
+                            mode: SelectPermanentEffect.Mode.Custom,
+                            cardEffect: activateClass);
+
+                        selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to DNA digivolve.",
+                            "The opponent is selecting 1 Digimon to DNA digivolve.");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                        #endregion
+
+                        IEnumerator SelectPermanentCoroutine1(Permanent permanent)
+                        {
+                            selectedPermanent1 = permanent;
+
+                            yield return null;
+                        }
+
+                        if (selectedPermanent1 != null)
+                        {
+                            #region Selecting First Permanent for DNA
+                            bool PermanentDNASelection2(Permanent permanent)
+                            {
+                                return allowedPermanents.Contains(permanent)
+                                    && permanent != selectedPermanent1;
+                            }
+
+                            SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                            selectPermanentEffect1.SetUp(
+                                selectPlayer: card.Owner,
+                                canTargetCondition: PermanentDNASelection2,
+                                canTargetCondition_ByPreSelecetedList: null,
+                                canEndSelectCondition: null,
+                                maxCount: 1,
+                                canNoSelect: true,
+                                canEndNotMax: false,
+                                selectPermanentCoroutine: SelectPermanentCoroutine2,
+                                afterSelectPermanentCoroutine: null,
+                                mode: SelectPermanentEffect.Mode.Custom,
+                                cardEffect: activateClass);
+
+                            selectPermanentEffect1.SetUpCustomMessage("Select second Digimon to DNA digivolve.",
+                                "The opponent is selecting second Digimon to DNA digivolve.");
+
+                            yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
+
+                            IEnumerator SelectPermanentCoroutine2(Permanent permanent)
+                            {
+                                selectedPermanent2 = permanent;
+
+                                yield return null;
+                            }
+                            #endregion
+                        }
+                    }
+
+                    if (selectedMEDNA != null
+                    && selectedPermanent1
+                    != null
+                    && selectedPermanent2 != null
+                    && selectedMEDNA.CanJogressFromTargetPermanent(selectedPermanent1, false))
+                    {
+                        int[] jogressEvoRootsFrameIDs =
+                        {
+                            selectedPermanent1.PermanentFrame.FrameID, selectedPermanent2.PermanentFrame.FrameID
+                        };
+
+                        PlayCardClass playCard = new PlayCardClass(
+                            cardSources: new List<CardSource>() { selectedMEDNA },
+                            hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
+                            payCost: true,
+                            targetPermanent: null,
+                            isTapped: false,
+                            root: SelectCardEffect.Root.Hand,
+                            activateETB: true);
+
+                        playCard.SetJogress(jogressEvoRootsFrameIDs);
+
+                        yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
+                    }
+                }
+            }
+            #endregion
+
+            return cardEffects;
+        }
+    }
+}