Просмотр исходного кода

Implement Lewis's SuspendPeremanentAndProcess

Co-authored-by: LewisWelch94
hooperk 5 месяцев назад
Родитель
Сommit
984c8d5415

+ 32 - 27
Assets/Scripts/CardEffect/AD1/Blue/AD1_019.cs

@@ -57,45 +57,50 @@ namespace DCGO.CardEffects.AD1
 
                 IEnumerator ActivateCoroutine(Hashtable hashtable)
                 {
-                    yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
+                     yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SuspendPeremanentAndProcessAccordingToResult(
                         new List<Permanent>() { card.PermanentOfThisCard() },
-                        CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
+                        activateClass,
+                        SuccessProcess,
+                        null));
 
-                    if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsAdventureDigimon))
+                    IEnumerator SuccessProcess(List<Permanent> suspendedPermaments)
                     {
-                        List<CardSource> tamerCards = new List<CardSource>();
-
-                        foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
+                        if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsAdventureDigimon))
                         {
-                            if (permanent.IsTamer)
+                            List<CardSource> tamerCards = new List<CardSource>();
+
+                            foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
                             {
-                                tamerCards.Add(permanent.TopCard);
+                                if (permanent.IsTamer)
+                                {
+                                    tamerCards.Add(permanent.TopCard);
+                                }
                             }
-                        }
 
-                        int reduceCost = Combinations.GetUniqueColorCardCount(tamerCards) / 2;
+                            int reduceCost = Combinations.GetUniqueColorCardCount(tamerCards) / 2;
 
-                        SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+                            SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
 
-                        selectHandEffect.SetUp(
-                            selectPlayer: card.Owner,
-                            canTargetCondition: IsAdventureDigimon,
-                            canTargetCondition_ByPreSelecetedList: null,
-                            canEndSelectCondition: null,
-                            maxCount: 1,
-                            canNoSelect: true,
-                            canEndNotMax: false,
-                            isShowOpponent: true,
-                            selectCardCoroutine: null,
-                            afterSelectCardCoroutine: null,
-                            mode: SelectHandEffect.Mode.PlayForCost,
-                            cardEffect: activateClass);
+                            selectHandEffect.SetUp(
+                                selectPlayer: card.Owner,
+                                canTargetCondition: IsAdventureDigimon,
+                                canTargetCondition_ByPreSelecetedList: null,
+                                canEndSelectCondition: null,
+                                maxCount: 1,
+                                canNoSelect: true,
+                                canEndNotMax: false,
+                                isShowOpponent: true,
+                                selectCardCoroutine: null,
+                                afterSelectCardCoroutine: null,
+                                mode: SelectHandEffect.Mode.PlayForCost,
+                                cardEffect: activateClass);
 
-                        selectHandEffect.SetReducedCostTuple((reduceCost, null));
+                            selectHandEffect.SetReducedCostTuple((reduceCost, null));
 
-                        selectHandEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
+                            selectHandEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
 
-                        yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
+                            yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
+                        }
                     }
                 }
             }

+ 8 - 0
Assets/Scripts/Script/CardController.cs

@@ -5111,7 +5111,13 @@ public class SuspendPermanentsClass
         _hashtable = hashtable;
     }
 
+    public bool IsSuspended(Permanent permanent)
+    {
+        return SuspendedPermanents.Contains(permanent);
+    }
+
     List<Permanent> _permanents { get; set; }
+    public List<Permanent> SuspendedPermanents { get; private set; } = new List<Permanent>();
     Hashtable _hashtable { get; set; }
 
     public IEnumerator Tap()
@@ -5165,6 +5171,8 @@ public class SuspendPermanentsClass
             {
                 permanent.ShowingPermanentCard.ShowPermanentData(true);
             }
+
+            SuspendedPermanents.Add(permanent);
         }
 
         if (suspendTargetPermanents.Count >= 1)

+ 26 - 0
Assets/Scripts/Script/CardEffectCommons.cs

@@ -415,6 +415,32 @@ public partial class CardEffectCommons
 
     #endregion
 
+    #region Suspend target permanents, and the effect determines whether the permanent has been suspended or not
+
+    public static IEnumerator SuspendPeremanentAndProcessAccordingToResult(List<Permanent> targetPermanents, ICardEffect activateClass, Func<List<Permanent>, IEnumerator> successProcess, Func<IEnumerator> failureProcess)
+    {
+        SuspendPermanentsClass suspendPermanentsClass = new SuspendPermanentsClass(targetPermanents, CardEffectHashtable(activateClass));
+
+        yield return ContinuousController.instance.StartCoroutine(suspendPermanentsClass.Tap());
+
+        if (targetPermanents.Some((permanent) => suspendPermanentsClass.IsSuspended(permanent)))
+        {
+            if (successProcess != null)
+            {
+                yield return ContinuousController.instance.StartCoroutine(successProcess(suspendPermanentsClass.SuspendedPermanents));
+            }
+        }
+        else
+        {
+            if (failureProcess != null)
+            {
+                yield return ContinuousController.instance.StartCoroutine(failureProcess());
+            }
+        }
+    }
+
+    #endregion
+
     #region Delete target permanents, and the effect determines whether the permanent has been deleted or not
 
     public static IEnumerator DeletePeremanentAndProcessAccordingToResult(List<Permanent> targetPermanents, ICardEffect activateClass, Func<List<Permanent>, IEnumerator> successProcess, Func<IEnumerator> failureProcess)