Search in sources :

Example 21 with FilterPermanent

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

the class JihadOpponentCondition method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    UUID chosenOpponent = (UUID) game.getState().getValue(getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(getSourceId() + "_color")));
    filter.add(TokenPredicate.FALSE);
    return game.getBattlefield().countAll(filter, chosenOpponent, game) == 0;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 22 with FilterPermanent

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

the class JihadOpponentCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID chosenOpponent = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
    filter.add(TokenPredicate.FALSE);
    return game.getBattlefield().countAll(filter, chosenOpponent, game) > 0;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 23 with FilterPermanent

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

the class LabyrinthRaptorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(permanent.getId(), game));
    if (player == null) {
        return false;
    }
    FilterPermanent filterPermanent = new FilterPermanent("creature blocking " + permanent.getIdName());
    filterPermanent.add(new BlockingAttackerIdPredicate(permanent.getId()));
    Effect effect = new SacrificeEffect(filterPermanent, 1, "");
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 24 with FilterPermanent

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

the class MoratoriumStoneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    if (card == null) {
        return false;
    }
    String cardName = card.getName();
    FilterCard filter1 = new FilterCard();
    filter1.add(new NamePredicate(cardName));
    FilterPermanent filter2 = new FilterPermanent();
    filter2.add(new NamePredicate(cardName));
    return new ExileGraveyardAllPlayersEffect(filter1).apply(game, source) && new ExileAllEffect(filter2).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) ExileGraveyardAllPlayersEffect(mage.abilities.effects.common.ExileGraveyardAllPlayersEffect) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) ExileAllEffect(mage.abilities.effects.common.ExileAllEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 25 with FilterPermanent

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

the class OKagachiVengefulKamiWatcher method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player player = game.getPlayer(event.getTargetId());
    if (player == null || !((DamagedPlayerEvent) event).isCombatDamage() || !event.getSourceId().equals(getSourceId())) {
        return false;
    }
    this.getEffects().setValue("damagedPlayer", event.getTargetId());
    FilterPermanent filter = new FilterNonlandPermanent("nonland permanent controlled by " + player.getName());
    filter.add(new ControllerIdPredicate(event.getTargetId()));
    this.getTargets().clear();
    this.addTarget(new TargetPermanent(filter));
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent)

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