use of mage.filter.common.FilterCreatureOrPlaneswalkerPermanent 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);
}
use of mage.filter.common.FilterCreatureOrPlaneswalkerPermanent in project mage by magefree.
the class SingleCombatRestrictionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filterSac = new FilterCreatureOrPlaneswalkerPermanent();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (player.choose(outcome, target, source.getSourceId(), game)) {
filterSac.add(Predicates.not(new PermanentIdPredicate(target.getFirstTarget())));
}
}
for (Permanent permanent : game.getBattlefield().getActivePermanents(filterSac, source.getControllerId(), game)) {
permanent.sacrifice(source, game);
}
return true;
}
use of mage.filter.common.FilterCreatureOrPlaneswalkerPermanent in project mage by magefree.
the class BlindZealotTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker" + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false, "destroy target creature or planeswalker that player controls");
this.getEffects().clear();
this.addEffect(new DoWhenCostPaid(ability, new DiscardTargetCost(new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE)), "Discard a creature card?"));
return true;
}
use of mage.filter.common.FilterCreatureOrPlaneswalkerPermanent in project mage by magefree.
the class ChandrasIncineratorTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
if (dEvent.isCombatDamage() || !game.getOpponents(event.getTargetId()).contains(getControllerId()) || !game.getControllerId(event.getSourceId()).equals(getControllerId())) {
return false;
}
this.getEffects().clear();
this.addEffect(new DamageTargetEffect(event.getAmount()));
FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker");
filter.add(new ControllerIdPredicate(event.getTargetId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
Aggregations