use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class UrzasTomeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
new DrawCardSourceControllerEffect(1).apply(game, source);
if (controller != null && controller.chooseUse(Outcome.Exile, "Exile a historic card from your graveyard?", source, game)) {
Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard(new FilterHistoricCard()));
if (cost.canPay(source, source, controller.getId(), game)) {
if (cost.pay(source, game, source, controller.getId(), false, null)) {
return true;
}
}
}
if (controller != null) {
controller.discard(1, false, false, source, game);
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class PutOnLibraryTargetEffect method getText.
@Override
public String getText(Mode mode) {
if (this.staticText != null && !this.staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
Target target = mode.getTargets().get(0);
sb.append("put ");
if (target.getMaxNumberOfTargets() == 0 || target.getMaxNumberOfTargets() == Integer.MAX_VALUE) {
sb.append("any number of ");
} else if (target.getMaxNumberOfTargets() != 1 || target.getNumberOfTargets() != 1) {
if (target.getMaxNumberOfTargets() > target.getNumberOfTargets()) {
sb.append("up to ");
}
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(' ');
}
sb.append("target ").append(mode.getTargets().get(0).getTargetName()).append(" on ");
sb.append(onTop ? "top" : "the bottom").append(" of ").append(mode.getTargets().get(0) instanceof TargetCardInYourGraveyard ? "your" : "its owner's").append(" library");
return sb.toString();
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class AcolyteOfAfflictionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.moveCards(player.getLibrary().getTopCards(game, 2), Zone.GRAVEYARD, source, game);
TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true);
if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
return true;
}
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
player.moveCards(card, Zone.HAND, source, game);
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ColfenorTheLastYewTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent == null) {
return false;
}
FilterCard filterCard = new FilterCreatureCard("creature card with toughness less than " + permanent.getToughness().getValue());
filterCard.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, permanent.getToughness().getValue()));
filterCard.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(permanent, game))));
this.getTargets().clear();
this.addTarget(new TargetCardInYourGraveyard(0, 1, filterCard));
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class DarkIntimationsReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<UUID> perms = new ArrayList<>();
filter.add(TargetController.YOU.getControllerPredicate());
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetPermanent target = new TargetPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.discardOne(false, false, source, game);
}
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filterCard);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
controller.moveCards(card, Zone.HAND, source, game);
}
controller.drawCards(1, source, game);
return true;
}
Aggregations