use of mage.target.TargetCard in project mage by magefree.
the class BagOfDevouringEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int result = player.rollDice(Outcome.Benefit, source, game, 10);
TargetCard target = new TargetCardInExile(0, result, StaticFilters.FILTER_CARD, CardUtil.getExileZoneId(game, source));
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class CavalierOfThornsEffect 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, 5));
if (cards.isEmpty()) {
return true;
}
controller.revealCards(source, cards, game);
TargetCard target = new TargetCard(1, 1, Zone.LIBRARY, filter);
if (cards.getCards(game).stream().anyMatch(card1 -> card1.isLand(game)) && controller.choose(Outcome.PutCardInPlay, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class CommuneWithTheGodsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
if (!cards.isEmpty()) {
FilterCard filterPutInHand = new FilterCard("creature or enchantment card to put in hand");
filterPutInHand.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate()));
controller.revealCards(source, cards, game);
if (cards.count(filterPutInHand, source.getSourceId(), source.getControllerId(), game) > 0) {
TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, filterPutInHand);
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class DakkonShadowSlayerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
boolean inGrave = player.getGraveyard().count(StaticFilters.FILTER_CARD_ARTIFACT, game) > 0;
if (!inGrave && player.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game) < 1) {
return false;
}
TargetCard target;
if (!inGrave || player.chooseUse(outcome, "Choose a card in your hand or your graveyard?", null, "Hand", "Graveyard", source, game)) {
target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_ARTIFACT);
player.choose(outcome, player.getHand(), target, game);
} else {
target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT);
player.choose(outcome, player.getGraveyard(), target, game);
}
Card card = game.getCard(target.getFirstTarget());
return card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
use of mage.target.TargetCard in project mage by magefree.
the class GiftOfTheGargantuanTarget 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, 4));
TargetCard target = new GiftOfTheGargantuanTarget();
player.choose(outcome, cards, target, game);
Cards toHand = new CardsImpl();
toHand.addAll(target.getTargets());
player.revealCards(source, toHand, game);
player.moveCards(toHand, Zone.HAND, source, game);
cards.removeAll(toHand);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
Aggregations