Search in sources :

Example 1 with TargetOpponentsCreaturePermanent

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

the class CemeteryDesecratorRemoveCountersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
        target.setNotTarget(true);
        controller.choose(outcome, target, source.getSourceId(), game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            int manaValue = card.getManaValue();
            if (controller.moveCards(card, Zone.EXILED, source, game)) {
                ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new CemeteryDesecratorRemoveCountersEffect(manaValue), false, triggerText);
                ability.addTarget(new TargetPermanent());
                Mode mode = new Mode(new BoostTargetEffect(-manaValue, -manaValue, Duration.EndOfTurn).setText("Target creature an opponent controls gets -X/-X until end of turn, where X is the mana value of the exiled card"));
                mode.addTarget(new TargetOpponentsCreaturePermanent());
                ability.addMode(mode);
                game.fireReflexiveTriggeredAbility(ability, source);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Mode(mage.abilities.Mode) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 2 with TargetOpponentsCreaturePermanent

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

the class ViviensInvocationDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
    if (cards.isEmpty()) {
        return true;
    }
    TargetCard target = new TargetCard(Zone.LIBRARY, filter);
    target.setNotTarget(true);
    controller.choose(Outcome.PutCreatureInPlay, cards, target, game);
    Card card = cards.get(target.getFirstTarget(), game);
    if (card == null) {
        controller.putCardsOnBottomOfLibrary(cards, game, source, false);
        return true;
    }
    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        cards.remove(card);
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        controller.putCardsOnBottomOfLibrary(cards, game, source, false);
        return true;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ViviensInvocationDamageEffect(new MageObjectReference(permanent, game)), false, "it deals damage equals to its power to target creature an opponent controls");
    ability.addTarget(new TargetOpponentsCreaturePermanent());
    game.fireReflexiveTriggeredAbility(ability, source);
    controller.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetCard(mage.target.TargetCard) MageObjectReference(mage.MageObjectReference) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 3 with TargetOpponentsCreaturePermanent

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

the class CinderheartGiantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || game.getBattlefield().count(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, source.getSourceId(), source.getControllerId(), game) < 1) {
        return false;
    }
    TargetPermanent target = new TargetOpponentsCreaturePermanent();
    target.setNotTarget(true);
    target.setRandom(true);
    target.chooseTarget(outcome, player.getId(), source, game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    return permanent != null && permanent.damage(7, source.getSourceId(), source, game) > 0;
}
Also used : Player(mage.players.Player) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) TargetPermanent(mage.target.TargetPermanent)

Aggregations

Player (mage.players.Player)3 TargetOpponentsCreaturePermanent (mage.target.common.TargetOpponentsCreaturePermanent)3 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)2 FilterCard (mage.filter.FilterCard)2 Permanent (mage.game.permanent.Permanent)2 TargetPermanent (mage.target.TargetPermanent)2 MageObjectReference (mage.MageObjectReference)1 Mode (mage.abilities.Mode)1 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)1 Card (mage.cards.Card)1 FilterCreatureCard (mage.filter.common.FilterCreatureCard)1 TargetCard (mage.target.TargetCard)1 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)1