Search in sources :

Example 86 with TargetCardInHand

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

the class ThroughTheBreachEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
            TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE);
            if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                            effect.setTargetPointer(new FixedTarget(permanent, game));
                            game.addEffect(effect, source);
                            SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
                            sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
                            game.addDelayedTriggeredAbility(delayedAbility, source);
                            return true;
                        }
                    }
                }
                return false;
            }
        }
        return true;
    }
    return false;
}
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) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Card(mage.cards.Card)

Example 87 with TargetCardInHand

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

the class ValakutAwakeningEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard targetCard = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_CARDS);
    player.choose(outcome, player.getHand(), targetCard, game);
    Cards cards = new CardsImpl(targetCard.getTargets());
    player.putCardsOnBottomOfLibrary(cards, game, source, true);
    player.drawCards(cards.size() + 1, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard)

Example 88 with TargetCardInHand

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

the class WildfireEternalCastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterCard filter = new FilterInstantOrSorceryCard();
        int cardsToCast = controller.getHand().count(filter, source.getControllerId(), source.getSourceId(), game);
        if (cardsToCast > 0 && controller.chooseUse(outcome, "Cast an instant or sorcery card from your " + "hand without paying its mana cost?", source, game)) {
            TargetCardInHand target = new TargetCardInHand(filter);
            controller.chooseTarget(outcome, target, source, game);
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) TargetCardInHand(mage.target.common.TargetCardInHand) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) FilterCard(mage.filter.FilterCard) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Card(mage.cards.Card)

Example 89 with TargetCardInHand

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

the class ExileCardsFromHandAdjuster method adjustCosts.

@Override
public void adjustCosts(Ability ability, Game game) {
    if (game.inCheckPlayableState()) {
        return;
    }
    Player player = game.getPlayer(ability.getControllerId());
    if (player == null) {
        return;
    }
    int cardCount = player.getHand().count(filter, game);
    int toExile = cardCount > 0 ? player.getAmount(0, cardCount, "Choose how many " + filter.getMessage() + " to exile", game) : 0;
    if (toExile > 0) {
        ability.addCost(new ExileFromHandCost(new TargetCardInHand(toExile, filter)));
        CardUtil.reduceCost(ability, 2 * toExile);
    }
}
Also used : Player(mage.players.Player) ExileFromHandCost(mage.abilities.costs.common.ExileFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand)

Example 90 with TargetCardInHand

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

the class PutCardFromHandOnTopOfLibraryCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    TargetCardInHand targetCardInHand = new TargetCardInHand();
    targetCardInHand.setRequired(false);
    Card card;
    if (targetCardInHand.canChoose(source.getSourceId(), controllerId, game) && controller.choose(Outcome.PreventDamage, targetCardInHand, source.getSourceId(), game)) {
        card = game.getCard(targetCardInHand.getFirstTarget());
        paid = card != null && controller.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, true);
    }
    return paid;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) 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