Browse Source

Update ICardEffect.cs

Property getter unexpectedly feeding incorrect hashtable to CanTrigger
Causing RegisterOnDeletion to override correct value

CanActivate must consider that played ESS granting card must still trigger OD as long as Top Card remains in the trash
Solly 1 tháng trước cách đây
mục cha
commit
d7b8dc7264
1 tập tin đã thay đổi với 28 bổ sung35 xóa
  1. 28 35
      Assets/Scripts/Script/ICardEffect.cs

+ 28 - 35
Assets/Scripts/Script/ICardEffect.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine;
@@ -391,7 +391,8 @@ public abstract class ICardEffect
                 {
                 {
                     if (IsInheritedEffect || IsLinkedEffect)
                     if (IsInheritedEffect || IsLinkedEffect)
                     {
                     {
-                        if (EffectSourceCard == EffectSourceCard.PermanentOfThisCard().TopCard)
+                        bool CardBelowBecameTopMostCard = EffectSourceCard == EffectSourceCard.PermanentOfThisCard().TopCard;
+                        if (CardBelowBecameTopMostCard)
                             return false;
                             return false;
 
 
                         if (EffectSourceCard.IsFlipped)
                         if (EffectSourceCard.IsFlipped)
@@ -402,6 +403,28 @@ public abstract class ICardEffect
 
 
                         if (IsLinkedEffect && !EffectSourceCard.PermanentOfThisCard().LinkedCards.Contains(EffectSourceCard))
                         if (IsLinkedEffect && !EffectSourceCard.PermanentOfThisCard().LinkedCards.Contains(EffectSourceCard))
                             return false;
                             return false;
+
+                        #region Determination whether the permanent is same as when triggered
+                        
+                        bool CardBelowMovedFromUnderPermanentToAnother;
+                        if (((ActivateICardEffect)this).PermanentWhenTriggered != null)
+                        {
+                            if (EffectSourceCard != null)
+                            {
+                                Permanent currentPermanent = EffectSourceCard.PermanentOfThisCard();
+
+                                if (currentPermanent != null)
+                                {
+                                    CardBelowMovedFromUnderPermanentToAnother = currentPermanent != ((ActivateICardEffect)this).PermanentWhenTriggered;
+                                    if (CardBelowMovedFromUnderPermanentToAnother)
+                                    {
+                                        return false;
+                                    }
+                                }
+                            }
+                        }
+
+                        #endregion
                     }
                     }
                     else
                     else
                     {
                     {
@@ -423,34 +446,6 @@ public abstract class ICardEffect
             return false;
             return false;
         }
         }
 
 
-        #endregion
-        //TODO: Look into this for the on deletion General issue
-        #region Determination whether the permanent is same as when triggered
-
-        if (IsInheritedEffect || IsLinkedEffect)
-        {
-            if (this is ActivateICardEffect)
-            {
-                Permanent PermanentWhenTriggered = ((ActivateICardEffect)this).PermanentWhenTriggered;
-
-                if (PermanentWhenTriggered != null)
-                {
-                    if (EffectSourceCard != null)
-                    {
-                        Permanent currentPermanent = EffectSourceCard.PermanentOfThisCard();
-
-                        if (currentPermanent != null)
-                        {
-                            if (currentPermanent != PermanentWhenTriggered)
-                            {
-                                return false;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
         #endregion
         #endregion
 
 
         return true;
         return true;
@@ -807,14 +802,12 @@ public abstract class ICardEffect
                 {
                 {
                     if (EffectDiscription.StartsWith("[On Deletion]"))
                     if (EffectDiscription.StartsWith("[On Deletion]"))
                     {
                     {
-                        Permanent effectPermanent = EffectSourceCard.PermanentOfThisCard() ?? new Permanent(new List<CardSource>() { EffectSourceCard });
+                        // Permanent effectPermanent = EffectSourceCard.PermanentOfThisCard() ?? new Permanent(new List<CardSource>() { EffectSourceCard });
 
 
-                        Hashtable hashtable = CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { effectPermanent }, null, null, false);
+                        // Hashtable hashtable = CardEffectCommons.OnDeletionHashtable(new List<Permanent>() { effectPermanent }, null, null, false);
 
 
-                        if (CanTrigger(hashtable))
-                        {
+                        // if (CanTrigger(hashtable))
                             return true;
                             return true;
-                        }
                     }
                     }
                 }
                 }
             }
             }