Search in sources :

Example 1 with FilterCreatureOrPlaneswalkerPermanent

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);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) TargetCreatureOrPlaneswalker(mage.target.common.TargetCreatureOrPlaneswalker) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 2 with FilterCreatureOrPlaneswalkerPermanent

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;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

Example 3 with FilterCreatureOrPlaneswalkerPermanent

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;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

Example 4 with FilterCreatureOrPlaneswalkerPermanent

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;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) TargetPermanent(mage.target.TargetPermanent) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

Aggregations

FilterPermanent (mage.filter.FilterPermanent)4 FilterCreatureOrPlaneswalkerPermanent (mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)4 Player (mage.players.Player)3 TargetPermanent (mage.target.TargetPermanent)3 UUID (java.util.UUID)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)2 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)1 DiscardTargetCost (mage.abilities.costs.common.DiscardTargetCost)1 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)1 DestroyTargetEffect (mage.abilities.effects.common.DestroyTargetEffect)1 DoWhenCostPaid (mage.abilities.effects.common.DoWhenCostPaid)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1 DamagedEvent (mage.game.events.DamagedEvent)1 DamagedPlayerEvent (mage.game.events.DamagedPlayerEvent)1 Permanent (mage.game.permanent.Permanent)1 Target (mage.target.Target)1 TargetCardInHand (mage.target.common.TargetCardInHand)1 TargetCreatureOrPlaneswalker (mage.target.common.TargetCreatureOrPlaneswalker)1