use of mage.cards.Cards in project mage by magefree.
the class GisaGloriousResurrectorReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Ability exiledWithSource = (Ability) game.getState().getValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()));
if (exiledWithSource == null) {
return false;
}
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, exiledWithSource));
if (player == null || exileZone == null || exileZone.isEmpty()) {
return false;
}
Cards cards = new CardsImpl(exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
if (cards.isEmpty()) {
return false;
}
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
cards.retainZone(Zone.BATTLEFIELD, game);
if (cards.isEmpty()) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cards, game)), source);
return true;
}
use of mage.cards.Cards 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.Cards 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.Cards in project mage by magefree.
the class HellholeRatsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int damage = 0;
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
Cards cards = targetPlayer.discard(1, false, false, source, game);
if (!cards.isEmpty()) {
for (Card card : cards.getCards(game)) {
damage = card.getManaValue();
}
targetPlayer.damage(damage, source.getSourceId(), source, game);
}
return true;
}
return false;
}
use of mage.cards.Cards 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;
}
Aggregations