From b04959fa896a8d6e8597aaea3fac88f565c3ced7 Mon Sep 17 00:00:00 2001 From: Sol Date: Sun, 21 Apr 2013 17:32:33 +0000 Subject: [PATCH] - Compare Targets of SubAbilities to the StackInstance SubAbilities for full Targeting confirmation (Bugfix Jitte multi-activation) --- .../SpellAbilityStackInstance.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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; } }