Search in sources :

Example 36 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class NecriteTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (super.checkTrigger(event, game)) {
        UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
        FilterPermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(defendingPlayerId));
        Target target = new TargetPermanent(filter);
        this.getTargets().clear();
        this.addTarget(target);
        return true;
    }
    return false;
}
Also used : Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 37 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class SeverTheBloodlineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (controller != null && targetPermanent != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        if (CardUtil.haveEmptyName(targetPermanent)) {
            // if no name (face down creature) only the creature itself is selected
            filter.add(new PermanentIdPredicate(targetPermanent.getId()));
        } else {
            filter.add(new NamePredicate(targetPermanent.getName()));
        }
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true);
        }
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Example 38 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class ShamanOfForgottenWaysEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterPermanent filter = new FilterCreaturePermanent();
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                int numberCreatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size();
                player.setLife(numberCreatures, game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) UUID(java.util.UUID)

Example 39 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class SkirkCommandoTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (super.checkTrigger(event, game)) {
        Player player = game.getPlayer(event.getPlayerId());
        if (player != null) {
            getTargets().clear();
            FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player " + player.getName() + " controls");
            filter.add(new ControllerIdPredicate(event.getPlayerId()));
            addTarget(new TargetCreaturePermanent(filter));
            return true;
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 40 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class TopplegeistAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
        Player opponent = game.getPlayer(event.getPlayerId());
        if (opponent != null) {
            FilterCreaturePermanent FILTER = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
            FILTER.add(new ControllerIdPredicate(opponent.getId()));
            this.getTargets().clear();
            this.addTarget(new TargetCreaturePermanent(FILTER));
            return true;
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Aggregations

FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)187 Player (mage.players.Player)125 Permanent (mage.game.permanent.Permanent)108 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)83 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)67 UUID (java.util.UUID)55 TargetPermanent (mage.target.TargetPermanent)32 Target (mage.target.Target)31 FilterPermanent (mage.filter.FilterPermanent)27 FixedTarget (mage.target.targetpointer.FixedTarget)25 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)23 ContinuousEffect (mage.abilities.effects.ContinuousEffect)22 MageObject (mage.MageObject)16 PowerPredicate (mage.filter.predicate.mageobject.PowerPredicate)16 OneShotEffect (mage.abilities.effects.OneShotEffect)14 Effect (mage.abilities.effects.Effect)13 Choice (mage.choices.Choice)13 TargetPlayer (mage.target.TargetPlayer)13 Card (mage.cards.Card)12 ChoiceCreatureType (mage.choices.ChoiceCreatureType)12