use of mage.cards.CardsImpl in project mage by magefree.
the class BerserkersFrenzyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
game.addEffect(new BlocksIfAbleTargetEffect(Duration.EndOfTurn).setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source);
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class BenefactionOfRhonasEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
boolean creatureCardFound = false;
boolean enchantmentCardFound = false;
for (UUID cardId : cards) {
Card card = game.getCard(cardId);
if (card != null) {
cards.add(card);
if (card.isCreature(game)) {
creatureCardFound = true;
}
if (card.isEnchantment(game)) {
enchantmentCardFound = true;
}
}
}
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
if ((creatureCardFound || enchantmentCardFound) && controller.chooseUse(Outcome.DrawCard, "Put a creature card and/or enchantment card into your hand?", source, game)) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put into your hand"));
if (creatureCardFound && controller.chooseTarget(Outcome.DrawCard, cards, target, source, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.HAND, source, game);
}
}
target = new TargetCard(Zone.LIBRARY, new FilterEnchantmentCard("enchantment card to put into your hand"));
if (enchantmentCardFound && controller.chooseTarget(Outcome.DrawCard, cards, target, source, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class CryOfTheCarnariumReplacementEffect 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.EXILED, source, game);
}
use of mage.cards.CardsImpl in project mage by magefree.
the class CryptIncursionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Cards cards = new CardsImpl(targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
player.moveCards(cards, Zone.EXILED, source, game);
int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
player.gainLife(3 * count, game, source);
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class CulminationOfStudiesEffect 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, source.getManaCostsToPay().getX()));
player.moveCards(cards, Zone.EXILED, source, game);
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
int landCards = cards.count(StaticFilters.FILTER_CARD_LAND, game);
int blueCards = cards.count(filterBlue, game);
int redCards = cards.count(filterRed, game);
if (landCards > 0) {
new TreasureToken().putOntoBattlefield(landCards, game, source, source.getControllerId());
}
if (blueCards > 0) {
player.drawCards(blueCards, source, game);
}
if (redCards > 0) {
new DamagePlayersEffect(redCards, TargetController.OPPONENT).apply(game, source);
}
return true;
}
Aggregations