Search in sources :

Example 16 with FilterArtifactPermanent

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

the class SeedsOfInnocenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (Permanent artifact : game.getState().getBattlefield().getActivePermanents(new FilterArtifactPermanent(), controller.getId(), game)) {
            Player artifactController = game.getPlayer(artifact.getControllerId());
            int cmc = artifact.getManaValue();
            if (artifact.destroy(source, game, true)) {
                if (artifactController != null) {
                    artifactController.gainLife(cmc, game, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent)

Example 17 with FilterArtifactPermanent

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

the class BlinkmothUrnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    FilterArtifactPermanent filter = new FilterArtifactPermanent("artifacts you control");
    filter.add(new ControllerIdPredicate(game.getActivePlayerId()));
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (player != null && sourcePermanent != null && !sourcePermanent.isTapped()) {
        player.getManaPool().addMana(Mana.ColorlessMana(game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).size()), game, source, false);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 18 with FilterArtifactPermanent

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

the class BurdenOfGreedCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    if (sourceAbility.getFirstTarget() == null) {
        return 0;
    }
    FilterArtifactPermanent filter = new FilterArtifactPermanent();
    filter.add(TappedPredicate.TAPPED);
    filter.add(new ControllerIdPredicate(sourceAbility.getFirstTarget()));
    return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Aggregations

FilterArtifactPermanent (mage.filter.common.FilterArtifactPermanent)18 Permanent (mage.game.permanent.Permanent)12 Player (mage.players.Player)10 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)6 TargetPermanent (mage.target.TargetPermanent)4 UUID (java.util.UUID)3 HashMap (java.util.HashMap)2 Card (mage.cards.Card)2 FilterPermanent (mage.filter.FilterPermanent)2 FilterArtifactCard (mage.filter.common.FilterArtifactCard)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 Target (mage.target.Target)2 TargetArtifactPermanent (mage.target.common.TargetArtifactPermanent)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 DamageEverythingEffect (mage.abilities.effects.common.DamageEverythingEffect)1 DrawCardAllEffect (mage.abilities.effects.common.DrawCardAllEffect)1 ReturnToHandFromBattlefieldAllEffect (mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect)1 SacrificeControllerEffect (mage.abilities.effects.common.SacrificeControllerEffect)1