Search in sources :

Example 46 with TargetCardInYourGraveyard

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

the class RecallEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        // Discard X cards
        Cards cardsDiscarded = controller.discard(source.getManaCostsToPay().getX(), false, false, source, game);
        if (!cardsDiscarded.isEmpty()) {
            // then return a card from your graveyard to your hand for each card discarded this way
            TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard());
            target.setNotTarget(true);
            target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game);
            controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 47 with TargetCardInYourGraveyard

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

the class SoulshiftAbility method trigger.

@Override
public void trigger(Game game, UUID controllerId, GameEvent triggeringEvent) {
    this.getTargets().clear();
    int intValue = amount.calculate(game, this, null);
    FilterCard filter = new FilterCard("Spirit card with mana value " + intValue + " or less from your graveyard");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, intValue + 1));
    filter.add(SubType.SPIRIT.getPredicate());
    this.addTarget(new TargetCardInYourGraveyard(filter));
    // To change body of generated methods, choose Tools | Templates.
    super.trigger(game, controllerId, triggeringEvent);
}
Also used : FilterCard(mage.filter.FilterCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 48 with TargetCardInYourGraveyard

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

the class FallOfTheThranReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Map<UUID, Set<Card>> toBattlefield = new LinkedHashMap<>();
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(2, 2, StaticFilters.FILTER_CARD_LAND);
                target.setNotTarget(true);
                target.setTargetController(playerId);
                if (target.canChoose(source.getSourceId(), playerId, game)) {
                    player.choose(outcome, target, source.getSourceId(), game);
                    if (target.getTargets().size() == 2) {
                        toBattlefield.put(playerId, new CardsImpl(target.getTargets()).getCards(game));
                    }
                }
            }
        }
        for (Map.Entry<UUID, Set<Card>> entry : toBattlefield.entrySet()) {
            Player player = game.getPlayer(entry.getKey());
            if (player != null) {
                player.moveCards(entry.getValue(), Zone.BATTLEFIELD, source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Set(java.util.Set) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CardsImpl(mage.cards.CardsImpl) LinkedHashMap(java.util.LinkedHashMap)

Example 49 with TargetCardInYourGraveyard

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

the class GraveBirthingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (opponent != null) {
        Target target = new TargetCardInYourGraveyard();
        target.setNotTarget(true);
        opponent.chooseTarget(outcome, target, source, game);
        Card card = game.getCard(target.getFirstTarget());
        opponent.moveCards(card, Zone.EXILED, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card)

Example 50 with TargetCardInYourGraveyard

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

the class GraveConsequencesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Player> players = game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).collect(Collectors.toList());
    for (Player player : players) {
        TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE);
        target.setNotTarget(true);
        player.choose(outcome, target, source.getSourceId(), game);
        Cards cards = new CardsImpl(target.getTargets());
        if (!cards.isEmpty()) {
            player.moveCards(cards, Zone.EXILED, source, game);
        }
    }
    for (Player player : players) {
        if (!player.getGraveyard().isEmpty()) {
            player.loseLife(player.getLife(), game, source, false);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

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