use of mage.cards.CardsImpl in project mage by magefree.
the class TrackDownEffect 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) {
return false;
}
if (!controller.getLibrary().hasCards()) {
return false;
}
Card card = controller.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
CardsImpl cards = new CardsImpl();
cards.add(card);
controller.revealCards(sourceObject.getName(), cards, game);
if (card.isLand(game) || card.isCreature(game)) {
controller.drawCards(1, source, game);
}
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class VarragothBloodskySireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
if (player.searchLibrary(target, source, game)) {
Cards foundCards = new CardsImpl(target.getTargets());
player.shuffleLibrary(source, game);
player.putCardsOnTopOfLibrary(foundCards, game, source, false);
return true;
}
player.shuffleLibrary(source, game);
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class VaevictisAsmadiTheDireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Player> playersToFlip = new ArrayList<>();
for (Target target : source.getTargets()) {
for (UUID permId : target.getTargets()) {
Permanent permanent = game.getPermanent(permId);
if (permanent == null || !permanent.sacrifice(source, game)) {
continue;
}
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
playersToFlip.add(player);
}
}
}
for (Player player : playersToFlip) {
if (player == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
continue;
}
player.revealCards(source, new CardsImpl(card), game);
if (card.isPermanent(game)) {
player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class WandOfDenialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (controller != null && targetPlayer != null) {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
controller.lookAtCards(sourceObject != null ? sourceObject.getName() : "", new CardsImpl(card), game);
if (!card.isLand(game) && controller.canPayLifeCost(source) && controller.getLife() >= 2 && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", source, game)) {
controller.loseLife(2, game, source, false);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
return true;
}
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ZursWeirdingReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
boolean paid = false;
Player player = game.getPlayer(event.getTargetId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
// Reveals it instead
player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + '|' + game.getPhase().getType() + ')', new CardsImpl(card), game);
// Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard
String message = "Pay 2 life to put " + card.getLogName() + " into " + player.getLogName() + " graveyard?";
for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
if (playerId.equals(player.getId())) {
continue;
}
Player otherPlayer = game.getPlayer(playerId);
if (otherPlayer == null || !otherPlayer.canPayLifeCost(source) || otherPlayer.getLife() < 2) {
continue;
}
PayLifeCost lifeCost = new PayLifeCost(2);
if (otherPlayer.chooseUse(Outcome.Benefit, message, source, game) && lifeCost.pay(source, game, source, otherPlayer.getId(), true)) {
player.moveCards(card, Zone.GRAVEYARD, source, game);
return true;
}
}
// This is still replacing the draw, so we still return true
player.drawCards(1, source, game, event);
return true;
}
Aggregations