use of mage.filter.predicate.permanent.PermanentIdPredicate in project mage by magefree.
the class EchoingDecayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (CardUtil.haveEmptyName(targetPermanent)) {
// if no name (face down creature) only the creature itself is selected
filter.add(new PermanentIdPredicate(targetPermanent.getId()));
} else {
filter.add(new NamePredicate(targetPermanent.getName()));
}
ContinuousEffect effect = new BoostAllEffect(-2, -2, Duration.EndOfTurn, filter, false);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.filter.predicate.permanent.PermanentIdPredicate in project mage by magefree.
the class DeadlyVanityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetPermanent target = new TargetCreatureOrPlaneswalker();
target.setNotTarget(true);
controller.choose(outcome, target, source.getId(), game);
FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent();
UUID targetId = target.getFirstTarget();
if (targetId != null) {
filter.add(Predicates.not(new PermanentIdPredicate(targetId)));
}
return new DestroyAllEffect(filter).apply(game, source);
}
use of mage.filter.predicate.permanent.PermanentIdPredicate in project mage by magefree.
the class DestroyAllNamedPermanentsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetPermanent == null) {
return false;
}
FilterPermanent filter = new FilterPermanent();
if (CardUtil.haveEmptyName(targetPermanent)) {
// if no name (face down creature) only the creature itself is selected
filter.add(new PermanentIdPredicate(targetPermanent.getId()));
} else {
filter.add(new NamePredicate(targetPermanent.getName()));
}
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
perm.destroy(source, game, false);
}
return true;
}
use of mage.filter.predicate.permanent.PermanentIdPredicate in project mage by magefree.
the class UnnaturalHungerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanent(source.getSourceId());
if (aura != null) {
Permanent attachedTo = game.getPermanent(aura.getAttachedTo());
if (attachedTo != null) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
// not attached permanent
filter.add(Predicates.not(new PermanentIdPredicate(aura.getAttachedTo())));
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(filter));
Player enchantedCreatureController = game.getPlayer(attachedTo.getControllerId());
if (enchantedCreatureController != null && cost.canPay(source, source, enchantedCreatureController.getId(), game) && enchantedCreatureController.chooseUse(outcome, "Sacrifice another creature to prevent " + attachedTo.getPower().getValue() + " damage?", source, game) && cost.pay(source, game, source, enchantedCreatureController.getId(), true)) {
}
if (enchantedCreatureController != null && !cost.isPaid()) {
enchantedCreatureController.damage(attachedTo.getPower().getValue(), source.getSourceId(), source, game);
}
return true;
}
}
return false;
}
use of mage.filter.predicate.permanent.PermanentIdPredicate in project mage by magefree.
the class ArcbondEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int damage = (Integer) this.getValue("damage");
UUID sourceId = (UUID) this.getValue("sourceId");
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && damage > 0 && sourceId != null) {
Permanent targetObject = game.getPermanentOrLKIBattlefield(sourceId);
if (targetObject != null) {
game.informPlayers(sourceObject.getLogName() + ": " + targetObject.getLogName() + " deals " + damage + " damage to each other creature and each player");
}
FilterPermanent filter = new FilterCreaturePermanent("each other creature");
filter.add(Predicates.not(new PermanentIdPredicate(sourceId)));
return new DamageEverythingEffect(StaticValue.get(damage), filter, sourceId).apply(game, source);
}
return false;
}
Aggregations