Search in sources :

Example 16 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class CelestialKirinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    if (spell != null) {
        int cmc = spell.getManaValue();
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
        return new DestroyAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) Spell(mage.game.stack.Spell) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 17 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class CephalidConstableTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
        FilterPermanent filter = new FilterPermanent("permanent" + (event.getAmount() > 1 ? "s" : "") + " damaged player control");
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        Target target = new TargetPermanent(0, event.getAmount(), filter, false);
        this.getTargets().clear();
        this.getTargets().add(target);
        return true;
    }
    return false;
}
Also used : Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 18 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class DoomForetoldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(game.getActivePlayerId());
    if (controller == null || player == null) {
        return false;
    }
    FilterPermanent filter2 = filter.copy();
    filter2.add(new ControllerIdPredicate(player.getId()));
    if (game.getBattlefield().contains(filter2, source, game, 1)) {
        TargetPermanent target = new TargetPermanent(filter2);
        target.setNotTarget(true);
        if (player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null && permanent.sacrifice(source, game)) {
                return true;
            }
        }
    }
    player.discard(1, false, false, source, game);
    player.loseLife(2, game, source, false);
    controller.drawCards(1, source, game);
    controller.gainLife(2, game, source);
    effect1.apply(game, source);
    effect2.apply(game, source);
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 19 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class EngulfTheShoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
        FilterPermanent creatureFilter = new FilterCreaturePermanent();
        creatureFilter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, islands + 1));
        Set<Card> cardsToHand = new HashSet<>();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) {
            cardsToHand.add(permanent);
        }
        controller.moveCards(cardsToHand, Zone.HAND, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ToughnessPredicate(mage.filter.predicate.mageobject.ToughnessPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 20 with FilterPermanent

use of mage.filter.FilterPermanent in project mage by magefree.

the class JolraelEmpressOfBeastsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (targetPlayer != null) {
        FilterPermanent filter = new FilterLandPermanent();
        filter.add(new ControllerIdPredicate(targetPlayer.getId()));
        game.addEffect(new BecomesCreatureAllEffect(new CreatureToken(3, 3), "lands", filter, Duration.EndOfTurn, false), source);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) BecomesCreatureAllEffect(mage.abilities.effects.common.continuous.BecomesCreatureAllEffect) CreatureToken(mage.game.permanent.token.custom.CreatureToken)

Aggregations

FilterPermanent (mage.filter.FilterPermanent)155 Permanent (mage.game.permanent.Permanent)99 Player (mage.players.Player)99 TargetPermanent (mage.target.TargetPermanent)62 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)49 UUID (java.util.UUID)41 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)30 Target (mage.target.Target)24 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)18 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)17 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)16 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)14 OneShotEffect (mage.abilities.effects.OneShotEffect)13 Card (mage.cards.Card)13 FixedTarget (mage.target.targetpointer.FixedTarget)13 FilterCard (mage.filter.FilterCard)11 FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)11 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)11 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)11 CardsImpl (mage.cards.CardsImpl)10