use of mage.util.TargetAddress in project mage by magefree.
the class PrecursorGolemCopySpellEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell == null || !spell.isInstantOrSorcery(game)) {
return false;
}
UUID targetGolem = null;
for (TargetAddress addr : TargetAddress.walk(spell)) {
Target targetInstance = addr.getTarget(spell);
for (UUID target : targetInstance.getTargets()) {
Permanent permanent = game.getPermanent(target);
if (permanent == null || !permanent.hasSubtype(SubType.GOLEM, game)) {
return false;
}
if (targetGolem == null) {
targetGolem = target;
} else // If a spell has multiple targets, but it's targeting the same Golem with all of them, Precursor Golem's last ability will trigger
{
if (!targetGolem.equals(target)) {
return false;
}
}
}
}
if (targetGolem == null) {
return false;
}
getEffects().setValue("triggeringSpell", spell);
getEffects().setValue("targetedGolem", targetGolem);
return true;
}
Aggregations