Search in sources :

Example 86 with TargetCardInYourGraveyard

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

the class CharmbreakerDevilsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || player.getGraveyard().count(StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY, game) < 1) {
        return false;
    }
    TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY);
    target.setRandom(true);
    target.setNotTarget(true);
    target.chooseTarget(outcome, player.getId(), source, game);
    Card card = game.getCard(target.getFirstTarget());
    return card != null && player.moveCards(card, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 87 with TargetCardInYourGraveyard

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

the class ConcoctEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.surveil(3, source, game);
    Target target = new TargetCardInYourGraveyard(filter);
    target.setNotTarget(true);
    if (player.choose(outcome, target, source.getSourceId(), game)) {
        Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 88 with TargetCardInYourGraveyard

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

the class DarkSupplicantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    FilterCard filter = new FilterCard("card named Scion of Darkness");
    filter.add(new NamePredicate("Scion of Darkness"));
    if (controller == null) {
        return false;
    }
    Card selectedCard = null;
    // Graveyard check
    if (controller.chooseUse(Outcome.Benefit, "Search your graveyard for Scion of Darkness?", source, game)) {
        TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter, true);
        if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
            selectedCard = game.getCard(target.getFirstTarget());
        }
    }
    // Hand check
    if (selectedCard == null && controller.chooseUse(Outcome.Benefit, "Search your hand for Scion of Darkness?", source, game)) {
        TargetCardInHand target = new TargetCardInHand(0, 1, filter);
        if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) {
            if (!target.getTargets().isEmpty()) {
                selectedCard = game.getCard(target.getFirstTarget());
            }
        }
    }
    // Library check
    boolean librarySearched = false;
    if (selectedCard == null && controller.chooseUse(Outcome.Benefit, "Search your library for Scion of Darkness?", source, game)) {
        librarySearched = true;
        TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
        if (controller.searchLibrary(target, source, game)) {
            if (!target.getTargets().isEmpty()) {
                selectedCard = game.getCard(target.getFirstTarget());
            }
        }
    }
    if (selectedCard != null) {
        controller.moveCards(selectedCard, Zone.BATTLEFIELD, source, game);
    }
    if (librarySearched) {
        controller.shuffleLibrary(source, game);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

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