use of mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect in project mage by magefree.
the class JandorsRingWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
JandorsRingWatcher watcher = game.getState().getWatcher(JandorsRingWatcher.class);
if (watcher != null) {
UUID cardId = watcher.getLastDrewCard(source.getControllerId());
Card card = game.getCard(cardId);
if (card != null) {
FilterCard filter = new FilterCard(card.getName());
filter.add(new CardIdPredicate(card.getId()));
DiscardCardYouChooseTargetEffect effect = new DiscardCardYouChooseTargetEffect(filter, TargetController.YOU);
if (effect.apply(game, source)) {
// Conditional was already checked, card should be in hand, but if for some weird reason it fails, the card won't be drawn, although the cost will already be paid
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(1, source, game);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect in project mage by magefree.
the class VenarianGlimmerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
FilterCard filter = new FilterNonlandCard();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
Effect effect = new DiscardCardYouChooseTargetEffect(filter, TargetController.ANY);
effect.setTargetPointer(targetPointer);
effect.apply(game, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect in project mage by magefree.
the class MemoryTheftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
new DiscardCardYouChooseTargetEffect(StaticFilters.FILTER_CARD_NON_LAND, TargetController.ANY).apply(game, source);
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller == null || player == null) {
return false;
}
FilterCard filter = new FilterCard("card owned by " + player.getName() + " that has an Adventure");
filter.add(AdventurePredicate.instance);
filter.add(new OwnerIdPredicate(player.getId()));
TargetCard target = new TargetCardInExile(0, 1, filter, null, true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game) || !controller.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
return controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
use of mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect in project mage by magefree.
the class HollowSpecterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer != null && controller != null && controller.chooseUse(Outcome.Benefit, "Pay {X}?", source, game)) {
int payCount = ManaUtil.playerPaysXGenericMana(true, "Hollow Specter", controller, source, game);
if (payCount > 0) {
return new DiscardCardYouChooseTargetEffect(TargetController.ANY, payCount).setTargetPointer(targetPointer).apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect in project mage by magefree.
the class LastRitesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller == null || targetPlayer == null) {
return false;
}
int discardCount = controller.discard(0, Integer.MAX_VALUE, false, source, game).size();
FilterCard filter = new FilterCard((discardCount > 1 ? "" : "a") + " nonland card" + (discardCount > 1 ? "s" : ""));
filter.add(Predicates.not(CardType.LAND.getPredicate()));
Effect effect = new DiscardCardYouChooseTargetEffect(StaticValue.get(discardCount), filter, TargetController.ANY);
effect.setTargetPointer(new FixedTarget(targetPlayer.getId()));
effect.apply(game, source);
return true;
}
Aggregations