Search in sources :

Example 16 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class JungleWayfinderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                TargetCardInLibrary target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_BASIC_LAND);
                if (player.chooseUse(Outcome.Benefit, "Search your library for a card to put into your hand?", source, game)) {
                    player.searchLibrary(target, source, game);
                    for (UUID cardId : target.getTargets()) {
                        Card card = player.getLibrary().getCard(cardId, game);
                        if (card != null) {
                            player.revealCards(source, new CardsImpl(card), game);
                            player.moveCards(card, Zone.HAND, source, game);
                        }
                    }
                    player.shuffleLibrary(source, game);
                }
            }
        }
        // prevent undo
        controller.resetStoredBookmark(game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 17 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class KaaliaZenithSeekerEffect 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, 6));
    Cards toHand = new CardsImpl();
    for (CreatureFinder creatureFinder : CreatureFinder.values()) {
        TargetCard targetCard = creatureFinder.getTarget();
        if (player.choose(outcome, cards, targetCard, game)) {
            toHand.addAll(targetCard.getTargets());
        }
    }
    cards.removeAll(toHand);
    player.revealCards(source, toHand, game);
    player.moveCards(toHand, Zone.HAND, source, game);
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 18 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class LordOfTheVoidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (player == null || controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
    controller.moveCards(cards, Zone.EXILED, source, game);
    if (!cards.getCards(StaticFilters.FILTER_CARD_CREATURE, game).isEmpty()) {
        TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
        if (controller.chooseTarget(outcome, cards, target, source, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 19 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class MyojinOfGrimBetrayalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
    if (controller == null || watcher == null) {
        return false;
    }
    Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    return controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 20 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class MyrIncubatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && controller.searchLibrary(target, source, game)) {
        if (!target.getTargets().isEmpty()) {
            tokensToCreate = target.getTargets().size();
            controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
        }
        CreateTokenEffect effect = new CreateTokenEffect(new MyrToken(), tokensToCreate);
        effect.apply(game, source);
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) MyrToken(mage.game.permanent.token.MyrToken) CardsImpl(mage.cards.CardsImpl)

Aggregations

CardsImpl (mage.cards.CardsImpl)507 Player (mage.players.Player)497 Cards (mage.cards.Cards)328 Card (mage.cards.Card)253 UUID (java.util.UUID)135 Permanent (mage.game.permanent.Permanent)114 FilterCard (mage.filter.FilterCard)108 MageObject (mage.MageObject)106 TargetCard (mage.target.TargetCard)99 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)53 TargetPlayer (mage.target.TargetPlayer)47 TargetCardInHand (mage.target.common.TargetCardInHand)41 OneShotEffect (mage.abilities.effects.OneShotEffect)37 Target (mage.target.Target)32 Ability (mage.abilities.Ability)27 FilterPermanent (mage.filter.FilterPermanent)27 CardSetInfo (mage.cards.CardSetInfo)25 Game (mage.game.Game)25 CardImpl (mage.cards.CardImpl)24 FilterCreatureCard (mage.filter.common.FilterCreatureCard)23