Search in sources :

Example 96 with TargetCardInLibrary

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

the class SvellaIceShaperEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Set<Card> cardsSet = controller.getLibrary().getTopCards(game, 4);
    Cards cards = new CardsImpl(cardsSet);
    TargetCard target = new TargetCardInLibrary(0, 1, new FilterNonlandCard("card to cast without paying its mana cost"));
    controller.choose(Outcome.PlayForFree, cards, target, game);
    Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
    if (card == null) {
        controller.putCardsOnBottomOfLibrary(cards, game, source, false);
        return true;
    }
    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
    Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
    if (cardWasCast) {
        cards.remove(card);
    }
    controller.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) FilterNonlandCard(mage.filter.common.FilterNonlandCard) ApprovingObject(mage.ApprovingObject) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard)

Example 97 with TargetCardInLibrary

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

the class VivienChampionOfTheWildsCastFromExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    // select
    Cards cardsToLook = new CardsImpl(player.getLibrary().getTopCards(game, 3));
    FilterCard filter = new FilterCard("card to exile face down");
    TargetCard target = new TargetCardInLibrary(filter);
    if (!player.choose(outcome, cardsToLook, target, game)) {
        return false;
    }
    // exile
    Card cardToExile = game.getCard(target.getFirstTarget());
    if (!player.moveCardsToExile(cardToExile, source, game, false, CardUtil.getCardExileZoneId(game, source), CardUtil.createObjectRealtedWindowTitle(source, game, " (look and cast)"))) {
        return false;
    }
    cardToExile.setFaceDown(true, game);
    // look and cast
    ContinuousEffect effect = new VivienChampionOfTheWildsLookEffect(player.getId());
    effect.setTargetPointer(new FixedTarget(cardToExile, game));
    game.addEffect(effect, source);
    if (cardToExile.isCreature(game)) {
        effect = new VivienChampionOfTheWildsCastFromExileEffect(player.getId());
        effect.setTargetPointer(new FixedTarget(cardToExile, game));
        game.addEffect(effect, source);
    }
    // put the rest on the bottom of your library in any order
    Cards cardsToBottom = new CardsImpl(cardsToLook);
    cardsToBottom.remove(cardToExile);
    player.putCardsOnBottomOfLibrary(cardsToBottom, game, source, true);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCard(mage.target.TargetCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 98 with TargetCardInLibrary

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

the class WildPairPowerToughnessPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
    if (controller == null || permanent == null) {
        return false;
    }
    int totalPT = permanent.getPower().getValue() + permanent.getToughness().getValue();
    FilterCreatureCard filter = new FilterCreatureCard("creature card with total power and toughness " + totalPT);
    filter.add(new WildPairPowerToughnessPredicate(totalPT));
    TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
    controller.searchLibrary(target, source, game);
    controller.moveCards(new CardsImpl(controller.getLibrary().getCard(target.getFirstTarget(), game)), Zone.BATTLEFIELD, source, game);
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 99 with TargetCardInLibrary

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

the class CustomTestCard method addCustomEffect_ReturnFromAnyToHand.

/**
 * Return target card to hand that can be called by text "return from ..."
 *
 * @param controller
 */
protected void addCustomEffect_ReturnFromAnyToHand(TestPlayer controller) {
    // graveyard
    Ability ability = new SimpleActivatedAbility(new ReturnFromGraveyardToHandTargetEffect().setText("return from graveyard"), new ManaCostsImpl(""));
    ability.addTarget(new TargetCardInGraveyard(StaticFilters.FILTER_CARD));
    addCustomCardWithAbility("return from graveyard for " + controller.getName(), controller, ability);
    // exile
    ability = new SimpleActivatedAbility(new ReturnFromExileEffect(Zone.HAND).setText("return from exile"), new ManaCostsImpl(""));
    ability.addTarget(new TargetCardInExile(StaticFilters.FILTER_CARD));
    addCustomCardWithAbility("return from exile for " + controller.getName(), controller, ability);
    // library
    ability = new SimpleActivatedAbility(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD)).setText("return from library"), new ManaCostsImpl(""));
    addCustomCardWithAbility("return from library for " + controller.getName(), controller, ability);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SpellAbility(mage.abilities.SpellAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetCardInExile(mage.target.common.TargetCardInExile) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 100 with TargetCardInLibrary

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

the class AdventureAwaitsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 5));
    TargetCard target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_CREATURE);
    player.choose(outcome, cards, target, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card != null && player.chooseUse(outcome, "Put " + card.getName() + " into your hand?", "Otherwise draw a card", "Put into hand", "Draw a card", source, game)) {
        player.moveCards(card, Zone.HAND, source, game);
        cards.remove(card);
        player.putCardsOnBottomOfLibrary(cards, game, source, false);
    } else {
        player.putCardsOnBottomOfLibrary(cards, game, source, false);
        player.drawCards(1, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) TargetCard(mage.target.TargetCard)

Aggregations

TargetCardInLibrary (mage.target.common.TargetCardInLibrary)225 Player (mage.players.Player)207 FilterCard (mage.filter.FilterCard)120 Card (mage.cards.Card)110 Permanent (mage.game.permanent.Permanent)68 UUID (java.util.UUID)65 CardsImpl (mage.cards.CardsImpl)53 TargetCard (mage.target.TargetCard)53 MageObject (mage.MageObject)37 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)31 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)28 Cards (mage.cards.Cards)26 TargetPlayer (mage.target.TargetPlayer)19 FilterCreatureCard (mage.filter.common.FilterCreatureCard)18 FilterPermanent (mage.filter.FilterPermanent)14 TargetPermanent (mage.target.TargetPermanent)14 FixedTarget (mage.target.targetpointer.FixedTarget)14 Cost (mage.abilities.costs.Cost)13 SearchLibraryPutInHandEffect (mage.abilities.effects.common.search.SearchLibraryPutInHandEffect)13 SearchLibraryPutInPlayEffect (mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)12