Search in sources :

Example 91 with TargetCardInLibrary

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

the class SeekEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(source.getFirstTarget());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null && opponent != null) {
        if (opponent.getLibrary().hasCards()) {
            TargetCardInLibrary target = new TargetCardInLibrary();
            if (player.searchLibrary(target, source, game, opponent.getId())) {
                UUID targetId = target.getFirstTarget();
                Card card = opponent.getLibrary().remove(targetId, game);
                if (card != null) {
                    player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
                    int cmc = card.getManaValue();
                    if (cmc > 0) {
                        player.gainLife(cmc, game, source);
                    }
                }
            }
        }
        opponent.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SplitCard(mage.cards.SplitCard) Card(mage.cards.Card)

Example 92 with TargetCardInLibrary

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

the class LightPawsEmperorsVoiceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent aura = (Permanent) getValue("permanentEnteringBattlefield");
    if (player == null || aura == null || !player.chooseUse(outcome, "Search for an Aura?", source, game)) {
        return false;
    }
    FilterCard filter = new FilterCard("Aura card with mana value less than or equal to " + aura.getManaValue());
    filter.add(SubType.AURA.getPredicate());
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, aura.getManaValue() + 1));
    filter.add(LightPawsEmperorsVoiceEffectPredicate.instance);
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    player.searchLibrary(target, source, game);
    Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (card != null && permanent != null && new AuraCardCanAttachToPermanentId(permanent.getId()).apply(card, game)) {
        game.getState().setValue("attachTo:" + card.getId(), permanent);
        player.moveCards(card, Zone.BATTLEFIELD, source, game);
        permanent.addAttachment(card.getId(), source, game);
    }
    player.shuffleLibrary(source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) AuraCardCanAttachToPermanentId(mage.filter.predicate.card.AuraCardCanAttachToPermanentId) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 93 with TargetCardInLibrary

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

the class MythosOfBrokkosEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (condition.apply(game, source)) {
        TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary();
        if (player.searchLibrary(targetCardInLibrary, source, game)) {
            Card card = game.getCard(targetCardInLibrary.getFirstTarget());
            if (card != null) {
                player.moveCards(card, Zone.GRAVEYARD, source, game);
            }
            player.shuffleLibrary(source, game);
        }
    }
    TargetCard targetCard = new TargetCardInYourGraveyard(0, 2, filter, true);
    player.choose(outcome, player.getGraveyard(), targetCard, game);
    Cards cards = new CardsImpl(targetCard.getTargets());
    return player.moveCards(cards, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) TargetCard(mage.target.TargetCard)

Example 94 with TargetCardInLibrary

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

the class OldGrowthDryadsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Set<Player> playersThatSearched = new HashSet<>(1);
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(opponentId);
        if (opponent != null && opponent.chooseUse(Outcome.PutLandInPlay, "Search your library for a basic land card and put it onto the battlefield tapped?", source, game)) {
            TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard());
            if (opponent.searchLibrary(target, source, game)) {
                Card targetCard = opponent.getLibrary().getCard(target.getFirstTarget(), game);
                if (targetCard != null) {
                    opponent.moveCards(targetCard, Zone.BATTLEFIELD, source, game, true, false, false, null);
                    playersThatSearched.add(opponent);
                }
            }
        }
    }
    for (Player opponent : playersThatSearched) {
        opponent.shuffleLibrary(source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) FilterBasicLandCard(mage.filter.common.FilterBasicLandCard) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) HashSet(java.util.HashSet) FilterBasicLandCard(mage.filter.common.FilterBasicLandCard) Card(mage.cards.Card)

Example 95 with TargetCardInLibrary

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

the class ShigekiJukaiVisionaryEffect 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, 4));
    player.revealCards(source, cards, game);
    TargetCard target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_LAND);
    player.choose(outcome, cards, target, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card != null) {
        player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
        cards.remove(card);
    }
    player.moveCards(cards, Zone.GRAVEYARD, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) 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