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;
}
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;
}
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;
}
Aggregations