Jelajahi Sumber

Update ShogunGekomon_EX7_022.cs

Andrej Erdelsky 1 tahun lalu
induk
melakukan
e8771ff854
1 mengubah file dengan 39 tambahan dan 72 penghapusan
  1. 39 72
      Assets/CardEffect/EX7/Blue/ShogunGekomon_EX7_022.cs

+ 39 - 72
Assets/CardEffect/EX7/Blue/ShogunGekomon_EX7_022.cs

@@ -10,13 +10,14 @@ namespace DCGO.CardEffects.EX7
         public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
         {
             List<ICardEffect> cardEffects = new List<ICardEffect>();
-            
+
             #region Alternate Digivolution
+
             if (timing == EffectTiming.None)
             {
                 bool PermanentCondition(Permanent targetPermanent)
                 {
-                    if(targetPermanent.TopCard.HasLevel && targetPermanent.Level == 4)
+                    if (targetPermanent.TopCard.HasLevel && targetPermanent.Level == 4)
                         return targetPermanent.TopCard.CardTraits.Contains("NSp");
 
                     return false;
@@ -30,18 +31,19 @@ namespace DCGO.CardEffects.EX7
                     condition: null)
                 );
             }
-            #endregion 
-            
+
+            #endregion
+
             #region On Play
 
             if (timing == EffectTiming.OnEnterFieldAnyone)
             {
                 ActivateClass activateClass = new ActivateClass();
                 activateClass.SetUpICardEffect("Opponent's 1 Digimon or Tamer can't suspend", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
                 cardEffects.Add(activateClass);
 
-                string EffectDiscription()
+                string EffectDescription()
                 {
                     return "[On Play] 1 of your opponent's Digimon or Tamers can't suspend until the end of their turn.";
                 }
@@ -74,7 +76,7 @@ namespace DCGO.CardEffects.EX7
                     return false;
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
                 {
                     if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
                     {
@@ -95,7 +97,8 @@ namespace DCGO.CardEffects.EX7
                             mode: SelectPermanentEffect.Mode.Custom,
                             cardEffect: activateClass);
 
-                        selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will be unable to suspend.", "The opponent is selecting 1 Digimon that will get unable to suspend.");
+                        selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will be unable to suspend.",
+                            "The opponent is selecting 1 Digimon that will get unable to suspend.");
 
                         yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
 
@@ -108,14 +111,15 @@ namespace DCGO.CardEffects.EX7
                                 CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
                                 canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
                                 canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
-                                selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
+                                selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
 
                                 if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
                                 {
-                                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
+                                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
+                                        .CreateDebuffEffect(selectedPermanent));
                                 }
 
-                                bool CanUseCondition1(Hashtable hashtable)
+                                bool CanUseCondition1(Hashtable hashtableDebuff)
                                 {
                                     if (selectedPermanent.TopCard != null)
                                     {
@@ -128,9 +132,9 @@ namespace DCGO.CardEffects.EX7
                                     return false;
                                 }
 
-                                bool PermanentCondition(Permanent permanent)
+                                bool PermanentCondition(Permanent permanentDebuff)
                                 {
-                                    if (permanent == selectedPermanent)
+                                    if (permanentDebuff == selectedPermanent)
                                     {
                                         return true;
                                     }
@@ -142,9 +146,9 @@ namespace DCGO.CardEffects.EX7
                     }
                 }
             }
-            
+
             #endregion
-            
+
             #region Owner's Turn Effect
 
             if (timing == EffectTiming.None)
@@ -152,10 +156,10 @@ namespace DCGO.CardEffects.EX7
                 ActivateClass activateClass = new ActivateClass();
                 activateClass.SetUpICardEffect("NSp digimon can't have attack targets switched", CanUseCondition, card);
                 activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
-                    EffectDiscription());
+                    EffectDescription());
                 cardEffects.Add(activateClass);
 
-                string EffectDiscription()
+                string EffectDescription()
                 {
                     return
                         "[Your Turn] All of your Digimon with the [NSp] trait trait can't have their attack targets switched.";
@@ -163,71 +167,34 @@ namespace DCGO.CardEffects.EX7
 
                 bool CanUseCondition(Hashtable hashtable)
                 {
-                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
-                    {
-                        return CardEffectCommons.IsOwnerTurn(card);
-                    }
-
-                    return false;
+                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
+                           CardEffectCommons.IsOwnerTurn(card);
                 }
 
                 bool CanActivateCondition(Hashtable hashtable)
                 {
-                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
-                        return true;
-                    
-                    return false;
+                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
                 {
-                    List<Permanent> validCards = new List<Permanent>();
-
-                    foreach (Permanent toCheck in card.Owner.GetBattleAreaPermanents())
-                    {
-                        if (toCheck.TopCard.EqualsTraits("NSp"))
-                            validCards.Add(toCheck);
-                    }
-
-                    if (validCards.Count > 0)
+                    foreach (var permanent in card.Owner.GetBattleAreaDigimons()
+                                 .Where(permanent => permanent != null && permanent.TopCard.ContainsTraits("NSp")))
                     {
-                        foreach (Permanent validCard in validCards)
-                        {
-                            CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass =
-                                new CanNotSwitchAttackTargetClass();
-                            canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be switched", CanUseCondition1,
-                                validCard.TopCard);
-                            canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
-                            validCard.UntilEachTurnEndEffects.Add((_timing) => canNotSwitchAttackTargetClass);
-
-                            yield return ContinuousController.instance.StartCoroutine(
-                                GManager.instance.GetComponent<Effects>().CreateBuffEffect(validCard));
+                        CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
+                        canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be switched", 
+                            _ => true, permanent.TopCard);
+                        canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
+                        permanent.UntilEachTurnEndEffects.Add(_ => canNotSwitchAttackTargetClass);
 
-                            bool CanUseCondition1(Hashtable hashtable)
-                            {
-                                if (validCard != null)
-                                {
-                                    return true;
-                                }
-
-                                return false;
-                            }
-
-                            bool PermanentCondition(Permanent permanent)
-                            {
-                                if (permanent != null)
-                                {
-                                    if (permanent.TopCard != null)
-                                    {
-                                        if (permanent == validCard)
-                                        {
-                                            return true;
-                                        }
-                                    }
-                                }
+                        yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
+                            .CreateBuffEffect(permanent));
 
-                                return false;
-                            }
+                        bool PermanentCondition(Permanent buffPermanent)
+                        {
+                            return buffPermanent != null &&
+                                   buffPermanent.TopCard != null &&
+                                   buffPermanent == permanent;
                         }
                     }
                 }