diff --git a/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java b/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java index 7a4ec43cd8a..68aa97cc2ac 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java +++ b/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java @@ -257,6 +257,14 @@ public class SpellAbilityStackInstance { return this.ability.isOptionalTrigger(); } + public final SpellAbilityStackInstance getSubInstace() { + return this.subInstace; + } + + public final TargetChoices getTargetChoices() { + return this.tc; + } + public void updateTarget(Target target) { if (target != null) { this.tc = target.getTargetChoices(); @@ -268,7 +276,23 @@ public class SpellAbilityStackInstance { public boolean compareToSpellAbility(SpellAbility sa) { // Compare my target choices to the SA passed in // TODO? Compare other data points in the SI to the passed SpellAbility for confirmation - TargetChoices choices = sa.getTarget() != null ? sa.getTarget().getTargetChoices() : null; - return (sa.equals(this.ability) && (choices == null || choices.equals(this.tc))); + SpellAbility compare = sa; + SpellAbilityStackInstance sub = this; + + if (!compare.equals(sub.ability)){ + return false; + } + + while (compare != null && sub != null) { + TargetChoices choices = compare.getTarget() != null ? compare.getTarget().getTargetChoices() : null; + + if (choices != null && !choices.equals(sub.getTargetChoices())) { + return false; + } + compare = compare.getSubAbility(); + sub = sub.getSubInstace(); + } + + return true; } }