Explorar o código

Merge pull request #715 from DCGO2/x89rt2-patch-4

Update BT16_055.cs
x89rt2 hai 5 meses
pai
achega
a70f026ebc
Modificáronse 1 ficheiros con 84 adicións e 126 borrados
  1. 84 126
      Assets/Scripts/CardEffect/BT16/Black/BT16_055.cs

+ 84 - 126
Assets/Scripts/CardEffect/BT16/Black/BT16_055.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections;
 using System.Collections.Generic;
 
+// Namakemon
 namespace DCGO.CardEffects.BT16
 {
     public class BT16_055 : CEntity_Effect
@@ -32,32 +33,23 @@ namespace DCGO.CardEffects.BT16
             }
             #endregion
 
-            #region On Play/When Digivolving Shared
-            Permanent selectedPermanent = null;
+            #region Shared OP/WD
+            string SharedEffectName() => "Conditionally 1 of your Digimon can't be DP reduced or De-Digivolved, Conditionally 1 of your Digimon gains <Blocker> and <Reboot>";
 
-            bool CanSelectPermanentCondition(Permanent permanent)
-            {
-                return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
-            }
+            string SharedEffectDescription(string tag) => $"[{tag}] If you have 3 or more security cards, 1 of your Digimon can't have its DP reduced by your opponent's effects, and isn't affected by <De-Digivolve> effects until the end of your opponent's turn. If you have 3 or fewer security cards, 1 of your Digimon gains <Blocker> and <Reboot> until the end of your opponent's turn.";
 
-            bool CanActivateCondition(Hashtable hashtable)
+            bool SharedCanActivateCondition(Hashtable hashtable)
             {
-                return CardEffectCommons.IsExistOnBattleArea(card);
+                return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
             }
 
-            IEnumerator AfterSelectPermanent(List<Permanent> permanents)
-            {
-                if (permanents.Count >= 1)
-                    selectedPermanent = permanents[0];
-
-                yield return null;
-            }
+            Permanent selectedPermanent = null;
 
-            bool CardEffectCondition(ICardEffect cardEffect)
+            bool CanSelectPermanentCondition(Permanent permanent)
             {
-                return CardEffectCommons.IsOpponentEffect(cardEffect, card);
+                return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
             }
-
+            
             #region Can't Be De-Digivolved
 
             void ActivateDeDigivolveProtection()
@@ -89,27 +81,9 @@ namespace DCGO.CardEffects.BT16
             }
             #endregion
 
-            #endregion
-
-            #region On Play
-            if (timing == EffectTiming.OnEnterFieldAnyone)
+            IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
             {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Digimon can't be DP reduced or De-Digivolved, Digimon gains <Blocker> and <Reboot>", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
-                cardEffects.Add(activateClass);
-
-                string EffectDiscription()
-                {
-                    return "[On Play] If you have 3 or more security cards, 1 of your Digimon can't have its DP reduced by your opponent's effects, and isn't affected by <De-Digivolve> effects until the end of your opponent's turn. If you have 3 or fewer security cards, 1 of your Digimon gains <Blocker> and <Reboot> until the end of your opponent's turn.";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                if (card.Owner.SecurityCards.Count >= 3)
                 {
                     SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
 
@@ -121,72 +95,37 @@ namespace DCGO.CardEffects.BT16
                             maxCount: 1,
                             canNoSelect: false,
                             canEndNotMax: false,
-                            selectPermanentCoroutine: null,
-                            afterSelectPermanentCoroutine: AfterSelectPermanent,
+                            selectPermanentCoroutine: SelectPermanentCoroutine,
+                            afterSelectPermanentCoroutine: null,
                             mode: SelectPermanentEffect.Mode.Custom,
                             cardEffect: activateClass);
 
                     selectPermanentEffect.SetUpCustomMessage(
-                                "Select Digimon that will get effects.",
-                                "The opponent is selecting Digimon that will get effects.");
+                                "Select 1 Digimon that can't have its DP reduced by your opponent's effects and isn't affected by <De-Digivolve> effects until the end of your opponent's turn.",
+                                "The opponent is selecting 1 Digimon that can't have its DP reduced by your opponent's effects and isn't affected by <De-Digivolve> effects until the end of your turn.");
+
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
 
-                    if (card.Owner.SecurityCards.Count >= 3)
+                    IEnumerator SelectPermanentCoroutine(Permanent permanent)
                     {
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
-
-                        if (selectedPermanent != null)
-                        {
-                            ActivateDeDigivolveProtection();
-
-                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
-                                targetPermanent: selectedPermanent,
-                                cardEffectCondition: CardEffectCondition,
-                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                activateClass: activateClass,
-                                effectName: "Can't have DP reduced"));
-                        }
+                        selectedPermanent = permanent;
+
+                        yield return null;
                     }
 
-                    if (card.Owner.SecurityCards.Count <= 3)
+                    if (selectedPermanent != null)
                     {
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
-
-                        if (selectedPermanent != null)
-                        {
-                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot(
-                                targetPermanent: selectedPermanent,
-                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                activateClass: activateClass));
-
-                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
-                                targetPermanent: selectedPermanent,
-                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                activateClass: activateClass));
-                        }
+                        ActivateDeDigivolveProtection();
+
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
+                            targetPermanent: selectedPermanent,
+                            cardEffectCondition: cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card),
+                            effectDuration: EffectDuration.UntilOpponentTurnEnd,
+                            activateClass: activateClass,
+                            effectName: "Can't have DP reduced"));
                     }
                 }
-            }
-            #endregion
-
-            #region When Digivolving
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Digimon can't be DP reduced or De-Digivolved, Digimon gains <Blocker> and <Reboot>", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
-                cardEffects.Add(activateClass);
-
-                string EffectDiscription()
-                {
-                    return "[When Digivolving] If you have 3 or more security cards, 1 of your Digimon can't have its DP reduced by your opponent's effects, and isn't affected by <De-Digivolve> effects until the end of your opponent's turn. If you have 3 or fewer security cards, 1 of your Digimon gains <Blocker> and <Reboot> until the end of your opponent's turn.";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                if (card.Owner.SecurityCards.Count <= 3)
                 {
                     SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
 
@@ -198,53 +137,72 @@ namespace DCGO.CardEffects.BT16
                             maxCount: 1,
                             canNoSelect: false,
                             canEndNotMax: false,
-                            selectPermanentCoroutine: null,
-                            afterSelectPermanentCoroutine: AfterSelectPermanent,
+                            selectPermanentCoroutine: SelectPermanentCoroutine,
+                            afterSelectPermanentCoroutine: null,
                             mode: SelectPermanentEffect.Mode.Custom,
                             cardEffect: activateClass);
 
                     selectPermanentEffect.SetUpCustomMessage(
-                                "Select Digimon that will get effects.",
-                                "The opponent is selecting Digimon that will get effects.");
+                                "Select 1 Digimon that gains <Blocker> and <Reboot> until the end of your opponent's turn.",
+                                "The opponent is selecting 1 Digimon that gains <Blocker> and <Reboot> until the end of your turn.");
 
-                    if (card.Owner.SecurityCards.Count >= 3)
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+                    IEnumerator SelectPermanentCoroutine(Permanent permanent)
                     {
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
-
-                        if (selectedPermanent != null)
-                        {
-                            ActivateDeDigivolveProtection();
-
-                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
-                                targetPermanent: selectedPermanent,
-                                cardEffectCondition: CardEffectCondition,
-                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                activateClass: activateClass,
-                                effectName: "Can't have DP reduced"));
-                        }
+                        selectedPermanent = permanent;
+
+                        yield return null;
                     }
 
-                    if (card.Owner.SecurityCards.Count <= 3)
+                    if (selectedPermanent != null)
                     {
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
-
-                        if (selectedPermanent != null)
-                        {
-                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot(
-                                targetPermanent: selectedPermanent,
-                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                activateClass: activateClass));
-
-                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
-                                targetPermanent: selectedPermanent,
-                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                activateClass: activateClass));
-                        }
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot(
+                            targetPermanent: selectedPermanent,
+                            effectDuration: EffectDuration.UntilOpponentTurnEnd,
+                            activateClass: activateClass));
+
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
+                            targetPermanent: selectedPermanent,
+                            effectDuration: EffectDuration.UntilOpponentTurnEnd,
+                            activateClass: activateClass));
                     }
                 }
             }
             #endregion
 
+            #region On Play
+            if (timing == EffectTiming.OnEnterFieldAnyone)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
+                activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
+                cardEffects.Add(activateClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
+                        && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
+                }
+            }
+            #endregion
+
+            #region When Digivolving
+            if (timing == EffectTiming.OnEnterFieldAnyone)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
+                activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
+                cardEffects.Add(activateClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
+                        && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
+                }
+            }
+            #endregion
+
             #region Inherited Effect
             if (timing == EffectTiming.None)
             {