Jelajahi Sumber

Update EX7_047.cs

x89rt2 1 bulan lalu
induk
melakukan
d9349fb6a7
1 mengubah file dengan 71 tambahan dan 182 penghapusan
  1. 71 182
      Assets/Scripts/CardEffect/EX7/Black/EX7_047.cs

+ 71 - 182
Assets/Scripts/CardEffect/EX7/Black/EX7_047.cs

@@ -1,10 +1,8 @@
 using System.Collections;
 using System.Collections.Generic;
-using UnityEngine;
 using System.Linq;
-using System;
-using Photon.Pun;
 
+// Eldradimon
 namespace DCGO.CardEffects.EX7
 {
     public class EX7_047 : CEntity_Effect
@@ -14,12 +12,11 @@ namespace DCGO.CardEffects.EX7
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
             #region Alternate Digivolution
-
             if (timing == EffectTiming.None)
             {
                 bool PermanentCondition(Permanent targetPermanent)
                 {
-                    return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.ContainsTraits("NSp");
+                    return targetPermanent.TopCard.EqualsTraits("NSp");
                 }
 
                 cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
@@ -27,14 +24,13 @@ namespace DCGO.CardEffects.EX7
                     digivolutionCost: 3,
                     ignoreDigivolutionRequirement: false,
                     card: card,
-                    condition: null)
+                    condition: null,
+                    level: 5)
                 );
             }
-
             #endregion
 
             #region Blocker
-
             if (timing == EffectTiming.None)
             {
                 cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
@@ -42,193 +38,86 @@ namespace DCGO.CardEffects.EX7
                     card: card,
                     condition: null));
             }
-
             #endregion
 
-            #region On Play
-
-            if (timing == EffectTiming.OnEnterFieldAnyone)
+            #region OP/WD Shared
+            string SharedEffectName = "Reveal the top 4 cards of your deck and play Digimon from them";
+
+            CardEffectFactory.ActivateClassesForSharedEffects
+            (ref cardEffects, timing, card,
+                SharedEffectName,
+                SharedActivateCoroutine,
+                SharedEffectDescription,
+                optional: false,
+                onPlay: true,
+                whenDigivolving: true);
+
+            string SharedEffectDescription(string tag) => $"[{tag}] Reveal the top 4 cards of your deck. You may play up to 7 play cost's total worth of Digimon cards with the [NSp] trait among them without paying the costs. Return the rest to the bottom of the deck.";
+          
+            IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
             {
-                const int maxCost = 7;
-
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Reveal the top 4 cards of your deck and play Digimon from them", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
-                activateClass.SetHashString("Reveal_EX7_047");
-                cardEffects.Add(activateClass);
-
-                string EffectDescription()
-                {
-                    return
-                        "[On Play] Reveal the top 4 cards of your deck. You may play up to 7 play cost's total worth of Digimon cards with the [NSp] trait among them without paying the costs. Return the rest to the bottom of the deck.";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
-                }
-
                 bool CanSelectCardCondition(CardSource cardSource)
                 {
-                    return CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass) &&
-                           cardSource.GetCostItself <= maxCost &&
-                           cardSource.ContainsTraits("NSp");
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
+                    return cardSource.IsDigimon
+                        && cardSource.HasPlayCost
+                        && cardSource.GetCostItself <= 7
+                        && cardSource.EqualsTraits("NSp")
+                        && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    int maxCount = card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame());
-
-                    List<CardSource> selectedCards = new List<CardSource>();
+                int maxCount = card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame());
 
-                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
-                        revealCount: 4,
-                        simplifiedSelectCardConditions:
-                        new SimplifiedSelectCardConditionClass[]
-                        {
-                            new(
-                                canTargetCondition: CanSelectCardCondition,
-                                message: "Select cards with the [NSp] whose play costs add up to 7 or less.",
-                                mode: SelectCardEffect.Mode.Custom,
-                                maxCount: maxCount,
-                                selectCardCoroutine: SelectCardCoroutine),
-                        },
-                        remainingCardsPlace: RemainingCardsPlace.DeckBottom,
-                        activateClass: activateClass,
-                        canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
-                        canEndSelectCondition: CanEndSelectCondition,
-                        canNoSelect: true,
-                        canEndNotMax: true
-                    ));
+                List<CardSource> selectedCards = new List<CardSource>();
 
-                    IEnumerator SelectCardCoroutine(CardSource cardSource)
+                yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
+                    revealCount: 4,
+                    simplifiedSelectCardConditions:
+                    new SimplifiedSelectCardConditionClass[]
                     {
-                        selectedCards.Add(cardSource);
-
-                        yield return null;
-                    }
-
-                    bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources, CardSource cardSource)
-                    {
-                        return cardSources.Sum(source => source.GetCostItself) + cardSource.GetCostItself <= maxCost;
-                    }
-
-                    bool CanEndSelectCondition(List<CardSource> cardSources)
-                    {
-                        return cardSources.Count > 0 &&
-                               cardSources.Sum(source => source.GetCostItself) <= maxCost;
-                    }
-
-                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
-                        cardSources: selectedCards,
-                        activateClass: activateClass,
-                        payCost: false,
-                        isTapped: false,
-                        root: SelectCardEffect.Root.Library,
-                        activateETB: true));
-                }
-            }
-
-            #endregion
-
-            #region When Digivolving
-
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                const int maxCost = 7;
-
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Reveal the top 4 cards of your deck and play Digimon from them", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
-                activateClass.SetHashString("Reveal_EX7_047");
-                cardEffects.Add(activateClass);
+                    new(
+                        canTargetCondition: CanSelectCardCondition,
+                        message: "Select cards with the [NSp] whose play costs add up to 7 or less.",
+                        mode: SelectCardEffect.Mode.Custom,
+                        maxCount: maxCount,
+                        selectCardCoroutine: SelectCardCoroutine),
+                    },
+                    remainingCardsPlace: RemainingCardsPlace.DeckBottom,
+                    activateClass: activateClass,
+                    canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
+                    canEndSelectCondition: CanEndSelectCondition,
+                    canNoSelect: true,
+                    canEndNotMax: true
+                ));
 
-                string EffectDescription()
+                IEnumerator SelectCardCoroutine(CardSource cardSource)
                 {
-                    return
-                        "[When Digivolving] Reveal the top 4 cards of your deck. You may play up to 7 play cost's total worth of Digimon cards with the [NSp] trait among them without paying the costs. Return the rest to the bottom of the deck.";
-                }
+                    selectedCards.Add(cardSource);
 
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
+                    yield return null;
                 }
 
-                bool CanSelectCardCondition(CardSource cardSource)
+                bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources, CardSource cardSource)
                 {
-                    return CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass) &&
-                           cardSource.GetCostItself <= maxCost &&
-                           cardSource.ContainsTraits("NSp");
+                    return cardSources.Sum(source => source.GetCostItself) + cardSource.GetCostItself <= 7;
                 }
 
-                bool CanActivateCondition(Hashtable hashtable)
+                bool CanEndSelectCondition(List<CardSource> cardSources)
                 {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
+                    return cardSources.Count > 0 &&
+                           cardSources.Sum(source => source.GetCostItself) <= 7;
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    int maxCount = card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame());
-
-                    List<CardSource> selectedCards = new List<CardSource>();
-
-                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
-                        revealCount: 4,
-                        simplifiedSelectCardConditions:
-                        new SimplifiedSelectCardConditionClass[]
-                        {
-                            new(
-                                canTargetCondition: CanSelectCardCondition,
-                                message: "Select cards with the [NSp] whose play costs add up to 7 or less.",
-                                mode: SelectCardEffect.Mode.Custom,
-                                maxCount: maxCount,
-                                selectCardCoroutine: SelectCardCoroutine),
-                        },
-                        remainingCardsPlace: RemainingCardsPlace.DeckBottom,
-                        activateClass: activateClass,
-                        canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
-                        canEndSelectCondition: CanEndSelectCondition,
-                        canNoSelect: true,
-                        canEndNotMax: true
-                    ));
-
-                    IEnumerator SelectCardCoroutine(CardSource cardSource)
-                    {
-                        selectedCards.Add(cardSource);
-
-                        yield return null;
-                    }
-
-                    bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources, CardSource cardSource)
-                    {
-                        return cardSources.Sum(source => source.GetCostItself) + cardSource.GetCostItself <= maxCost;
-                    }
-
-                    bool CanEndSelectCondition(List<CardSource> cardSources)
-                    {
-                        return cardSources.Count > 0 &&
-                               cardSources.Sum(source => source.GetCostItself) <= maxCost;
-                    }
-
-                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
-                        cardSources: selectedCards,
-                        activateClass: activateClass,
-                        payCost: false,
-                        isTapped: false,
-                        root: SelectCardEffect.Root.Library,
-                        activateETB: true));
-                }
+                yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
+                    cardSources: selectedCards,
+                    activateClass: activateClass,
+                    payCost: false,
+                    isTapped: false,
+                    root: SelectCardEffect.Root.Library,
+                    activateETB: true));
             }
-
             #endregion
 
             #region End of Your Turn
-
             if (timing == EffectTiming.OnEndTurn)
             {
                 ActivateClass activateClass = new ActivateClass();
@@ -244,35 +133,35 @@ namespace DCGO.CardEffects.EX7
                 
                 bool CanUseCondition(Hashtable hashtable)
                 {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
-                           CardEffectCommons.IsOwnerTurn(card);
+                    return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
+                        && CardEffectCommons.IsOwnerTurn(card);
                 }
 
                 bool CanSelectDNACardCondition(CardSource cardSource)
                 {
                     return cardSource.IsDigimon &&
                            cardSource.CanPlayJogress(true) &&
-                           cardSource.ContainsTraits("NSp");
+                           cardSource.EqualsTraits("NSp");
                 }
 
                 bool CanActivateCondition(Hashtable hashtable)
                 {
-                    return CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDNACardCondition) &&
-                           card.Owner.GetBattleAreaDigimons().Count >= 2;
+                    return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
+                        && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDNACardCondition)
+                        && card.Owner.GetBattleAreaDigimons().Count >= 2;
                 }
 
                 IEnumerator ActivateCoroutine(Hashtable hashtable)
                 {
                     yield return ContinuousController.instance.StartCoroutine(
-                                             CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
-                                                 CanSelectDNACardCondition,
-                                                 payCost: true,
-                                                 isHand: true,
-                                                 activateClass
-                                             ));
+                        CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
+                            CanSelectDNACardCondition,
+                            payCost: true,
+                            isHand: true,
+                            activateClass
+                        ));
                 }
             }
-
             #endregion
 
             return cardEffects;