SpellAbility: remove getTriggeringAbility, it is always root

This commit is contained in:
Hans Mackowiak
2021-02-25 10:50:19 +01:00
parent e428e66623
commit ba70477ad7
3 changed files with 12 additions and 20 deletions

View File

@@ -1487,7 +1487,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
String logic = sa.getParam("AILogic"); String logic = sa.getParam("AILogic");
if ("NeverBounceItself".equals(logic)) { if ("NeverBounceItself".equals(logic)) {
Card source = sa.getHostCard(); Card source = sa.getHostCard();
if (fetchList.contains(source) && (fetchList.size() > 1 || !sa.getTriggeringAbility().isMandatory())) { if (fetchList.contains(source) && (fetchList.size() > 1 || !sa.getRootAbility().isMandatory())) {
// For cards that should never be bounced back to hand with their own [e.g. triggered] abilities, such as guild lands. // For cards that should never be bounced back to hand with their own [e.g. triggered] abilities, such as guild lands.
fetchList.remove(source); fetchList.remove(source);
} }

View File

@@ -240,9 +240,9 @@ public class AbilityUtils {
} }
} }
} else if (defined.equals("DelayTriggerRememberedLKI")) { } else if (defined.equals("DelayTriggerRememberedLKI")) {
SpellAbility trigSa = sa.getTriggeringAbility(); SpellAbility root = sa.getRootAbility();
if (trigSa != null) { if (root != null) {
for (Object o : trigSa.getTriggerRemembered()) { for (Object o : root.getTriggerRemembered()) {
if (o instanceof Card) { if (o instanceof Card) {
cards.add((Card)o); cards.add((Card)o);
} }
@@ -251,9 +251,9 @@ public class AbilityUtils {
System.err.println("Warning: couldn't find trigger SA in the chain of SpellAbility " + sa); System.err.println("Warning: couldn't find trigger SA in the chain of SpellAbility " + sa);
} }
} else if (defined.equals("DelayTriggerRemembered")) { } else if (defined.equals("DelayTriggerRemembered")) {
SpellAbility trigSa = sa.getTriggeringAbility(); SpellAbility root = sa.getRootAbility();
if (trigSa != null) { if (root != null) {
for (Object o : trigSa.getTriggerRemembered()) { for (Object o : root.getTriggerRemembered()) {
if (o instanceof Card) { if (o instanceof Card) {
cards.addAll(addRememberedFromCardState(game, (Card)o)); cards.addAll(addRememberedFromCardState(game, (Card)o));
} }
@@ -1021,9 +1021,9 @@ public class AbilityUtils {
addPlayer(card.getRemembered(), defined, players); addPlayer(card.getRemembered(), defined, players);
} }
else if (defined.startsWith("DelayTriggerRemembered")) { else if (defined.startsWith("DelayTriggerRemembered")) {
SpellAbility trigSa = sa.getTriggeringAbility(); SpellAbility root = sa.getRootAbility();
if (trigSa != null) { if (root != null) {
addPlayer(trigSa.getTriggerRemembered(), defined, players); addPlayer(root.getTriggerRemembered(), defined, players);
} else { } else {
System.err.println("Warning: couldn't find trigger SA in the chain of SpellAbility " + sa); System.err.println("Warning: couldn't find trigger SA in the chain of SpellAbility " + sa);
} }
@@ -1696,9 +1696,9 @@ public class AbilityUtils {
return sum; return sum;
} }
if (sq[0].startsWith("TriggerRememberAmount")) { if (sq[0].startsWith("TriggerRememberAmount")) {
SpellAbility trigSa = sa.getTriggeringAbility(); SpellAbility root = sa.getRootAbility();
int count = 0; int count = 0;
for (final Object o : trigSa.getTriggerRemembered()) { for (final Object o : root.getTriggerRemembered()) {
if (o instanceof Integer) { if (o instanceof Integer) {
count += (Integer) o; count += (Integer) o;
} }

View File

@@ -671,14 +671,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
return saRoot.optionalCosts.contains(cost); return saRoot.optionalCosts.contains(cost);
} }
public SpellAbility getTriggeringAbility() {
SpellAbility sa = this;
while (sa.getParent() != null && !sa.isTrigger()) {
sa = sa.getParent();
}
return sa;
}
public Map<AbilityKey, Object> getTriggeringObjects() { public Map<AbilityKey, Object> getTriggeringObjects() {
return triggeringObjects; return triggeringObjects;
} }