Search in sources :

Example 16 with Library

use of mage.players.Library in project mage by magefree.

the class AtlaPalaniNestTenderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Library library = player.getLibrary();
    if (!library.hasCards()) {
        return true;
    }
    Cards cards = new CardsImpl();
    Card toBattlefield = null;
    for (Card card : library.getCards(game)) {
        cards.add(card);
        if (card.isCreature(game)) {
            toBattlefield = card;
            break;
        }
    }
    if (toBattlefield != null) {
        player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
    }
    player.revealCards(source, cards, game);
    cards.remove(toBattlefield);
    if (!cards.isEmpty()) {
        player.putCardsOnBottomOfLibrary(cards, game, source, false);
    }
    return true;
}
Also used : Player(mage.players.Player) Library(mage.players.Library)

Example 17 with Library

use of mage.players.Library in project mage by magefree.

the class ClearTheLandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean tapped = true;
    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) {
                Library library = player.getLibrary();
                Cards cardsToReveal = new CardsImpl();
                cardsToReveal.addAll(library.getTopCards(game, 5));
                if (!cardsToReveal.isEmpty()) {
                    player.revealCards(source, "Revealed cards for " + player.getName(), cardsToReveal, game);
                    Cards cardsToPutOnBattlefield = new CardsImpl();
                    Cards cardsToExile = new CardsImpl();
                    for (Card card : cardsToReveal.getCards(game)) {
                        if (card.isLand(game)) {
                            cardsToPutOnBattlefield.add(card);
                        } else {
                            cardsToExile.add(card);
                        }
                    }
                    player.moveCards(cardsToPutOnBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, true, null);
                    player.moveCards(cardsToExile.getCards(game), Zone.EXILED, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Library(mage.players.Library) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 18 with Library

use of mage.players.Library in project mage by magefree.

the class BioplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Library library = player.getLibrary();
    if (library == null || !library.hasCards()) {
        return false;
    }
    Card card = library.getFromTop(game);
    if (card == null) {
        return false;
    }
    if (player.moveCards(card, Zone.EXILED, source, game) && card.isCreature(game)) {
        game.addEffect(new BoostSourceEffect(card.getPower().getValue(), card.getToughness().getValue(), Duration.EndOfTurn), source);
    }
    return true;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) Player(mage.players.Player) Library(mage.players.Library) Card(mage.cards.Card)

Aggregations

Library (mage.players.Library)18 Player (mage.players.Player)18 Card (mage.cards.Card)11 MageObject (mage.MageObject)9 Permanent (mage.game.permanent.Permanent)7 ContinuousEffect (mage.abilities.effects.ContinuousEffect)5 CardsImpl (mage.cards.CardsImpl)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 UUID (java.util.UUID)3 Cards (mage.cards.Cards)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 ApprovingObject (mage.ApprovingObject)2 CardType (mage.constants.CardType)2 FilterCard (mage.filter.FilterCard)2 TargetPermanent (mage.target.TargetPermanent)2 ArrayList (java.util.ArrayList)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 DamagePlayersEffect (mage.abilities.effects.common.DamagePlayersEffect)1