Quellcode durchsuchen

Merge pull request #1569 from DCGO2/hooperk-EX4-059

Update EX4-059
x89rt2 vor 1 Monat
Ursprung
Commit
025f91006a
1 geänderte Dateien mit 83 neuen und 117 gelöschten Zeilen
  1. 83 117
      Assets/Scripts/CardEffect/EX4/Purple/EX4_059.cs

+ 83 - 117
Assets/Scripts/CardEffect/EX4/Purple/EX4_059.cs

@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
 
+// Cherubimon
 namespace DCGO.CardEffects.EX4
 {
     public class EX4_059 : CEntity_Effect
@@ -9,183 +10,148 @@ namespace DCGO.CardEffects.EX4
         {
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
+            #region Alt Evo
             if (timing == EffectTiming.None)
             {
                 bool PermanentCondition(Permanent targetPermanent)
                 {
-                    return targetPermanent.TopCard.CardColors.Contains(CardColor.Green) && targetPermanent.TopCard.CardColors.Count == 2 && targetPermanent.TopCard.HasLevel && targetPermanent.Level == 5;
+                    return targetPermanent.TopCard.CardColors.Contains(CardColor.Green)
+                        && targetPermanent.TopCard.CardColors.Count == 2;
                 }
 
-                cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
+                cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
             }
+            #endregion
 
+            #region Alliance
             if (timing == EffectTiming.OnAllyAttack)
             {
                 cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
             }
+            #endregion
 
+            #region When Digivolving
             if (timing == EffectTiming.OnEnterFieldAnyone)
             {
                 ActivateClass activateClass = new ActivateClass();
                 activateClass.SetUpICardEffect("This Digimon and your 1 Digimon gains effects", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
                 cardEffects.Add(activateClass);
 
-                string EffectDiscription()
+                string EffectDescription()
                 {
                     return "[When Digivolving] Until the end of your opponent's turn, this Digimon and 1 of your level 5 or lower Digimon gain \"[On Deletion] You may play this card without paying the cost.\"";
                 }
 
                 bool CanSelectPermanentCondition(Permanent permanent)
                 {
-                    if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
-                    {
-                        if (permanent.Level <= 5)
-                        {
-                            if (permanent.TopCard.HasLevel)
-                            {
-                                return true;
-                            }
-                        }
-                    }
-
-                    return false;
+                    return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                        && permanent.TopCard.HasLevel
+                        && permanent.Level <= 5;
                 }
 
                 bool CanUseCondition(Hashtable hashtable)
                 {
-                    return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
+                    return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
+                        && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
                 }
 
                 bool CanActivateCondition(Hashtable hashtable)
                 {
-                    if (CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        return true;
-                    }
-
-                    return false;
+                    return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
                 }
 
                 IEnumerator ActivateCoroutine(Hashtable _hashtable)
                 {
-                    if (isExistOnField(card))
+                    List<Permanent> selectedPermanents = new List<Permanent>() { card.PermanentOfThisCard() };
+
+                    if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
                     {
-                        if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
+                        SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                        selectPermanentEffect.SetUp(
+                            selectPlayer: card.Owner,
+                            canTargetCondition: CanSelectPermanentCondition,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            maxCount: 1,
+                            canNoSelect: false,
+                            canEndNotMax: false,
+                            selectPermanentCoroutine: SelectPermanentCoroutine,
+                            afterSelectPermanentCoroutine: null,
+                            mode: SelectPermanentEffect.Mode.Custom,
+                            cardEffect: activateClass);
+
+                        selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+                        IEnumerator SelectPermanentCoroutine(Permanent permanent)
                         {
-                            List<Permanent> slectedPermanents = new List<Permanent>() { card.PermanentOfThisCard() };
-
-                            if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
-                            {
-                                int maxCount = 1;
+                            selectedPermanents.Add(permanent);
 
-                                SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
-
-                                selectPermanentEffect.SetUp(
-                                    selectPlayer: card.Owner,
-                                    canTargetCondition: CanSelectPermanentCondition,
-                                    canTargetCondition_ByPreSelecetedList: null,
-                                    canEndSelectCondition: null,
-                                    maxCount: maxCount,
-                                    canNoSelect: false,
-                                    canEndNotMax: false,
-                                    selectPermanentCoroutine: SelectPermanentCoroutine,
-                                    afterSelectPermanentCoroutine: null,
-                                    mode: SelectPermanentEffect.Mode.Custom,
-                                    cardEffect: activateClass);
+                            yield return null;
+                        }
+                    }
 
-                                selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
+                    foreach (Permanent selectedPermanent in selectedPermanents)
+                    {
+                        if (selectedPermanent != null)
+                        {
+                            CardSource topCard = null;
 
-                                yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                            ActivateClass activateClass1 = new ActivateClass();
+                            activateClass1.SetUpICardEffect("Play this card from trash", CanUseCondition1, selectedPermanent.TopCard);
+                            activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDescription1());
+                            activateClass1.SetEffectSourcePermanent(selectedPermanent);
+                            CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
 
-                                IEnumerator SelectPermanentCoroutine(Permanent permanent)
-                                {
-                                    slectedPermanents.Add(permanent);
+                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
 
-                                    yield return null;
-                                }
+                            string EffectDescription1()
+                            {
+                                return "[On Deletion] You may play this card without paying the cost.";
                             }
 
-                            foreach (Permanent selectedPermanent in slectedPermanents)
+                            bool CanUseCondition1(Hashtable hashtable1)
                             {
-                                if (selectedPermanent != null)
+                                if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable1, (permanent) => permanent == selectedPermanent, activateClass1))
                                 {
-                                    ActivateClass activateClass1 = new ActivateClass();
-                                    activateClass1.SetUpICardEffect("Play this card from trash", CanUseCondition1, selectedPermanent.TopCard);
-                                    activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDiscription1());
-                                    activateClass1.SetEffectSourcePermanent(selectedPermanent);
-                                    CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
-
-                                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
+                                    topCard = selectedPermanent.TopCard;
 
-                                    string EffectDiscription1()
+                                    if (!topCard.CanNotBeAffected(activateClass))
                                     {
-                                        return "[On Deletion] You may play this card without paying the cost.";
+                                        return true;
                                     }
+                                }
 
-                                    bool CanUseCondition1(Hashtable hashtable1)
-                                    {
-                                        if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable1, (permanent) => permanent == selectedPermanent, activateClass1))
-                                        {
-                                            if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
-                                            {
-                                                return true;
-                                            }
-                                        }
-
-                                        return false;
-                                    }
+                                return false;
+                            }
 
-                                    bool CanActivateCondition1(Hashtable hashtable1)
-                                    {
-                                        if (CardEffectCommons.CanActivateOnDeletion(selectedPermanent.TopCard, activateClass1))
-                                        {
-                                            if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: selectedPermanent.TopCard, payCost: false, cardEffect: activateClass1))
-                                            {
-                                                return true;
-                                            }
-                                        }
-
-                                        if (CardEffectCommons.IsTopCardInTrashOnDeletion(hashtable1))
-                                        {
-                                            CardSource TopCard = CardEffectCommons.GetTopCardFromEffectHashtable(hashtable1);
-
-                                            if (TopCard != null)
-                                            {
-                                                if (CardEffectCommons.IsExistOnTrash(TopCard))
-                                                {
-                                                    if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: TopCard, payCost: false, cardEffect: activateClass1))
-                                                    {
-                                                        return true;
-                                                    }
-                                                }
-                                            }
-                                        }
-
-                                        return false;
-                                    }
+                            bool CanActivateCondition1(Hashtable hashtable1)
+                            {
+                                return CardEffectCommons.CanActivateOnDeletion(topCard, activateClass1)
+                                    && CardEffectCommons.CanPlayAsNewPermanent(cardSource: topCard, payCost: false, cardEffect: activateClass1);
+                            }
 
-                                    IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
-                                    {
-                                        CardSource TopCard = CardEffectCommons.GetTopCardFromEffectHashtable(_hashtable1);
-
-                                        if (TopCard != null)
-                                        {
-                                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
-                                                cardSources: new List<CardSource>() { TopCard },
-                                                activateClass: activateClass1,
-                                                payCost: false,
-                                                isTapped: false,
-                                                root: SelectCardEffect.Root.Trash,
-                                                activateETB: true));
-                                        }
-                                    }
+                            IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
+                            {
+                                if (topCard != null)
+                                {
+                                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
+                                        cardSources: new List<CardSource>() { topCard },
+                                        activateClass: activateClass1,
+                                        payCost: false,
+                                        isTapped: false,
+                                        root: SelectCardEffect.Root.Trash,
+                                        activateETB: true));
                                 }
                             }
                         }
                     }
                 }
             }
+            #endregion
 
             return cardEffects;
         }