Search in sources :

Example 11 with PermanentIdPredicate

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;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 12 with PermanentIdPredicate

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);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) TargetCreatureOrPlaneswalker(mage.target.common.TargetCreatureOrPlaneswalker) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 13 with PermanentIdPredicate

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;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent)

Example 14 with PermanentIdPredicate

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;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Player(mage.players.Player) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 15 with PermanentIdPredicate

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;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamageEverythingEffect(mage.abilities.effects.common.DamageEverythingEffect) MageObject(mage.MageObject) UUID(java.util.UUID)

Aggregations

PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)45 Permanent (mage.game.permanent.Permanent)38 Player (mage.players.Player)26 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)24 FilterPermanent (mage.filter.FilterPermanent)19 TargetPermanent (mage.target.TargetPermanent)19 Target (mage.target.Target)17 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)17 UUID (java.util.UUID)14 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)9 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)7 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)5 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)5 MageObject (mage.MageObject)4 Predicate (mage.filter.predicate.Predicate)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 BecomesFaceDownCreatureAllEffect (mage.abilities.effects.common.continuous.BecomesFaceDownCreatureAllEffect)3 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)3 AbilityPredicate (mage.filter.predicate.mageobject.AbilityPredicate)3 ArrayList (java.util.ArrayList)2