Forráskód Böngészése

Implement AD1-025 and When Digimon Leave Trigger

hooperk 5 hónapja
szülő
commit
31bf1fcdf4

+ 1 - 1
Assets/Scripts/CardEffect/AD1/Red/AD1_025.cs

@@ -164,7 +164,7 @@ namespace DCGO.CardEffects.AD1
                 bool CanUseCondition(Hashtable hashtable)
                 {
                     return CardEffectCommons.IsExistOnBattleArea(card)
-                        && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, IsOpponentsDigimon);
+                        && CardEffectCommons.CanTriggerOnPermanentLeave(hashtable, IsOpponentsDigimon);
                 }
 
                 bool IsEnemyOptionPermanent(Permanent permanent)

+ 31 - 0
Assets/Scripts/Script/CardEffectCommons/CanUseEffects/OnDeletion.cs

@@ -47,6 +47,37 @@ public partial class CardEffectCommons
     }
     #endregion
 
+    #region Can trigger "when permanent leaves the battle area" effect
+    public static bool CanTriggerOnPermanentLeave(Hashtable hashtable, Func<Permanent, bool> permanentCondition)
+    {
+        List<Hashtable> hashtables = GetHashtablesFromHashtable(hashtable);
+
+        if (hashtables != null)
+        {
+            foreach (Hashtable hashtable1 in hashtables)
+            {
+                Permanent permanent = GetPermanentFromHashtable(hashtable1);
+
+                if (permanent != null)
+                {
+                    if (permanent.TopCard != null)
+                    {
+                        if (permanentCondition != null)
+                        {
+                            if (permanentCondition(permanent))
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+
     #region Can trigger "when permanent is deleted by battle" effects
     public static bool IsByBattle(Hashtable hashtable)
     {

+ 1 - 1
Assets/Scripts/Script/CardEffectCommons/HashtableSetting.cs

@@ -81,7 +81,7 @@ public partial class CardEffectCommons
     }
     #endregion
 
-    #region Hashtable used when check whether the permanent can activate [On Deletion] or "Permanent returned to hand" effect
+    #region Hashtable used when check whether the permanent can activate [On Deletion], "Permanent leaves" or "Permanent returned to hand" effect
     public static Hashtable OnDeletionHashtable(List<Permanent> permanents, ICardEffect cardEffect, IBattle battle, bool isDPZero)
     {
         Hashtable hashtable = new Hashtable();