use of mage.cards.CardsImpl in project mage by magefree.
the class GlimpseOfTomorrowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
int count = permanents.size();
player.shuffleCardsToLibrary(new CardsImpl(permanents), game, source);
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, count));
player.revealCards(source, cards, game);
Cards toBattlefield = new CardsImpl(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
toBattlefield.removeIf(uuid -> game.getCard(uuid).hasSubtype(SubType.AURA, game));
player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
toBattlefield.clear();
cards.retainZone(Zone.LIBRARY, game);
toBattlefield.addAll(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
toBattlefield.removeIf(uuid -> !game.getCard(uuid).hasSubtype(SubType.AURA, game));
player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
cards.retainZone(Zone.LIBRARY, game);
player.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class GrimReminderWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_NON_LAND);
if (controller.searchLibrary(target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
Cards cardsToReveal = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
String cardName = card.getName();
GrimReminderWatcher watcher = game.getState().getWatcher(GrimReminderWatcher.class);
if (watcher != null) {
for (UUID playerId : watcher.getPlayersCastSpell(cardName)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(6, game, source, false);
}
}
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class HedronAlignmentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Cards cardsToReveal = new CardsImpl();
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
// Check battlefield
if (!game.getBattlefield().contains(filterPermanent, source, game, 1)) {
return true;
}
if (controller.getHand().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
return true;
}
if (controller.getGraveyard().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) {
return true;
}
Cards cardsToCheck = new CardsImpl();
cardsToCheck.addAll(game.getExile().getAllCards(game));
if (cardsToCheck.count(filterCard, source.getSourceId(), controller.getId(), game) == 0) {
return true;
}
controller.won(game);
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class JudgeUnworthyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null && controller != null) {
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
controller.revealCards(sourceCard.getName(), new CardsImpl(card), game);
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
targetCreature.damage(card.getManaValue(), source.getSourceId(), source, game, false, true);
return true;
}
}
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class LagonnaBandStorytellerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (controller == null || card == null || !card.isEnchantment(game) || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
return false;
}
int cmc = card.getManaValue();
if (controller.putCardsOnTopOfLibrary(new CardsImpl(card), game, source, false)) {
controller.gainLife(cmc, game, source);
return true;
}
return false;
}
Aggregations