Search in sources :

Example 56 with TargetCardInGraveyard

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

the class DeathbonnetHulkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard target = new TargetCardInGraveyard(0, 1);
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    boolean flag = card.isCreature(game);
    player.moveCards(card, Zone.EXILED, source, game);
    if (!flag) {
        return true;
    }
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent != null) {
        permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Permanent(mage.game.permanent.Permanent) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 57 with TargetCardInGraveyard

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

the class DanseMacabreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int toughness = 0;
    Cards cards = new CardsImpl();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) {
            continue;
        }
        TargetPermanent target = new TargetPermanent(filter);
        target.setNotTarget(true);
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent == null) {
            continue;
        }
        if (source.isControlledBy(playerId)) {
            toughness += permanent.getToughness().getValue();
        }
        cards.add(permanent);
        permanent.sacrifice(source, game);
    }
    int result = controller.rollDice(outcome, source, game, 20) + toughness;
    cards.retainZone(Zone.GRAVEYARD, game);
    if (cards.isEmpty()) {
        return true;
    }
    FilterCard filterCard = new FilterCard("card put into a graveyard this way");
    filterCard.add(Predicates.or(cards.stream().map(cardId -> new CardIdPredicate(cardId)).collect(Collectors.toSet())));
    TargetCardInGraveyard target;
    if (result >= 15) {
        target = new TargetCardInGraveyard(0, 2, filterCard);
    } else if (result > 0) {
        target = new TargetCardInGraveyard(filterCard);
    } else {
        return true;
    }
    target.setNotTarget(true);
    controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
    controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) Predicates(mage.filter.predicate.Predicates) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) FilterPermanent(mage.filter.FilterPermanent) Collectors(java.util.stream.Collectors) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) Ability(mage.abilities.Ability) TokenPredicate(mage.filter.predicate.permanent.TokenPredicate) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 58 with TargetCardInGraveyard

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

the class DiregrafHordeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (!new ZombieDecayedToken().putOntoBattlefield(2, game, source, source.getControllerId())) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ExileTargetEffect(), false, "exile up to two target cards from graveyards");
    ability.addTarget(new TargetCardInGraveyard(0, 2));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ZombieDecayedToken(mage.game.permanent.token.ZombieDecayedToken) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 59 with TargetCardInGraveyard

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

the class DimirDoppelgangerCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
    ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)59 Player (mage.players.Player)54 Card (mage.cards.Card)32 FilterCard (mage.filter.FilterCard)24 OwnerIdPredicate (mage.filter.predicate.card.OwnerIdPredicate)23 UUID (java.util.UUID)21 FilterCreatureCard (mage.filter.common.FilterCreatureCard)17 Permanent (mage.game.permanent.Permanent)14 Target (mage.target.Target)14 TargetCard (mage.target.TargetCard)12 MageObject (mage.MageObject)8 Ability (mage.abilities.Ability)6 CardsImpl (mage.cards.CardsImpl)6 CardIdPredicate (mage.filter.predicate.mageobject.CardIdPredicate)5 TargetPlayer (mage.target.TargetPlayer)5 HashSet (java.util.HashSet)4 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)4 Cards (mage.cards.Cards)4 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)4 TargetOpponent (mage.target.common.TargetOpponent)4