Search in sources :

Example 21 with TargetCardInHand

use of mage.target.common.TargetCardInHand in project mage by magefree.

the class ScentOfBrineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    return new CounterUnlessPaysEffect(new GenericManaCost(xValue)).apply(game, source);
}
Also used : CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) TargetCardInHand(mage.target.common.TargetCardInHand)

Example 22 with TargetCardInHand

use of mage.target.common.TargetCardInHand in project mage by magefree.

the class ScentOfIvyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source);
    return true;
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect)

Example 23 with TargetCardInHand

use of mage.target.common.TargetCardInHand in project mage by magefree.

the class ScentOfNightshadeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = -1 * cost.getNumberRevealedCards();
    game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source);
    return true;
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect)

Example 24 with TargetCardInHand

use of mage.target.common.TargetCardInHand in project mage by magefree.

the class ShowAndTellEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Set<Card> cardsToPutIntoPlay = new LinkedHashSet<>();
    TargetCardInHand target = new TargetCardInHand(filter);
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            if (player.chooseUse(outcome, "Put an artifact, creature, enchantment, or land card from hand onto the battlefield?", source, game)) {
                target.clearChosen();
                if (player.chooseTarget(outcome, target, source, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        cardsToPutIntoPlay.add(card);
                    }
                }
            }
        }
    }
    return controller.moveCards(cardsToPutIntoPlay, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 25 with TargetCardInHand

use of mage.target.common.TargetCardInHand in project mage by magefree.

the class AmplifyEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent sourceCreature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || sourceCreature == null) {
        return false;
    }
    FilterCreatureCard filter = new FilterCreatureCard("creatures cards to reveal");
    filter.add(new AmplifyPredicate(sourceCreature));
    // You can’t reveal this card or any other cards that are entering the battlefield at the same time as this card.
    filter.add(Predicates.not(new CardIdPredicate(source.getSourceId())));
    for (Permanent enteringPermanent : game.getPermanentsEntering().values()) {
        filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId())));
    }
    if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) <= 0) {
        return false;
    }
    if (!controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
        return false;
    }
    TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
    if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) {
        Cards cards = new CardsImpl();
        cards.addAll(target.getTargets());
        int amountCounters = cards.size() * amplifyFactor.getFactor();
        sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
        controller.revealCards(sourceCreature.getIdName(), cards, game);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) TargetCardInHand(mage.target.common.TargetCardInHand) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Aggregations

TargetCardInHand (mage.target.common.TargetCardInHand)148 Player (mage.players.Player)133 Card (mage.cards.Card)96 FilterCard (mage.filter.FilterCard)61 Permanent (mage.game.permanent.Permanent)45 CardsImpl (mage.cards.CardsImpl)41 UUID (java.util.UUID)39 Cards (mage.cards.Cards)24 Target (mage.target.Target)21 TargetCard (mage.target.TargetCard)21 MageObject (mage.MageObject)17 FixedTarget (mage.target.targetpointer.FixedTarget)14 ApprovingObject (mage.ApprovingObject)13 FilterCreatureCard (mage.filter.common.FilterCreatureCard)12 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)10 RevealTargetFromHandCost (mage.abilities.costs.common.RevealTargetFromHandCost)10 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)10 ContinuousEffect (mage.abilities.effects.ContinuousEffect)9 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)9 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)9