Search in sources :

Example 71 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class ScrapTrawlerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
        Permanent permanent = ((ZoneChangeEvent) event).getTarget();
        if (permanent != null && permanent.isControlledBy(this.getControllerId()) && permanent.isArtifact(game)) {
            FilterCard filter = new FilterArtifactCard("artifact card in your graveyard with mana value less than " + permanent.getManaCost().manaValue());
            filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getManaCost().manaValue()));
            TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
            getTargets().clear();
            addTarget(target);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) FilterArtifactCard(mage.filter.common.FilterArtifactCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 72 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class ReturnFromGraveyardToBattlefieldTargetEffect method getText.

@Override
public String getText(Mode mode) {
    if (staticText != null && !staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    boolean yourGrave = !mode.getTargets().isEmpty() && mode.getTargets().get(0) instanceof TargetCardInYourGraveyard;
    sb.append(yourGrave ? "return " : "put ");
    if (mode.getTargets().isEmpty()) {
        sb.append("target creature");
    } else {
        Target target = mode.getTargets().get(0);
        if (target.getMaxNumberOfTargets() > 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());
    }
    sb.append(yourGrave ? " to" : " onto");
    sb.append(" the battlefield");
    if (tapped && attacking) {
        sb.append(" tapped and attacking");
    } else if (tapped) {
        sb.append(" tapped");
    } else if (attacking) {
        sb.append(" attacking");
    }
    if (!yourGrave) {
        sb.append(" under your control");
    }
    return sb.toString();
}
Also used : Target(mage.target.Target) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 73 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class SearchLibraryGraveyardPutOntoBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    Card cardFound = null;
    boolean needShuffle = false;
    if (controller != null && sourceObject != null) {
        if (forceToSearchBoth || controller.chooseUse(outcome, "Search your library for a " + filter.getMessage() + '?', source, game)) {
            TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
            target.clearChosen();
            if (controller.searchLibrary(target, source, game)) {
                if (!target.getTargets().isEmpty()) {
                    cardFound = game.getCard(target.getFirstTarget());
                }
            }
            needShuffle = true;
        }
        if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a " + filter.getMessage() + '?', source, game)) {
            TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true);
            target.clearChosen();
            if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
                if (!target.getTargets().isEmpty()) {
                    cardFound = game.getCard(target.getFirstTarget());
                }
            }
        }
        if (cardFound != null) {
            controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
        }
        if (needShuffle) {
            controller.shuffleLibrary(source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 74 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class EdgarsAwakeningTriggeredAbility method makeAbility.

private static final ReflexiveTriggeredAbility makeAbility() {
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect(), false, "return target creature card from your graveyard to your hand");
    ability.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
    return ability;
}
Also used : ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect)

Example 75 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class GodPharaohsGiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD, true);
    controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
    Card cardChosen = game.getCard(target.getFirstTarget());
    if (cardChosen == null || !controller.moveCards(cardChosen, Zone.EXILED, source, game)) {
        return false;
    }
    // create token and modify all attributes permanently (without game usage)
    EmptyToken token = new EmptyToken();
    CardUtil.copyTo(token).from(cardChosen, game);
    token.removePTCDA();
    token.getPower().modifyBaseValue(4);
    token.getToughness().modifyBaseValue(4);
    token.getColor().setColor(ObjectColor.BLACK);
    token.removeAllCreatureTypes();
    token.addSubType(SubType.ZOMBIE);
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
    if (!permanents.isEmpty()) {
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card) EmptyToken(mage.game.permanent.token.EmptyToken)

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