Search in sources :

Example 81 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class DualNatureExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (creature != null) {
        FilterPermanent filter = new FilterPermanent();
        filter.add(TokenPredicate.TRUE);
        filter.add(new NamePredicate(creature.getName()));
        new ExileAllEffect(filter).apply(game, source);
        return true;
    }
    return false;
}
Also used : NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) ExileAllEffect(mage.abilities.effects.common.ExileAllEffect) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent)

Example 82 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class FarrelsMantleDamageEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent aura = getSourcePermanentOrLKI(game);
    if (aura == null || !event.getTargetId().equals(aura.getAttachedTo()) || game.getPermanent(aura.getAttachedTo()) == null) {
        return false;
    }
    MageObjectReference mor = new MageObjectReference(event.getTargetId(), game);
    FilterPermanent filter = new FilterCreaturePermanent();
    filter.add(Predicates.not(new MageObjectReferencePredicate(mor)));
    TargetPermanent target = new TargetPermanent(filter);
    target.setTargetController(game.getControllerId(event.getTargetId()));
    this.getTargets().clear();
    this.addTarget(target);
    this.getEffects().clear();
    this.addEffect(new FarrelsMantleEffect(mor));
    return true;
}
Also used : 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) TargetPermanent(mage.target.TargetPermanent) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) TargetPermanent(mage.target.TargetPermanent) MageObjectReference(mage.MageObjectReference)

Example 83 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class FlamesOfTheRazeBoarEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    permanent.damage(4, source.getSourceId(), source, game);
    if (!FerociousCondition.instance.apply(game, source)) {
        return true;
    }
    FilterPermanent filter = new FilterCreaturePermanent();
    filter.add(new ControllerIdPredicate(permanent.getControllerId()));
    filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
    return new DamageAllEffect(2, filter).apply(game, source);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect)

Example 84 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class HarshMercyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        Set<String> chosenTypes = new HashSet<>();
        PlayerIteration: for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            Choice typeChoice = new ChoiceCreatureType(sourceObject);
            if (player != null && !player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
                continue PlayerIteration;
            }
            String chosenType = typeChoice.getChoice();
            if (chosenType != null) {
                game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType);
                chosenTypes.add(chosenType);
            }
        }
        FilterPermanent filter = new FilterCreaturePermanent("creatures");
        for (String type : chosenTypes) {
            filter.add(Predicates.not(SubType.byDescription(type).getPredicate()));
        }
        return new DestroyAllEffect(filter, true).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) UUID(java.util.UUID) HashSet(java.util.HashSet) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 85 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class LatullasOrdersTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
    if (event.getSourceId().equals(enchantment.getAttachedTo()) && ((DamagedPlayerEvent) event).isCombatDamage()) {
        Player player = game.getPlayer(event.getTargetId());
        if (player != null) {
            FilterPermanent filter = new FilterPermanent("an artifact controlled by " + player.getLogName());
            filter.add(CardType.ARTIFACT.getPredicate());
            filter.add(new ControllerIdPredicate(event.getTargetId()));
            this.getTargets().clear();
            this.addTarget(new TargetPermanent(filter));
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Aggregations

FilterPermanent (mage.filter.FilterPermanent)155 Permanent (mage.game.permanent.Permanent)99 Player (mage.players.Player)99 TargetPermanent (mage.target.TargetPermanent)62 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)49 UUID (java.util.UUID)41 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)30 Target (mage.target.Target)24 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)18 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)17 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)16 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)14 OneShotEffect (mage.abilities.effects.OneShotEffect)13 Card (mage.cards.Card)13 FixedTarget (mage.target.targetpointer.FixedTarget)13 FilterCard (mage.filter.FilterCard)11 FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)11 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)11 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)11 CardsImpl (mage.cards.CardsImpl)10