- Improved implementation of searching for targets in SpellAbilityTargetingCards + a better comment.

This commit is contained in:
Agetian
2015-06-10 05:47:36 +00:00
parent de8ff5a0e1
commit 7a55c53eba

View File

@@ -1166,15 +1166,18 @@ public class AbilityUtils {
final Object o = root.getTriggeringObject(triggeringType); final Object o = root.getTriggeringObject(triggeringType);
if (o instanceof SpellAbility) { if (o instanceof SpellAbility) {
s = (SpellAbility) o; s = (SpellAbility) o;
// if there is no target information in SA, look in SpellAbilityTargetingCards triggering object before giving up // if there is no target information in SA but targets are listed in SpellAbilityTargeting cards, copy that
final CardCollectionView tgtList = (CardCollectionView)root.getTriggeringObject("SpellAbilityTargetingCards"); // information so it's not lost if the calling code is interested in targets of the triggered SA.
if (s.getTargets() != null && s.getTargets().getNumTargeted() == 0) { if (triggeringType.equals("SpellAbility")) {
if (tgtList != null && tgtList.size() > 0) { final CardCollectionView tgtList = (CardCollectionView)root.getTriggeringObject("SpellAbilityTargetingCards");
TargetChoices tc = new TargetChoices(); if (s.getTargets() != null && s.getTargets().getNumTargeted() == 0) {
for (Card c : tgtList) { if (tgtList != null && tgtList.size() > 0) {
tc.add(c); TargetChoices tc = new TargetChoices();
for (Card c : tgtList) {
tc.add(c);
}
s.setTargets(tc);
} }
s.setTargets(tc);
} }
} }
} }