Search in sources :

Example 66 with TargetCardInHand

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

the class PutCardFromHandOnTopOfLibrary method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        TargetCardInHand target = new TargetCardInHand();
        controller.chooseTarget(Outcome.ReturnToHand, target, ability, game);
        Card card = controller.getHand().get(target.getFirstTarget(), game);
        if (card != null) {
            controller.putCardsOnTopOfLibrary(new CardsImpl(card), game, ability, false);
            paid = true;
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 67 with TargetCardInHand

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

the class MishraArtificerProdigyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterCard filter = new FilterCard("card named " + this.cardName);
        filter.add(new NamePredicate(cardName));
        Card card = null;
        // Graveyard
        if (controller.chooseUse(Outcome.Neutral, "Search your graveyard?", source, game)) {
            // You can't fail to find the card in your graveyard because it's not hidden
            TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter);
            if (controller.choose(Outcome.PutCardInPlay, controller.getGraveyard(), target, game)) {
                card = game.getCard(target.getFirstTarget());
            }
        }
        // Hand
        if (card == null && controller.chooseUse(Outcome.Neutral, "Search your hand?", source, game)) {
            TargetCardInHand target = new TargetCardInHand(0, 1, filter);
            if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) {
                card = game.getCard(target.getFirstTarget());
            }
        }
        // Library
        if (card == null && controller.chooseUse(Outcome.Neutral, "Search your library?", source, game)) {
            TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
            if (controller.searchLibrary(target, source, game)) {
                card = game.getCard(target.getFirstTarget());
            }
            controller.shuffleLibrary(source, game);
        }
        // Put on battlefield
        if (card != null) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 68 with TargetCardInHand

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

the class MinionOfTheMightyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    TargetCardInHand target = new TargetCardInHand(filter);
    if (controller == null) {
        return false;
    }
    target.choose(outcome, controller.getId(), source.getSourceId(), game);
    Card card = controller.getHand().get(target.getFirstTarget(), game);
    if (card == null) {
        return false;
    }
    controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent != null) {
        game.getCombat().addAttackingCreature(permanent.getId(), game);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCardInHand(mage.target.common.TargetCardInHand) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 69 with TargetCardInHand

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

the class NightshadeAssassinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    FilterCard filter = new FilterCard();
    filter.add(new ColorPredicate(ObjectColor.BLACK));
    int blackCards = controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
    int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game);
    game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards.");
    if (cardsToReveal > 0) {
        TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter);
        if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
            controller.revealCards(sourceObject.getIdName(), new CardsImpl(target.getTargets()), game);
            int unboost = target.getTargets().size() * -1;
            ContinuousEffect effect = new BoostTargetEffect(unboost, unboost, Duration.EndOfTurn);
            effect.setTargetPointer(getTargetPointer());
            game.addEffect(effect, source);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CardsImpl(mage.cards.CardsImpl)

Example 70 with TargetCardInHand

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

the class NightshadeSeerEffect 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)

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