use of mage.cards.Cards 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.Cards 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.Cards 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.Cards 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;
}
use of mage.cards.Cards in project mage by magefree.
the class MundaAmbushLeaderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards allCards = new CardsImpl();
allCards.addAll(controller.getLibrary().getTopCards(game, 4));
controller.lookAtCards(sourceObject.getIdName(), allCards, game);
if (!allCards.isEmpty()) {
Cards cardsToReveal = new CardsImpl();
TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
controller.chooseTarget(outcome, allCards, target, source, game);
cardsToReveal.addAll(target.getTargets());
if (!cardsToReveal.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game, true);
allCards.removeAll(cardsToReveal);
}
controller.putCardsOnTopOfLibrary(cardsToReveal, game, source, true);
}
if (!allCards.isEmpty()) {
controller.putCardsOnBottomOfLibrary(allCards, game, source, true);
}
return true;
}
return false;
}
Aggregations