Search in sources :

Example 46 with FilterCreaturePermanent

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

the class EchoingDecayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (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()));
        }
        ContinuousEffect effect = new BoostAllEffect(-2, -2, Duration.EndOfTurn, filter, false);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) 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) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 47 with FilterCreaturePermanent

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

the class ExhilaratingElocutionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
    FilterCreaturePermanent filterPermanent = new FilterCreaturePermanent();
    filterPermanent.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(permanent, game))));
    game.addEffect(new BoostControlledEffect(1, 1, Duration.EndOfTurn, filterPermanent), source);
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect) MageObjectReference(mage.MageObjectReference)

Example 48 with FilterCreaturePermanent

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

the class InstigatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (player != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(player.getId()));
        RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 49 with FilterCreaturePermanent

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

the class KillingWaveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int amount = (ManacostVariableValue.REGULAR).calculate(game, source, this);
    if (amount > 0) {
        List<Permanent> sacrifices = new LinkedList<>();
        Map<UUID, Integer> lifePaidAmounts = new HashMap<>();
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game);
                int lifePaid = 0;
                int playerLife = player.getLife();
                for (Permanent creature : creatures) {
                    String message = "Pay " + amount + " life? If you don't, " + creature.getName() + " will be sacrificed.";
                    if (playerLife - amount - lifePaid >= 0 && player.chooseUse(Outcome.Neutral, message, source, game)) {
                        game.informPlayers(player.getLogName() + " pays " + amount + " life. They will not sacrifice " + creature.getName());
                        lifePaid += amount;
                    } else {
                        game.informPlayers(player.getLogName() + " will sacrifice " + creature.getName());
                        sacrifices.add(creature);
                    }
                }
                lifePaidAmounts.put(playerId, lifePaid);
            }
        }
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            int lifePaid = lifePaidAmounts.get(playerId);
            if (lifePaid > 0) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    player.loseLife(lifePaid, game, source, false);
                }
            }
        }
        for (Permanent creature : sacrifices) {
            creature.sacrifice(source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Example 50 with FilterCreaturePermanent

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

the class KindredDominanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (controller != null && controller.choose(outcome, typeChoice, game)) {
        game.informPlayers(controller.getLogName() + " has chosen " + typeChoice.getChoice());
        FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures not of the chosen type");
        filter.add(Predicates.not(SubType.byDescription(typeChoice.getChoice()).getPredicate()));
        return new DestroyAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

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