Search in sources :

Example 66 with FilterPermanent

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

the class BladegriffPrototypeAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player player = game.getPlayer(getControllerId());
    if (player == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterPermanent filter = new FilterNonlandPermanent("nonland permanent controlled by an opponent of " + player.getName());
    filter.add(Predicates.or(game.getOpponents(getControllerId()).stream().map(ControllerIdPredicate::new).collect(Collectors.toSet())));
    TargetPermanent target = new TargetPermanent(filter);
    target.setTargetController(event.getPlayerId());
    this.getTargets().clear();
    this.addTarget(target);
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) TargetPermanent(mage.target.TargetPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent)

Example 67 with FilterPermanent

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

the class KarrthusControlEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent filter = new FilterPermanent();
    filter.add(SubType.DRAGON.getPredicate());
    List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter, game);
    for (Permanent dragon : dragons) {
        ContinuousEffect effect = new KarrthusControlEffect(source.getControllerId());
        effect.setTargetPointer(new FixedTarget(dragon.getId(), game));
        game.addEffect(effect, source);
    }
    for (Permanent dragon : dragons) {
        dragon.untap(game);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 68 with FilterPermanent

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

the class NihiloorLoseLifeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null) {
            continue;
        }
        TargetPermanent target = new TargetPermanent(0, 1, filter, true);
        target.withChooseHint("tapping a creature controlled by " + opponent.getName());
        controller.choose(outcome, target, source.getControllerId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent == null || !permanent.tap(source, game)) {
            continue;
        }
        FilterPermanent filter2 = new FilterPermanent("creature controlled by " + opponent.getName() + " with power " + permanent.getPower().getValue() + " or less");
        filter2.add(new NihiloorPredicate(permanent, playerId));
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new GainControlTargetEffect(Duration.Custom, true), false, "gain control of target creature that player controls with " + "power less than or equal to the tapped creature's power for as long as you control {this}");
        ability.addTarget(new TargetPermanent(filter2));
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 69 with FilterPermanent

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

the class NightmareUnmakingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    FilterPermanent filter = new FilterCreaturePermanent();
    filter.add(new PowerPredicate(comparisonType, player.getHand().size()));
    return new ExileAllEffect(filter).apply(game, source);
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ExileAllEffect(mage.abilities.effects.common.ExileAllEffect) PowerPredicate(mage.filter.predicate.mageobject.PowerPredicate)

Example 70 with FilterPermanent

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

the class OranRiefTheVastwoodEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent filter = new FilterPermanent();
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new ColorPredicate(ObjectColor.GREEN));
    for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
        if (permanent.getTurnsOnBattlefield() == 0) {
            permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
        }
    }
    return true;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent)

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