Procházet zdrojové kódy

Fix BT24-090 & BT24-094 throne rooms performance

hooperk před 4 měsíci
rodič
revize
e4d867b3e9

+ 11 - 117
Assets/Scripts/CardEffect/BT24/Blue/BT24_090.cs

@@ -57,139 +57,33 @@ namespace DCGO.CardEffects.BT24
             #endregion
 
             #region Alliance
-
-            string GrantedAllianceHashstring(CardSource cardSource) => $"BT24_090_Alliance_On_{cardSource.CardIndex}_From_{card.CardIndex}";//Get unique reference of this card granting to particular cardsource
-
-            /// Alliance effect which is granted to all of your Digimon while this card is face up in security
-            /// The effect itself tracks if the card granting it is still present and if the conditions for granting are still met
-            ICardEffect GetAllianceEffect(CardSource cardSource)
-            {
-                bool HasOXII(Permanent permanent)
-                {
-                    return permanent.TopCard.EqualsCardName("Neptunemon")
-                        || permanent.TopCard.EqualsCardName("Venusmon");
-                }
-
-                bool Condition()
-                {
-                    return CardEffectCommons.IsExistInSecurity(card, false) //Is this card that provides the effect still providing the effect
-                        && cardSource == cardSource.PermanentOfThisCard().TopCard //Added effects don't check if it is inherited or not so have to check that this is the topcard
-                        && (cardSource.CardColors.Contains(CardColor.Blue) || cardSource.CardColors.Contains(CardColor.Yellow))
-                        && cardSource.HasTSTraits // Does this card meet conditions
-                        && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOXII); // Is the condition for granting met
-                }
-
-                ICardEffect cardEffect = CardEffectFactory.AllianceSelfEffect(false, cardSource, Condition);
-                cardEffect.SetHashString(GrantedAllianceHashstring(cardSource)); // Unique identifier using exact card object references
-                return cardEffect;
-            }
-
-            ///Grant all cards in a permanent the effect permanently
-            ///Grants to every card so effect can survive through degeneration
-            ///The effect's CanUseCondition will deactivate when the conditions for granting are not met
-            void GrantEffect(List<Permanent> permanents)
-            {
-                foreach (Permanent permanent in permanents)
-                {
-                    foreach(CardSource cardSource in permanent.cardSources)
-                    {
-                        if(!cardSource.HasDP || permanent.EffectList_ForCard(EffectTiming.OnAllyAttack, cardSource).Any(effect => effect.HashString == GrantedAllianceHashstring(cardSource)))
-                            continue; // if the card could not be a relevant top card or if it already has the effect, don't grant the effect
-
-                        Func<EffectTiming, ICardEffect> getCardEffect = CardEffectCommons.GetCardEffectByEffectTiming(timing: EffectTiming.OnAllyAttack, cardEffect: GetAllianceEffect(cardSource));
-
-                        permanent.PermanentEffects.Add(getCardEffect);
-                    }
-                }
-            }
-
-            string SharedEffectDescription() => "(Security) [All Turns] All of your blue or yellow [TS] trait Digimon gain <Blocker>. While you have [Neptunemon] or [Venusmon], all of your blue or yellow [TS] trait Digimon gain <Alliance>."; 
-
-            bool IsYourPermanent(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
-
-            #region Give permanents conditional Alliance on card added to security
-            if (timing == EffectTiming.OnAddSecurity)
-            {
-                ActivateClass activateClass = new();
-                activateClass.SetUpICardEffect("Set Up Alliance", CanUseCondition, card);
-                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, SharedEffectDescription());
-                activateClass.SetIsBackgroundProcess(true);
-                cardEffects.Add(activateClass);
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistInSecurity(card, false)
-                        && CardEffectCommons.GetCardSourcesFromHashtable(hashtable).Contains(card);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    List<Permanent> permanents = card.Owner.GetBattleAreaPermanents();
-                    GrantEffect(permanents);
-                    yield return null;
-                }
-            }
-            #endregion
-
-            #region Give permanents conditional Alliance on permanent enter
-            if (timing == EffectTiming.OnEnterFieldAnyone)
+            if (timing == EffectTiming.OnAllyAttack)
             {
-                ActivateClass activateClass = new();
-                activateClass.SetUpICardEffect("Set Up Alliance", CanUseCondition, card);
-                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, SharedEffectDescription());
-                activateClass.SetIsBackgroundProcess(true);
-                cardEffects.Add(activateClass);
-
-                bool CanUseCondition(Hashtable hashtable)
+                bool PermanentCondition(Permanent permanent)
                 {
-                    return CardEffectCommons.IsExistInSecurity(card, false)
-                        && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsYourPermanent)
-                            || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsYourPermanent));
+                    return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                        && (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Yellow))
+                        && permanent.TopCard.HasTSTraits;
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                bool HasOXII(Permanent permanent)
                 {
-                    List<Permanent> permanents = CardEffectCommons.GetHashtablesFromHashtable(hashtable)
-                            .Map(CardEffectCommons.GetPermanentFromHashtable)
-                            .Filter(IsYourPermanent);
-                    GrantEffect(permanents);
-                    yield return null;
+                    return permanent.TopCard.EqualsCardName("Neptunemon")
+                        || permanent.TopCard.EqualsCardName("Venusmon");
                 }
-            }
-            #endregion
-
-            #region Give permanents conditional Alliance on card added to permanent stack
-            if(timing == EffectTiming.OnAddDigivolutionCards)
-            {
-                ActivateClass activateClass = new();
-                activateClass.SetUpICardEffect("Set Up Alliance", CanUseCondition, card);
-                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, SharedEffectDescription());
-                activateClass.SetIsBackgroundProcess(true);
-                cardEffects.Add(activateClass);
 
-                bool CanUseCondition(Hashtable hashtable)
+                bool CanUseCondition()
                 {
                     return CardEffectCommons.IsExistInSecurity(card, false)
-                        && CardEffectCommons.CanTriggerOnAddDigivolutionCard(
-                                hashtable: hashtable,
-                                permanentCondition: IsYourPermanent,
-                                cardEffectCondition: null,
-                                cardCondition: null);
+                        && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOXII);
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    List<Permanent> permanents = new List<Permanent>() { CardEffectCommons.GetPermanentFromHashtable(hashtable) };
-                    GrantEffect(permanents);
-                    yield return null;
-                }
+                cardEffects.Add(CardEffectFactory.AllianceStaticEffect(PermanentCondition, false, card, CanUseCondition));
             }
             #endregion
 
             #endregion
 
-            #endregion
-
             #region Main Effect
 
             if (timing == EffectTiming.OptionSkill)

+ 14 - 115
Assets/Scripts/CardEffect/BT24/Green/BT24_094.cs

@@ -34,8 +34,9 @@ namespace DCGO.CardEffects.BT24
 
             #endregion
 
-            #region All Turns - Security DP
+            #region All Turns - Security
 
+            #region All Turns - Security DP
             if (timing == EffectTiming.None)
             {
                 bool PermanentCondition(Permanent permanent)
@@ -60,136 +61,34 @@ namespace DCGO.CardEffects.BT24
                     effectName: () => "All of your green or yellow [TS] trait Digimon get +2000 DP."));
                 #endregion
             }
+            #endregion
 
             #region All Turns - Security Alliance
-            string GrantedAllianceHashstring(CardSource cardSource) => $"BT24_090_Alliance_On_{cardSource.CardIndex}_From_{card.CardIndex}";//Get unique reference of this card granting to particular cardsource
-
-            /// Alliance effect which is granted to all of your Digimon while this card is face up in security
-            /// The effect itself tracks if the card granting it is still present and if the conditions for granting are still met
-            ICardEffect GetAllianceEffect(CardSource cardSource)
-            {
-                bool HasOXII(Permanent permanent)
-                {
-                    return permanent.TopCard.EqualsCardName("Merukimon")
-                        || permanent.TopCard.EqualsCardName("Minervamon");
-                }
-
-                bool Condition()
-                {
-                    return CardEffectCommons.IsExistInSecurity(card, false) //Is this card that provides the effect still providing the effect
-                        && cardSource == cardSource.PermanentOfThisCard().TopCard //Added effects don't check if it is inherited or not so have to check that this is the topcard
-                        && (cardSource.CardColors.Contains(CardColor.Blue) || cardSource.CardColors.Contains(CardColor.Yellow))
-                        && cardSource.HasTSTraits // Does this card meet conditions
-                        && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOXII); // Is the condition for granting met
-                }
-
-                ICardEffect cardEffect = CardEffectFactory.AllianceSelfEffect(false, cardSource, Condition);
-                cardEffect.SetHashString(GrantedAllianceHashstring(cardSource)); // Unique identifier using exact card object references
-                return cardEffect;
-            }
-
-            ///Grant all cards in a permanent the effect permanently
-            ///Grants to every card so effect can survive through degeneration
-            ///The effect's CanUseCondition will deactivate when the conditions for granting are not met
-            void GrantEffect(List<Permanent> permanents)
+            if (timing == EffectTiming.OnAllyAttack)
             {
-                foreach (Permanent permanent in permanents)
-                {
-                    foreach (CardSource cardSource in permanent.cardSources)
-                    {
-                        if (!cardSource.HasDP || permanent.EffectList_ForCard(EffectTiming.OnAllyAttack, cardSource).Any(effect => effect.HashString == GrantedAllianceHashstring(cardSource)))
-                            continue; // if the card could not be a relevant top card or if it already has the effect, don't grant the effect
-
-                        Func<EffectTiming, ICardEffect> getCardEffect = CardEffectCommons.GetCardEffectByEffectTiming(timing: EffectTiming.OnAllyAttack, cardEffect: GetAllianceEffect(cardSource));
-
-                        permanent.PermanentEffects.Add(getCardEffect);
-                    }
-                }
-            }
-
-            string SharedEffectDescription() => "(Security) [All Turns] All of your blue or yellow [TS] trait Digimon gain <Blocker>. While you have [Neptunemon] or [Venusmon], all of your blue or yellow [TS] trait Digimon gain <Alliance>.";
-
-            bool IsYourPermanent(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
-
-            #region Give permanents conditional Alliance on card added to security
-            if (timing == EffectTiming.OnAddSecurity)
-            {
-                ActivateClass activateClass = new();
-                activateClass.SetUpICardEffect("Set Up Alliance", CanUseCondition, card);
-                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, SharedEffectDescription());
-                activateClass.SetIsBackgroundProcess(true);
-                cardEffects.Add(activateClass);
-
-                bool CanUseCondition(Hashtable hashtable)
+                bool PermanentCondition(Permanent permanent)
                 {
-                    return CardEffectCommons.IsExistInSecurity(card, false)
-                        && CardEffectCommons.GetCardSourcesFromHashtable(hashtable).Contains(card);
+                    return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                        && (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Yellow))
+                        && permanent.TopCard.HasTSTraits;
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                bool HasOXII(Permanent permanent)
                 {
-                    List<Permanent> permanents = card.Owner.GetBattleAreaPermanents();
-                    GrantEffect(permanents);
-                    yield return null;
+                    return permanent.TopCard.EqualsCardName("Merukimon")
+                        || permanent.TopCard.EqualsCardName("Minervamon");
                 }
-            }
-            #endregion
-
-            #region Give permanents conditional Alliance on permanent enter
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                ActivateClass activateClass = new();
-                activateClass.SetUpICardEffect("Set Up Alliance", CanUseCondition, card);
-                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, SharedEffectDescription());
-                activateClass.SetIsBackgroundProcess(true);
-                cardEffects.Add(activateClass);
 
-                bool CanUseCondition(Hashtable hashtable)
+                bool CanUseCondition()
                 {
                     return CardEffectCommons.IsExistInSecurity(card, false)
-                        && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsYourPermanent)
-                            || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsYourPermanent));
+                        && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOXII);
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    List<Permanent> permanents = CardEffectCommons.GetHashtablesFromHashtable(hashtable)
-                            .Map(CardEffectCommons.GetPermanentFromHashtable)
-                            .Filter(IsYourPermanent);
-                    GrantEffect(permanents);
-                    yield return null;
-                }
+                cardEffects.Add(CardEffectFactory.AllianceStaticEffect(PermanentCondition, false, card, CanUseCondition));
             }
             #endregion
 
-            #region Give permanents conditional Alliance on card added to permanent stack
-            if (timing == EffectTiming.OnAddDigivolutionCards)
-            {
-                ActivateClass activateClass = new();
-                activateClass.SetUpICardEffect("Set Up Alliance", CanUseCondition, card);
-                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, SharedEffectDescription());
-                activateClass.SetIsBackgroundProcess(true);
-                cardEffects.Add(activateClass);
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistInSecurity(card, false)
-                        && CardEffectCommons.CanTriggerOnAddDigivolutionCard(
-                                hashtable: hashtable,
-                                permanentCondition: IsYourPermanent,
-                                cardEffectCondition: null,
-                                cardCondition: null);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    List<Permanent> permanents = new List<Permanent>() { CardEffectCommons.GetPermanentFromHashtable(hashtable) };
-                    GrantEffect(permanents);
-                    yield return null;
-                }
-            }
-            #endregion
-            #endregion
             #endregion
 
             #region Main Effect

+ 7 - 7
Assets/Scripts/Script/CardEffectCommons/KeyWordEffects/Alliance.cs

@@ -38,13 +38,13 @@ public partial class CardEffectCommons
     #endregion
 
     #region Effect process of [Alliance]
-    public static IEnumerator AllianceProcess(Hashtable hashtable, ICardEffect activateClass, CardSource card)
+    public static IEnumerator AllianceProcess(Hashtable hashtable, ICardEffect activateClass, Permanent targetPermanent, CardSource card)
     {
         bool CanSelectPermanentCondition(Permanent permanent)
         {
             if (IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
             {
-                if (permanent != card.PermanentOfThisCard())
+                if (permanent != targetPermanent)
                 {
                     if (CanActivateSuspendCostEffect(permanent.TopCard))
                     {
@@ -106,18 +106,18 @@ public partial class CardEffectCommons
                             {
                                 if (tapPermanent.IsSuspended)
                                 {
-                                    if (IsExistOnBattleArea(card))
+                                    if (IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
                                     {
                                         int plusDP = tapPermanent.DP;
 
                                         yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
-                                            targetPermanent: card.PermanentOfThisCard(),
+                                            targetPermanent: targetPermanent,
                                             changeValue: plusDP,
                                             effectDuration: EffectDuration.UntilEndAttack,
                                             activateClass: activateClass));
 
                                         yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
-                                            targetPermanent: card.PermanentOfThisCard(),
+                                            targetPermanent: targetPermanent,
                                             changeValue: 1,
                                             effectDuration: EffectDuration.UntilEndAttack,
                                             activateClass: activateClass));
@@ -205,9 +205,9 @@ public partial class CardEffectCommons
             return true;
         }
 
-        AllianceClass alliance = CardEffectFactory.AllianceStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition);
+        ICardEffect alliance = CardEffectFactory.AllianceStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition);
 
-        AddEffectToPlayer(effectDuration: effectDuration, card: card, cardEffect: alliance, timing: EffectTiming.None);
+        AddEffectToPlayer(effectDuration: effectDuration, card: card, cardEffect: alliance, timing: EffectTiming.OnAllyAttack);
 
         foreach (Permanent permanent in GManager.instance.turnStateMachine.gameContext.PermanentsForTurnPlayer)
         {

+ 31 - 21
Assets/Scripts/Script/CardEffectFactory/KeyWordEffects/Alliance.cs

@@ -71,37 +71,26 @@ public partial class CardEffectFactory
 
         IEnumerator ActivateCoroutine(Hashtable _hashtable)
         {
-            return CardEffectCommons.AllianceProcess(_hashtable, activateClass, card);
+            return CardEffectCommons.AllianceProcess(_hashtable, activateClass, targetPermanent, card);
         }
 
         return activateClass;
     }
     #endregion
 
-    #region Static effect of [Alliance]
-    public static AllianceClass AllianceStaticEffect(Func<Permanent, bool> permanentCondition, bool isInheritedEffect, CardSource card, Func<bool> condition)
+    #region Static effect of [Alliance] to all PermanentCondition Digimon
+    public static ActivateClass AllianceStaticEffect(Func<Permanent, bool> permanentCondition, bool isInheritedEffect, CardSource card, Func<bool> condition)
     {
-        string effectName = "Alliance";
-
-        AllianceClass allianceClass = new AllianceClass();
-        allianceClass.SetUpICardEffect(effectName, CanUseCondition, card);
-        allianceClass.SetUpAllianceClass(PermanentCondition: PermanentCondition);
-
-        if (isInheritedEffect)
-        {
-            allianceClass.SetIsInheritedEffect(true);
-        }
+        ActivateClass activateClass = new ActivateClass();
+        activateClass.SetUpICardEffect("Alliance", CanUseCondition, card);
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, DataBase.AllianceEffectDiscription());
+        activateClass.SetIsInheritedEffect(isInheritedEffect);
 
         bool CanUseCondition(Hashtable hashtable)
         {
-            return condition == null || condition();
-        }
-
-        bool PermanentCondition(Permanent permanent)
-        {
-            if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
+            if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanentCondition))
             {
-                if (permanentCondition == null || permanentCondition(permanent))
+                if (condition == null || condition())
                 {
                     return true;
                 }
@@ -110,7 +99,28 @@ public partial class CardEffectFactory
             return false;
         }
 
-        return allianceClass;
+        bool CanActivateCondition(Hashtable hashtable)
+        {
+            Permanent attackingPermanent = CardEffectCommons.GetAttackerFromHashtable(hashtable);
+
+            bool CanSelectPermanentCondition(Permanent permanent)
+            {
+                return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                    && permanent != attackingPermanent
+                    && CardEffectCommons.CanActivateSuspendCostEffect(permanent.TopCard);
+            }
+
+            return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(attackingPermanent, card)
+                && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition);
+        }
+
+        IEnumerator ActivateCoroutine(Hashtable hashtable)
+        {
+            Permanent attackingPermanent = CardEffectCommons.GetAttackerFromHashtable(hashtable);
+            return CardEffectCommons.AllianceProcess(hashtable, activateClass, attackingPermanent, card);
+        }
+
+        return activateClass;
     }
     #endregion
 }

+ 0 - 7
Assets/Scripts/Script/CardEffectInterfaces.cs

@@ -51,13 +51,6 @@ public interface IRebootEffect
 }
 #endregion
 
-#region "Target permanent gains Alliance" effect
-public interface IAllianceEffect
-{
-    bool HasAlliance(Permanent permanent);
-}
-#endregion
-
 #region "Target permanent gains Scapegoat" effect
 public interface IScapegoatEffect
 {

+ 0 - 35
Assets/Scripts/Script/CardEffects/AllianceClass.cs

@@ -1,35 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using System.Linq;
-using Photon;
-using System;
-
-public class AllianceClass : ICardEffect, IAllianceEffect
-{
-    public void SetUpAllianceClass(Func<Permanent, bool> PermanentCondition)
-    {
-        this.PermanentCondition = PermanentCondition;
-    }
-
-    Func<Permanent, bool> PermanentCondition { get; set; }
-
-    public bool HasAlliance(Permanent permanent)
-    {
-        if (PermanentCondition != null)
-        {
-            if (permanent != null)
-            {
-                if (permanent.TopCard != null)
-                {
-                    if (PermanentCondition(permanent))
-                    {
-                        return true;
-                    }
-                }
-            }
-        }
-
-        return false;
-    }
-}

+ 0 - 11
Assets/Scripts/Script/CardEffects/AllianceClass.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 12be472d7187a674daa43b4847d6b0c2
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 13 - 18
Assets/Scripts/Script/Permanent.cs

@@ -2885,6 +2885,10 @@ public class Permanent
     {
         get
         {
+            Hashtable hashtable = new Hashtable(){
+                {"AttackingPermanent", this}
+            };
+            
             foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
             {
                 foreach (Permanent permanent in player.GetFieldPermanents())
@@ -2892,14 +2896,11 @@ public class Permanent
                     #region Permanent Effects
                     foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.OnAllyAttack))
                     {
-                        if (cardEffect is IAllianceEffect)
+                        if (cardEffect.EffectName == "Alliance")
                         {
-                            if (cardEffect.CanTrigger(null))
+                            if (cardEffect.CanTrigger(hashtable))
                             {
-                                if (((IAllianceEffect)cardEffect).HasAlliance(this))
-                                {
-                                    return true;
-                                }
+                                return true;
                             }
                         }
                     }
@@ -2914,14 +2915,11 @@ public class Permanent
 
                     foreach (ICardEffect cardEffect in source.EffectList(EffectTiming.OnAllyAttack))
                     {
-                        if (cardEffect is IAllianceEffect)
+                        if (cardEffect.EffectName == "Alliance")
                         {
-                            if (cardEffect.CanTrigger(null))
+                            if (cardEffect.CanTrigger(hashtable))
                             {
-                                if (((IAllianceEffect)cardEffect).HasAlliance(this))
-                                {
-                                    return true;
-                                }
+                                return true;
                             }
                         }
                     }
@@ -2931,14 +2929,11 @@ public class Permanent
                 #region Player Effects
                 foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.OnAllyAttack))
                 {
-                    if (cardEffect is IAllianceEffect)
+                    if (cardEffect.EffectName == "Alliance")
                     {
-                        if (cardEffect.CanTrigger(null))
+                        if (cardEffect.CanTrigger(hashtable))
                         {
-                            if (((IAllianceEffect)cardEffect).HasAlliance(this))
-                            {
-                                return true;
-                            }
+                            return true;
                         }
                     }
                 }