Search in sources :

Example 6 with FilterArtifactPermanent

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

the class GoblinVandalTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent sourcePermanent = game.getPermanent(getSourceId());
    if (sourcePermanent.isAttacking()) {
        for (CombatGroup combatGroup : game.getCombat().getGroups()) {
            if (combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(getSourceId())) {
                UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
                FilterPermanent filter = new FilterArtifactPermanent();
                filter.add(new ControllerIdPredicate(defendingPlayerId));
                Target target = new TargetPermanent(filter);
                this.addTarget(target);
                return true;
            }
        }
    }
    return false;
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) CombatGroup(mage.game.combat.CombatGroup)

Example 7 with FilterArtifactPermanent

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

the class HammerMageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterArtifactPermanent filter = new FilterArtifactPermanent();
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
    for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
        permanent.destroy(source, game, false);
    }
    return true;
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent)

Example 8 with FilterArtifactPermanent

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

the class BludgeonBrawlGainAbilityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterArtifactPermanent filter = new FilterArtifactPermanent("noncreature, non-Equipment artifact");
    filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
    filter.add(Predicates.not(SubType.EQUIPMENT.getPredicate()));
    Cards affectedPermanents = new CardsImpl();
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
    for (Permanent permanent : permanents) {
        if (permanent != null) {
            permanent.addSubType(game, SubType.EQUIPMENT);
            affectedPermanents.add(permanent.getId());
        }
    }
    game.getState().setValue(source.getSourceId() + "BludgeonBrawlAffectedPermanents", affectedPermanents);
    return true;
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 9 with FilterArtifactPermanent

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

the class ScrapMasteryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Map<UUID, Set<Card>> exiledCards = new HashMap<>();
        // exile artifacts from graveyard
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                Set<Card> cards = player.getGraveyard().getCards(new FilterArtifactCard(), game);
                controller.moveCards(cards, Zone.EXILED, source, game);
                exiledCards.put(player.getId(), cards);
            }
        }
        // sacrifice all artifacts
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), playerId, game)) {
                    permanent.sacrifice(source, game);
                }
            }
        }
        // puts all cards they exiled this way onto the battlefield
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                player.moveCards(exiledCards.get(playerId), Zone.BATTLEFIELD, source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Set(java.util.Set) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) HashMap(java.util.HashMap) FilterArtifactCard(mage.filter.common.FilterArtifactCard) UUID(java.util.UUID) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

Example 10 with FilterArtifactPermanent

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

the class EmissaryOfDespairCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    if (effect.getTargetPointer().getFirst(game, sourceAbility) == null) {
        return 0;
    }
    FilterArtifactPermanent filter = new FilterArtifactPermanent();
    filter.add(new ControllerIdPredicate(effect.getTargetPointer().getFirst(game, sourceAbility)));
    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