Search in sources :

Example 51 with TargetCardInYourGraveyard

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

the class GraveEndeavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    List<Integer> results = player.rollDice(outcome, source, game, 10, 2, 0);
    int firstResult = results.get(0);
    int secondResult = results.get(1);
    int first, second;
    if (firstResult != secondResult && player.chooseUse(outcome, "Choose a number of +1/+1 counters to put on the creature you return", "The other number will be the amount of life your opponents lose and you gain", "" + firstResult, "" + secondResult, source, game)) {
        first = firstResult;
        second = secondResult;
    } else {
        first = secondResult;
        second = firstResult;
    }
    if (player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) {
        TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
        target.setNotTarget(true);
        player.choose(outcome, target, source.getControllerId(), game);
        if (target.getFirstTarget() != null) {
            new ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(CounterType.P1P1.createInstance(first)).setTargetPointer(new FixedTarget(target.getFirstTarget(), game)).apply(game, source);
        }
    }
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null) {
            continue;
        }
        opponent.loseLife(second, game, source, false);
    }
    player.gainLife(second, game, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldWithCounterTargetEffect) Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID)

Example 52 with TargetCardInYourGraveyard

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

the class HauntingVoyageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    SubType chosenSubType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    if (controller != null && chosenSubType != null) {
        Set<Card> cardsToBattlefield = new LinkedHashSet<>();
        if (!ForetoldCondition.instance.apply(game, source)) {
            TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 2, new FilterBySubtypeCard(chosenSubType), true);
            controller.chooseTarget(outcome, target, source, game);
            for (UUID cardId : target.getTargets()) {
                Card card = game.getCard(cardId);
                if (card != null) {
                    cardsToBattlefield.add(card);
                }
            }
        } else {
            for (UUID cardId : controller.getGraveyard()) {
                Card card = game.getCard(cardId);
                if (card != null && card.hasSubtype(chosenSubType, game)) {
                    cardsToBattlefield.add(card);
                }
            }
        }
        if (!cardsToBattlefield.isEmpty()) {
            controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
            return true;
        }
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) SubType(mage.constants.SubType) FilterBySubtypeCard(mage.filter.common.FilterBySubtypeCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) FilterBySubtypeCard(mage.filter.common.FilterBySubtypeCard) Card(mage.cards.Card)

Example 53 with TargetCardInYourGraveyard

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

the class HarnessTheStormEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (super.checkTrigger(event, game)) {
        CastFromHandWatcher watcher = game.getState().getWatcher(CastFromHandWatcher.class);
        if (watcher != null && watcher.spellWasCastFromHand(event.getSourceId())) {
            Spell spell = game.getState().getStack().getSpell(event.getSourceId());
            if (spell != null) {
                FilterCard filterCard = new FilterCard("a card named " + spell.getName() + " in your graveyard");
                filterCard.add(new NamePredicate(spell.getName()));
                this.getTargets().clear();
                this.getTargets().add(new TargetCardInYourGraveyard(filterCard));
                return true;
            }
        }
    }
    return false;
}
Also used : CastFromHandWatcher(mage.watchers.common.CastFromHandWatcher) FilterCard(mage.filter.FilterCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterInstantOrSorcerySpell(mage.filter.common.FilterInstantOrSorcerySpell) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Example 54 with TargetCardInYourGraveyard

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

the class IncarnationTechniqueEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.millCards(5, source, game);
    TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
    target.setNotTarget(true);
    if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
        return true;
    }
    player.choose(outcome, target, source.getSourceId(), game);
    Card card = game.getCard(target.getFirstTarget());
    if (card != null) {
        player.moveCards(card, Zone.BATTLEFIELD, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 55 with TargetCardInYourGraveyard

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

the class MakeAWishEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || player.getGraveyard().isEmpty()) {
        return false;
    }
    TargetCard target = new TargetCardInYourGraveyard(Math.min(player.getGraveyard().size(), 2), StaticFilters.FILTER_CARD);
    target.setNotTarget(true);
    target.setRandom(true);
    target.chooseTarget(outcome, player.getId(), source, game);
    return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) 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