Search in sources :

Example 1 with AnotherCardPredicate

use of mage.filter.predicate.mageobject.AnotherCardPredicate 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)

Example 2 with AnotherCardPredicate

use of mage.filter.predicate.mageobject.AnotherCardPredicate in project mage by magefree.

the class RelentlessDeadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.Benefit, "Do you want to pay {X} to return zombie?", source, game)) {
            int payCount = ManaUtil.playerPaysXGenericMana(true, "Relentless Dead", controller, source, game);
            // can be 0
            FilterCard filter = new FilterCard("Another target Zombie card with mana value {" + payCount + "}");
            filter.add(SubType.ZOMBIE.getPredicate());
            filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, payCount));
            filter.add(new AnotherCardPredicate());
            TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
            if (controller.chooseTarget(outcome, target, source, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) AnotherCardPredicate(mage.filter.predicate.mageobject.AnotherCardPredicate) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Aggregations

AnotherCardPredicate (mage.filter.predicate.mageobject.AnotherCardPredicate)2 Player (mage.players.Player)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 Card (mage.cards.Card)1 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 FilterCard (mage.filter.FilterCard)1 FilterArtifactCard (mage.filter.common.FilterArtifactCard)1 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)1 Permanent (mage.game.permanent.Permanent)1 TargetCardInHand (mage.target.common.TargetCardInHand)1 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)1