Search in sources :

Example 1 with FilterArtifactCard

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

the class MuzzioVisionaryArchitectEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int highCMC = 0;
    List<Permanent> controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), controller.getId(), game);
    for (Permanent permanent : controlledArtifacts) {
        if (permanent.getSpellAbility() != null) {
            int cmc = permanent.getSpellAbility().getManaCosts().manaValue();
            if (cmc > highCMC) {
                highCMC = cmc;
            }
        }
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, highCMC));
    controller.lookAtCards(source, null, cards, game);
    if (!cards.isEmpty()) {
        TargetCard target = new TargetCard(Zone.LIBRARY, new FilterArtifactCard("artifact card to put onto the battlefield"));
        if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.Benefit, cards, target, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                controller.revealCards(source, new CardsImpl(card), game);
                cards.remove(card);
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
    }
    controller.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) TargetCard(mage.target.TargetCard) FilterArtifactCard(mage.filter.common.FilterArtifactCard) TargetCard(mage.target.TargetCard) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

Example 2 with FilterArtifactCard

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

the class TezzeretTheSeekerEffect3 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int cmc = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof PayVariableLoyaltyCost) {
            cmc = ((PayVariableLoyaltyCost) cost).getAmount();
        }
    }
    FilterArtifactCard filter = new FilterArtifactCard("artifact card with mana value " + cmc + " or less");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc + 1));
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    if (controller.searchLibrary(target, source, game)) {
        Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
        if (card != null) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
        controller.shuffleLibrary(source, game);
        return true;
    }
    controller.shuffleLibrary(source, game);
    return false;
}
Also used : Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) PayVariableLoyaltyCost(mage.abilities.costs.common.PayVariableLoyaltyCost) FilterArtifactCard(mage.filter.common.FilterArtifactCard) Cost(mage.abilities.costs.Cost) PayVariableLoyaltyCost(mage.abilities.costs.common.PayVariableLoyaltyCost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

Example 3 with FilterArtifactCard

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

the class SaheelisDirectiveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
    if (!cards.isEmpty()) {
        controller.revealCards(source, cards, game);
        FilterCard filter = new FilterArtifactCard("artifact cards with mana value " + xValue + " or less to put onto the battlefield");
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
        TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
        target1.setNotTarget(true);
        controller.choose(Outcome.PutCardInPlay, cards, target1, game);
        Cards toBattlefield = new CardsImpl(target1.getTargets());
        cards.removeAll(toBattlefield);
        controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
        controller.moveCards(cards, Zone.GRAVEYARD, source, game);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCard(mage.target.TargetCard) FilterArtifactCard(mage.filter.common.FilterArtifactCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 4 with FilterArtifactCard

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

the class SequesteredStashEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterArtifactCard("artifact card from your graveyard"));
    target.setNotTarget(true);
    if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseUse(outcome, "Put an artifact card from your graveyard to library?", source, game) && controller.choose(outcome, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.LIBRARY, source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterArtifactCard(mage.filter.common.FilterArtifactCard) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

Example 5 with FilterArtifactCard

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

the class ArsenalThresherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Permanent arsenalThresher = game.getPermanentEntering(source.getSourceId());
    FilterArtifactCard filter = new FilterArtifactCard();
    filter.add(new AnotherCardPredicate());
    if (controller.chooseUse(Outcome.Benefit, "Reveal other artifacts in your hand?", source, game)) {
        Cards cards = new CardsImpl();
        if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
            TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
            if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
                for (UUID uuid : target.getTargets()) {
                    cards.add(controller.getHand().get(uuid, game));
                }
                if (arsenalThresher != null) {
                    controller.revealCards(arsenalThresher.getIdName(), cards, game);
                    // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
                    List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
                    arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source.getControllerId(), source, game, appliedEffects);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCardInHand(mage.target.common.TargetCardInHand) ArrayList(java.util.ArrayList) FilterArtifactCard(mage.filter.common.FilterArtifactCard) AnotherCardPredicate(mage.filter.predicate.mageobject.AnotherCardPredicate) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

FilterArtifactCard (mage.filter.common.FilterArtifactCard)11 Player (mage.players.Player)9 Card (mage.cards.Card)5 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)5 Permanent (mage.game.permanent.Permanent)5 FilterCard (mage.filter.FilterCard)4 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)3 UUID (java.util.UUID)2 Cards (mage.cards.Cards)2 CardsImpl (mage.cards.CardsImpl)2 FilterArtifactPermanent (mage.filter.common.FilterArtifactPermanent)2 TargetCard (mage.target.TargetCard)2 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 MageObject (mage.MageObject)1 Cost (mage.abilities.costs.Cost)1 PayVariableLoyaltyCost (mage.abilities.costs.common.PayVariableLoyaltyCost)1