Search in sources :

Example 6 with TargetCardInYourGraveyard

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;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterHistoricCard(mage.filter.common.FilterHistoricCard) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 7 with TargetCardInYourGraveyard

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();
}
Also used : Target(mage.target.Target) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 8 with TargetCardInYourGraveyard

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;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 9 with TargetCardInYourGraveyard

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;
}
Also used : FilterCard(mage.filter.FilterCard) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ToughnessPredicate(mage.filter.predicate.mageobject.ToughnessPredicate) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) MageObjectReference(mage.MageObjectReference)

Example 10 with TargetCardInYourGraveyard

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;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ArrayList(java.util.ArrayList) TargetPermanent(mage.target.TargetPermanent) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Aggregations

TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)88 Player (mage.players.Player)78 Card (mage.cards.Card)47 FilterCard (mage.filter.FilterCard)38 TargetCard (mage.target.TargetCard)29 CardsImpl (mage.cards.CardsImpl)18 UUID (java.util.UUID)16 Target (mage.target.Target)16 Permanent (mage.game.permanent.Permanent)14 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)11 FilterCreatureCard (mage.filter.common.FilterCreatureCard)10 TargetCardInHand (mage.target.common.TargetCardInHand)10 Cards (mage.cards.Cards)9 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)7 MageObject (mage.MageObject)6 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)5 HashSet (java.util.HashSet)4 ExileFromGraveCost (mage.abilities.costs.common.ExileFromGraveCost)4 OneShotEffect (mage.abilities.effects.OneShotEffect)4 FixedTarget (mage.target.targetpointer.FixedTarget)4