use of mage.cards.CardsImpl in project mage by magefree.
the class LanternOfTheLostEffect 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();
game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).forEach(cards::addAll);
player.moveCards(cards, Zone.EXILED, source, game);
player.drawCards(1, source, game);
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class MadcapExperimentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
CardsImpl toReveal = new CardsImpl();
Card toBattlefield = null;
for (Card card : controller.getLibrary().getCards(game)) {
toReveal.add(card);
game.fireUpdatePlayersEvent();
if (card.isArtifact(game)) {
toBattlefield = card;
break;
}
}
controller.revealCards(source, toReveal, game);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
int damage = toReveal.size();
toReveal.remove(toBattlefield);
controller.putCardsOnBottomOfLibrary(toReveal, game, source, false);
controller.damage(damage, source.getSourceId(), source, game);
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class MindBombEffect 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) {
return false;
}
Map<UUID, Cards> cardsToDiscard = new HashMap<>();
// choose
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Cards cards = new CardsImpl();
Target target = new TargetDiscard(0, 3, new FilterCard(), playerId);
player.chooseTarget(Outcome.Discard, target, source, game);
cards.addAll(target.getTargets());
cardsToDiscard.put(playerId, cards);
}
// discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Cards cardsPlayer = cardsToDiscard.get(playerId);
cardsToDiscard.put(playerId, player.discard(cardsPlayer, false, source, game));
}
}
// damage
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Cards cardsPlayer = cardsToDiscard.get(playerId);
if (cardsPlayer != null) {
player.damage(3 - cardsPlayer.size(), source.getSourceId(), source, game);
}
}
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class MerfolkSpyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null && !player.getHand().isEmpty()) {
Cards revealed = new CardsImpl();
revealed.add(player.getHand().getRandom(game));
player.revealCards("Merfolk Spy", revealed, game);
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class MidnightRitualEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToExile = new CardsImpl(getTargetPointer().getTargets(game, source));
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
if (!cardsToExile.isEmpty()) {
new ZombieToken().putOntoBattlefield(cardsToExile.size(), game, source, controller.getId());
}
return true;
}
return false;
}
Aggregations