use of mage.target.TargetCard in project mage by magefree.
the class PsychoticEpisodeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (player != null && controller != null && sourceObject != null) {
TargetCard targetCard = new TargetCard(Zone.ALL, new FilterCard());
targetCard.setRequired(true);
Cards options = player.getHand().copy();
Card topdeck = player.getLibrary().getFromTop(game);
options.add(topdeck);
controller.lookAtCards("Top of Library (Psychotic Episode)", topdeck, game);
if (controller.choose(Outcome.Discard, options, targetCard, game)) {
Card card = game.getCard(targetCard.getFirstTarget());
if (card != null) {
CardsImpl cards = new CardsImpl();
cards.add(card);
player.revealCards(sourceObject.getIdName(), cards, game);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
}
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class DevelopmentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.Benefit, staticText + "?", source, game)) {
Cards cards = controller.getSideboard();
if (cards.isEmpty()) {
game.informPlayer(controller, "You have no cards outside the game.");
return true;
}
TargetCard target = new TargetCard(0, 4, Zone.OUTSIDE, new FilterCard("cards you own from outside the game"));
target.setNotTarget(true);
if (controller.choose(Outcome.Benefit, controller.getSideboard(), target, game)) {
controller.shuffleCardsToLibrary(new CardsImpl(target.getTargets()), game, source);
}
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class SummoningTrapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put on the battlefield"));
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
if (!cards.isEmpty()) {
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
}
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class ExileAllCardsFromAllGraveyards method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject Valki = game.getObject(source.getSourceId());
Set<Card> cardsToExile = new LinkedHashSet<>();
if (controller != null && Valki != null) {
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + Valki.getZoneChangeCounter(game), game);
for (UUID opponentId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
opponent.revealCards(source, opponent.getHand(), game);
TargetCard targetToExile = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_CREATURE);
targetToExile.withChooseHint("card to exile");
targetToExile.setNotTarget(true);
if (controller.choose(Outcome.Exile, opponent.getHand(), targetToExile, game)) {
Card targetedCardToExile = game.getCard(targetToExile.getFirstTarget());
if (targetedCardToExile != null && game.getState().getZone(source.getSourceId()) == Zone.BATTLEFIELD) {
cardsToExile.add(targetedCardToExile);
}
}
}
}
// exile all cards at one time
controller.moveCardsToExile(cardsToExile, source, game, true, exileId, Valki.getName());
game.addDelayedTriggeredAbility(new ValkiGodOfLiesReturnExiledCardAbility(), source);
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class ExploreTheVastlandsTarget method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 5));
TargetCard target = new ExploreTheVastlandsTarget();
player.choose(outcome, cards, target, game);
Cards toHand = new CardsImpl(target.getTargets());
cards.removeIf(target.getTargets()::contains);
player.revealCards(source, toHand, game);
player.moveCards(toHand, Zone.HAND, source, game);
player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.gainLife(3, game, source);
}
}
return true;
}
Aggregations