Search in sources :

Example 11 with FilterArtifactPermanent

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

the class StrategySchmategyffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    int numTimesToDo = 1;
    if (controller != null) {
        // 6 - Repeat this process two more times
        while (numTimesToDo > 0) {
            // ai must try to choose min
            int amount = controller.rollDice(Outcome.Detriment, source, game, 6);
            numTimesToDo--;
            if (amount == 2) {
                List<Permanent> artifactPermanents = game.getBattlefield().getActivePermanents(new FilterArtifactPermanent(), controller.getId(), game);
                for (Permanent permanent : artifactPermanents) {
                    permanent.destroy(source, game, false);
                }
            } else if (amount == 3) {
                List<Permanent> landPermanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, controller.getId(), game);
                for (Permanent permanent : landPermanents) {
                    permanent.destroy(source, game, false);
                }
            } else if (amount == 4) {
                new DamageEverythingEffect(3, new FilterCreaturePermanent()).apply(game, source);
            } else if (amount == 5) {
                new DiscardHandAllEffect().apply(game, source);
                new DrawCardAllEffect(7).apply(game, source);
            } else if (amount == 6) {
                numTimesToDo += 2;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DrawCardAllEffect(mage.abilities.effects.common.DrawCardAllEffect) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) DamageEverythingEffect(mage.abilities.effects.common.DamageEverythingEffect) List(java.util.List) DiscardHandAllEffect(mage.abilities.effects.common.discard.DiscardHandAllEffect)

Example 12 with FilterArtifactPermanent

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

the class TezzeretTheSeekerEffect3 method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game);
    for (Permanent permanent : permanents) {
        if (permanent != null) {
            switch(layer) {
                case TypeChangingEffects_4:
                    if (sublayer == SubLayer.NA) {
                        if (!permanent.isArtifact(game)) {
                            permanent.addCardType(game, CardType.ARTIFACT);
                        }
                        if (!permanent.isCreature(game)) {
                            permanent.addCardType(game, CardType.CREATURE);
                        }
                    }
                    break;
                case PTChangingEffects_7:
                    if (sublayer == SubLayer.SetPT_7b) {
                        permanent.getPower().setValue(5);
                        permanent.getToughness().setValue(5);
                    }
            }
        }
    }
    return true;
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) TargetArtifactPermanent(mage.target.common.TargetArtifactPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent)

Example 13 with FilterArtifactPermanent

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

the class YawgmothDemonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int artifacts = game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game);
        boolean artifactSacrificed = false;
        if (artifacts > 0 && controller.chooseUse(outcome, "Sacrifice an artifact?", source, game)) {
            if (new SacrificeControllerEffect(new FilterArtifactPermanent(), 1, "").apply(game, source)) {
                artifactSacrificed = true;
            }
        }
        if (!artifactSacrificed) {
            Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
            if (sourceObject != null) {
                sourceObject.tap(source, game);
                controller.damage(2, source.getSourceId(), source, game);
            }
        }
        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) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect)

Example 14 with FilterArtifactPermanent

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

the class HurkylsRecallReturnToHandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (targetPointer.getFirst(game, source) != null) {
        FilterPermanent filter = new FilterArtifactPermanent();
        filter.add(new OwnerIdPredicate(targetPointer.getFirst(game, source)));
        return new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) FilterPermanent(mage.filter.FilterPermanent) ReturnToHandFromBattlefieldAllEffect(mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect)

Example 15 with FilterArtifactPermanent

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

the class WardOfBonesEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
        final Card card = game.getCard(event.getSourceId());
        final Player opponent = game.getPlayer(event.getPlayerId());
        if (card == null || opponent == null) {
            return false;
        }
        if (card.isCreature(game) && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, opponent.getId(), game) > game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
            return true;
        }
        if (card.isArtifact(game) && game.getBattlefield().countAll(new FilterArtifactPermanent(), opponent.getId(), game) > game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game)) {
            return true;
        }
        if (card.isEnchantment(game) && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, opponent.getId(), game) > game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), game)) {
            return true;
        }
        final int yourLands = game.getBattlefield().countAll(new FilterLandPermanent(), source.getControllerId(), game);
        if (card.isLand(game) && game.getBattlefield().countAll(new FilterLandPermanent(), opponent.getId(), game) > yourLands) {
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Card(mage.cards.Card)

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