use of mage.target.TargetCard in project mage by magefree.
the class KaaliaZenithSeekerEffect 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));
Cards toHand = new CardsImpl();
for (CreatureFinder creatureFinder : CreatureFinder.values()) {
TargetCard targetCard = creatureFinder.getTarget();
if (player.choose(outcome, cards, targetCard, game)) {
toHand.addAll(targetCard.getTargets());
}
}
cards.removeAll(toHand);
player.revealCards(source, toHand, game);
player.moveCards(toHand, Zone.HAND, source, game);
player.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class LostHoursEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer != null && controller != null) {
targetPlayer.revealCards(source, targetPlayer.getHand(), game);
if (targetPlayer.getHand().size() > 0) {
TargetCard target = new TargetCard(Zone.HAND, new FilterCard(StaticFilters.FILTER_CARD_A_NON_LAND));
if (controller.choose(Outcome.Discard, targetPlayer.getHand(), target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
targetPlayer.putCardOnTopXOfLibrary(card, game, source, 3, true);
}
}
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class LordOfTheVoidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (player == null || controller == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
controller.moveCards(cards, Zone.EXILED, source, game);
if (!cards.getCards(StaticFilters.FILTER_CARD_CREATURE, game).isEmpty()) {
TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
if (controller.chooseTarget(outcome, cards, target, source, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
}
}
}
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class MemoryLeakEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(source.getFirstTarget());
if (controller == null || opponent == null) {
return false;
}
opponent.revealCards(source, opponent.getHand(), game);
TargetCard target;
Cards cards;
if (controller.chooseUse(outcome, "Exile a card from hand or graveyard?", null, "Hand", "Graveyard", source, game)) {
FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s hand");
target = new TargetCard(Zone.HAND, filter);
target.setNotTarget(true);
cards = opponent.getHand();
} else {
FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s graveyard");
target = new TargetCard(Zone.GRAVEYARD, filter);
target.setNotTarget(true);
cards = opponent.getGraveyard();
}
if (controller.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
}
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class MurmursFromBeyondEffect 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) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) {
controller.revealCards(staticText, cards, game);
Card cardToGraveyard;
if (cards.size() == 1) {
cardToGraveyard = cards.getRandom(game);
} else {
Player opponent;
Set<UUID> opponents = game.getOpponents(controller.getId());
if (opponents.size() == 1) {
opponent = game.getPlayer(opponents.iterator().next());
} else {
Target target = new TargetOpponent(true);
controller.chooseTarget(Outcome.Detriment, target, source, game);
opponent = game.getPlayer(target.getFirstTarget());
}
TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard());
opponent.chooseTarget(outcome, cards, target, source, game);
cardToGraveyard = game.getCard(target.getFirstTarget());
}
if (cardToGraveyard != null) {
controller.moveCards(cardToGraveyard, Zone.GRAVEYARD, source, game);
cards.remove(cardToGraveyard);
}
controller.moveCards(cards, Zone.HAND, source, game);
}
return true;
}
return false;
}
Aggregations