Search in sources :

Example 16 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class FlameblastDragonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCosts cost = new ManaCostsImpl("{X}{R}");
    if (player != null) {
        if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, Flameblast Dragon deals X damage to any target", source, game)) {
            int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
            cost.add(new GenericManaCost(costX));
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                Permanent permanent = game.getPermanent(source.getFirstTarget());
                if (permanent != null) {
                    permanent.damage(costX, source.getSourceId(), source, game, false, true);
                    return true;
                }
                Player targetPlayer = game.getPlayer(source.getFirstTarget());
                if (targetPlayer != null) {
                    targetPlayer.damage(costX, source.getSourceId(), source, game);
                    return true;
                }
                return false;
            }
        }
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Permanent(mage.game.permanent.Permanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 17 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class PowerLeakEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (player == null || permanent == null) {
        return false;
    }
    ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
    String message = "Pay {X} to prevent X damage from " + permanent.getLogName() + "?";
    int xValue = 0;
    if (player.chooseUse(Outcome.Neutral, message, source, game)) {
        xValue = player.announceXMana(0, Integer.MAX_VALUE, "Choose the amount of mana to pay", game, source);
        cost.add(new GenericManaCost(xValue));
        if (cost.pay(source, game, source, player.getId(), false, null)) {
            game.informPlayers(player.getLogName() + " paid {" + xValue + "} for " + permanent.getLogName());
        } else {
            game.informPlayers(player.getLogName() + " didn't pay {X} for " + permanent.getLogName());
        }
    } else {
        game.informPlayers(player.getLogName() + " didn't pay {X} for " + permanent.getLogName());
    }
    PreventDamageByTargetEffect effect = new PreventDamageByTargetEffect(Duration.OneUse, xValue, false);
    if (xValue != 0 && cost.isPaid()) {
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    player.damage(2, source.getSourceId(), source, game);
    effect.discard();
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) PreventDamageByTargetEffect(mage.abilities.effects.common.PreventDamageByTargetEffect) Player(mage.players.Player) TargetEnchantmentPermanent(mage.target.common.TargetEnchantmentPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 18 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class TilonallisSummonerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        ManaCosts cost = new ManaCostsImpl("{X}{R}");
        if (controller.chooseUse(outcome, "Pay " + cost.getText() + "? If you do, you create X 1/1 red Elemental creature tokens that are tapped and attacking.", source, game)) {
            int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
            cost.add(new GenericManaCost(costX));
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                // otherwise you can undo the payment
                controller.resetStoredBookmark(game);
                CreateTokenEffect effect = new CreateTokenEffect(new TilonallisSummonerElementalToken(), costX, true, true);
                effect.apply(game, source);
                Effect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD).setText("exile those tokens unless you have the city's blessing");
                exileEffect.setTargetPointer(new FixedTargets(new CardsImpl(effect.getLastAddedTokenIds()), game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.ANY, new InvertCondition(CitysBlessingCondition.instance)), source);
            }
        }
        return true;
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) TilonallisSummonerElementalToken(mage.game.permanent.token.TilonallisSummonerElementalToken) FixedTargets(mage.target.targetpointer.FixedTargets) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) CitysBlessingHint(mage.abilities.hint.common.CitysBlessingHint) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) InvertCondition(mage.abilities.condition.InvertCondition) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) CardsImpl(mage.cards.CardsImpl) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 19 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class InvokePrejudiceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = true;
    Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
    if (spell != null) {
        CounterUnlessPaysEffect effect = new CounterUnlessPaysEffect(new GenericManaCost(spell.getManaValue()));
        effect.setTargetPointer(getTargetPointer());
        result = effect.apply(game, source);
    }
    return result;
}
Also used : CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Spell(mage.game.stack.Spell)

Example 20 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class NumaJoragaChieftainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ManaCosts cost = new ManaCostsImpl("{X}{X}");
    if (!player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(2 * costX));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, costX, false, ""), false, "distribute " + costX + " +1/+1 counters among any number of target Elves");
    ability.addTarget(new TargetCreaturePermanentAmount(costX, filter));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

GenericManaCost (mage.abilities.costs.mana.GenericManaCost)31 Player (mage.players.Player)15 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)12 Permanent (mage.game.permanent.Permanent)10 ManaCosts (mage.abilities.costs.mana.ManaCosts)7 Ability (mage.abilities.Ability)6 CounterUnlessPaysEffect (mage.abilities.effects.common.CounterUnlessPaysEffect)6 FixedTarget (mage.target.targetpointer.FixedTarget)5 SpellAbility (mage.abilities.SpellAbility)4 PassAbility (mage.abilities.common.PassAbility)4 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)4 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)4 ManaCost (mage.abilities.costs.mana.ManaCost)4 Effect (mage.abilities.effects.Effect)3 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 StackAbility (mage.game.stack.StackAbility)3 ActivatedAbility (mage.abilities.ActivatedAbility)2 RevealTargetFromHandCost (mage.abilities.costs.common.RevealTargetFromHandCost)2 TapSourceCost (mage.abilities.costs.common.TapSourceCost)2 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)2