Search in sources :

Example 31 with TargetCardInHand

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

the class IvySeerEffect 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 32 with TargetCardInHand

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

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

Example 33 with TargetCardInHand

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

the class JacobHaukenInspectorLookEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    controller.drawCards(1, source, game);
    if (!controller.getHand().isEmpty()) {
        TargetCardInHand target = new TargetCardInHand().withChooseHint("to exile");
        controller.chooseTarget(outcome, controller.getHand(), target, source, game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
            MageObject sourceObject = source.getSourceObject(game);
            String exileName = sourceObject == null ? null : sourceObject.getIdName();
            controller.moveCardsToExile(card, source, game, true, exileId, exileName);
            if (game.getState().getZone(card.getId()) == Zone.EXILED) {
                card.setFaceDown(true, game);
                JacobHaukenInspectorLookEffect effect = new JacobHaukenInspectorLookEffect(controller.getId());
                effect.setTargetPointer(new FixedTarget(card, game));
                game.addEffect(effect, source);
            }
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card)

Example 34 with TargetCardInHand

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

the class LichsMasteryLoseLifeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ControllerIdPredicate(controller.getId()));
    for (int i = 0; i < amount; i++) {
        int handCount = controller.getHand().size();
        int graveCount = controller.getGraveyard().size();
        int permCount = game.getBattlefield().getActivePermanents(filter, controller.getId(), game).size();
        if (graveCount + handCount == 0 || (permCount > 0 && controller.chooseUse(Outcome.Exile, "Exile permanent you control? (No = from hand or graveyard)", source, game))) {
            Target target = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true);
            controller.choose(outcome, target, source.getSourceId(), game);
            Effect effect = new ExileTargetEffect();
            effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
            effect.apply(game, source);
        } else if (graveCount == 0 || (handCount > 0 && controller.chooseUse(Outcome.Exile, "Exile a card from your hand? (No = from graveyard)", source, game))) {
            Target target = new TargetCardInHand(1, 1, new FilterCard());
            controller.choose(outcome, target, source.getSourceId(), game);
            Card card = controller.getHand().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.EXILED, source, game);
            }
        } else if (graveCount > 0) {
            Target target = new TargetCardInYourGraveyard(1, 1, new FilterCard(), true);
            target.choose(Outcome.Exile, source.getControllerId(), source.getSourceId(), game);
            Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.EXILED, source, game);
            }
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) LoseGameSourceControllerEffect(mage.abilities.effects.common.LoseGameSourceControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 35 with TargetCardInHand

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

the class MasterOfPredicamentsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (!controller.getHand().isEmpty()) {
            Card cardFromHand = null;
            if (controller.getHand().size() > 1) {
                TargetCard target = new TargetCardInHand(new FilterCard());
                if (controller.choose(Outcome.PlayForFree, controller.getHand(), target, game)) {
                    cardFromHand = game.getCard(target.getFirstTarget());
                }
            } else {
                cardFromHand = controller.getHand().getRandom(game);
            }
            if (cardFromHand == null) {
                return false;
            }
            Player attackedPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
            if (attackedPlayer == null) {
                return false;
            }
            boolean guessWrong;
            if (attackedPlayer.chooseUse(Outcome.Detriment, "Is the chosen card's " + "mana value greater than 4?", source, game)) {
                game.informPlayers(attackedPlayer.getLogName() + " guessed that the chosen " + "card's mana value is greater than 4");
                guessWrong = cardFromHand.getManaValue() <= 4;
            } else {
                game.informPlayers(attackedPlayer.getLogName() + " guessed that the chosen " + "card's mana value is not greater than 4");
                guessWrong = cardFromHand.getManaValue() > 4;
            }
            game.informPlayers(attackedPlayer.getLogName() + " guessed " + (guessWrong ? "wrong" : "right"));
            if (guessWrong) {
                if (cardFromHand.isLand(game)) {
                // If the revealed card is a land, you can't cast it. So nothing happens
                } else {
                    if (controller.chooseUse(outcome, "Cast " + cardFromHand.getName() + " without paying its mana cost?", source, game)) {
                        game.getState().setValue("PlayFromNotOwnHandZone" + cardFromHand.getId(), Boolean.TRUE);
                        controller.cast(controller.chooseAbilityForCast(cardFromHand, game, true), game, true, new ApprovingObject(source, game));
                        game.getState().setValue("PlayFromNotOwnHandZone" + cardFromHand.getId(), null);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) 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