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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations