Search in sources :

Example 51 with TargetCardInHand

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

the class CinderSeerEffect 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 DamageTargetEffect(xValue).apply(game, source);
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 52 with TargetCardInHand

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

the class ConchHornEffect method putOnLibrary.

private boolean putOnLibrary(Player player, Ability source, Game game) {
    TargetCardInHand target = new TargetCardInHand();
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        player.chooseTarget(Outcome.ReturnToHand, target, source, game);
        Card card = player.getHand().get(target.getFirstTarget(), game);
        if (card != null) {
            return player.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false);
        }
    }
    return false;
}
Also used : TargetCardInHand(mage.target.common.TargetCardInHand) Card(mage.cards.Card)

Example 53 with TargetCardInHand

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

the class DreamCacheEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.drawCards(3, source, game);
        boolean putOnTop = controller.chooseUse(Outcome.Neutral, "Put cards on top?", source, game);
        TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard());
        controller.chooseTarget(Outcome.Detriment, target, source, game);
        Cards cardsToLibrary = new CardsImpl(target.getTargets());
        if (!cardsToLibrary.isEmpty()) {
            if (putOnTop) {
                controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
            } else {
                controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 54 with TargetCardInHand

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

the class FoldIntoAetherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID targetId = getTargetPointer().getFirst(game, source);
    StackObject stackObject = game.getStack().getStackObject(targetId);
    Player spellController = null;
    if (stackObject != null) {
        spellController = game.getPlayer(stackObject.getControllerId());
    }
    if (game.getStack().counter(targetId, source, game)) {
        TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE);
        if (spellController != null && target.canChoose(source.getSourceId(), spellController.getId(), game) && spellController.chooseUse(Outcome.Neutral, "Put a creature card from your hand in play?", source, game) && spellController.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                spellController.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) StackObject(mage.game.stack.StackObject) UUID(java.util.UUID) Card(mage.cards.Card)

Example 55 with TargetCardInHand

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

the class IlhargTheRazeBoarEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_CREATURE);
    if (!player.choose(outcome, player.getHand(), target, game)) {
        return false;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    game.getCombat().addAttackingCreature(permanent.getId(), game);
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("return " + permanent.getName() + " to its owner's hand");
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

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