use of mage.target.TargetCard in project mage by magefree.
the class AugurOfBolasEffect 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 topCards = new CardsImpl();
topCards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!topCards.isEmpty()) {
controller.lookAtCards(sourceObject.getIdName(), topCards, game);
int number = topCards.count(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game);
if (number > 0) {
if (controller.chooseUse(outcome, "Reveal an instant or sorcery card from the looked at cards and put it into your hand?", source, game)) {
Card card = null;
if (number == 1) {
Set<Card> cards = topCards.getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game);
if (!cards.isEmpty()) {
card = cards.iterator().next();
}
} else {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterInstantOrSorceryCard());
controller.chooseTarget(outcome, topCards, target, source, game);
card = topCards.get(target.getFirstTarget(), game);
}
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
topCards.remove(card);
}
}
}
controller.putCardsOnBottomOfLibrary(topCards, game, source, true);
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class AtrisOracleOfHalfTruthsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || targetOpponent == null || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
targetOpponent.choose(outcome, cards, target, game);
Cards faceDownPile = new CardsImpl(target.getTargets());
cards.removeAll(target.getTargets());
controller.revealCards(sourceObject.getIdName() + " - cards in face-up pile", cards, game);
game.informPlayers(targetOpponent.getLogName() + " puts " + faceDownPile.size() + " card(s) into the face-down pile");
if (controller.chooseUse(outcome, "Choose a pile to put in your hand.", null, "Face-down", "Face-up", source, game)) {
controller.moveCards(faceDownPile, Zone.HAND, source, game);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} else {
controller.moveCards(faceDownPile, Zone.GRAVEYARD, source, game);
controller.moveCards(cards, Zone.HAND, source, game);
}
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class AshnodsCylixEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
player.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on top of your library"));
if (player.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
game.informPlayers(source.getSourceObject(game).getIdName() + ": " + player.getLogName() + " puts a card back on top of their library");
}
}
player.moveCards(cards, Zone.EXILED, source, game);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class SearchForBlexEffect method actionWithSelectedCards.
@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
TargetCard target = new TargetCard(0, 5, Zone.LIBRARY, filter);
if (player.choose(outcome, cards, target, game)) {
Cards pickedCards = new CardsImpl(target.getTargets());
cards.removeAll(pickedCards);
player.moveCards(pickedCards, Zone.HAND, source, game);
player.loseLife(pickedCards.size() * 3, game, source, false);
}
}
}
use of mage.target.TargetCard in project mage by magefree.
the class BountyOfSkemfarEffect 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, 6));
player.revealCards(source, cards, game);
TargetCard target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_LAND);
player.choose(outcome, cards, target, game);
Card land = cards.get(target.getFirstTarget(), game);
if (land != null) {
player.moveCards(land, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.LIBRARY);
target = new TargetCardInLibrary(0, 1, filter);
player.choose(outcome, cards, target, game);
Card elf = cards.get(target.getFirstTarget(), game);
if (elf != null) {
player.moveCards(elf, Zone.HAND, source, game);
}
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.LIBRARY);
player.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
Aggregations