use of mage.util.TargetAddress in project mage by magefree.
the class MoveTargetAuraEffect method apply.
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
Permanent potentialAttachment = input.getObject();
for (TargetAddress addr : TargetAddress.walk(aura)) {
Target target = addr.getTarget(aura);
Filter filter = target.getFilter();
return filter.match(potentialAttachment, game);
}
return false;
}
use of mage.util.TargetAddress in project mage by magefree.
the class InkTreaderNephilimEffect method checkInterveningIfClause.
@Override
public boolean checkInterveningIfClause(Game game) {
Spell spell = (Spell) getEffects().get(0).getValue("triggeringSpell");
if (spell == null) {
return false;
}
boolean flag = false;
for (TargetAddress addr : TargetAddress.walk(spell)) {
Target targetInstance = addr.getTarget(spell);
for (UUID target : targetInstance.getTargets()) {
if (target == null) {
continue;
}
Permanent permanent = game.getPermanent(target);
if (permanent == null || !permanent.getId().equals(getSourceId())) {
return false;
}
if (getSourceObjectZoneChangeCounter() != 0 && getSourceObjectZoneChangeCounter() != permanent.getZoneChangeCounter(game)) {
return false;
}
flag = true;
}
}
return flag;
}
use of mage.util.TargetAddress in project mage by magefree.
the class MirrorwingDragonCopySpellEffect method checkSpell.
private boolean checkSpell(Spell spell, Game game) {
if (spell == null || !spell.isInstantOrSorcery(game)) {
return false;
}
boolean noTargets = true;
for (TargetAddress addr : TargetAddress.walk(spell)) {
if (addr == null) {
continue;
}
noTargets = false;
Target targetInstance = addr.getTarget(spell);
if (targetInstance == null) {
continue;
}
for (UUID target : targetInstance.getTargets()) {
if (target == null) {
continue;
}
Permanent permanent = game.getPermanent(target);
if (permanent == null || !permanent.getId().equals(getSourceId())) {
return false;
}
}
}
if (noTargets) {
return false;
}
getEffects().setValue("triggeringSpell", spell);
return true;
}
use of mage.util.TargetAddress in project mage by magefree.
the class ZadaHedronGrinderCopySpellEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(event.getPlayerId())) {
return false;
}
Spell spell = game.getSpell(event.getTargetId());
if (spell == null || !spell.isInstantOrSorcery(game)) {
return false;
}
boolean noTargets = true;
for (TargetAddress addr : TargetAddress.walk(spell)) {
if (addr == null) {
continue;
}
noTargets = false;
Target targetInstance = addr.getTarget(spell);
if (targetInstance == null) {
continue;
}
for (UUID target : targetInstance.getTargets()) {
if (target == null) {
continue;
}
Permanent permanent = game.getPermanent(target);
if (permanent == null || !permanent.getId().equals(getSourceId())) {
return false;
}
}
}
if (noTargets) {
return false;
}
getEffects().setValue("triggeringSpell", spell);
return true;
}
use of mage.util.TargetAddress in project mage by magefree.
the class SpellWithOnlySingleTargetPredicate method apply.
@Override
public boolean apply(ObjectSourcePlayer<Spell> input, Game game) {
Spell spell = input.getObject();
if (spell == null) {
return false;
}
UUID singleTarget = null;
for (TargetAddress addr : TargetAddress.walk(spell)) {
Target targetInstance = addr.getTarget(spell);
for (UUID targetId : targetInstance.getTargets()) {
if (singleTarget == null) {
singleTarget = targetId;
} else if (!singleTarget.equals(targetId)) {
return false;
}
}
}
return singleTarget != null;
}
Aggregations