Search in sources :

Example 41 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl 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 42 with ManaCostsImpl

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

the class ManaPoolTest method test_MultipleMana_OneXAbility.

@Test
public void test_MultipleMana_OneXAbility() {
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
    // 
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl("{X}"));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("damage X", playerA, ability);
    // make mana
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4);
    // use for ability
    // showAvailableAbilities("before ability", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{X}:", playerB);
    setChoice(playerA, "X=3");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 3);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget) Test(org.junit.Test)

Example 43 with ManaCostsImpl

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

the class ManaPoolTest method test_ConditionalMana_OneXPart.

@Test
public void test_ConditionalMana_OneXPart() {
    // {R}
    addCard(Zone.HAND, playerA, "Lightning Bolt");
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // 
    addCustomCardWithAbility("add 10", playerA, new SimpleManaAbility(Zone.ALL, new AddConditionalManaEffect(Mana.RedMana(10), new SimpleActivatedAbilityManaBuilder()), new ManaCostsImpl("")));
    // 
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl(""));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("damage X", playerA, ability);
    // 
    // {X}: Counter target spell
    ability = new SimpleActivatedAbility(Zone.ALL, new CounterUnlessPaysEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl("{X}"));
    ability.addTarget(new TargetSpell());
    addCustomCardWithAbility("counter until pay X", playerB, ability);
    addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
    // make mana for spell
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana spell", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 1);
    // cast spell
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
    // make mana for pay X to prevent
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Add {R}");
    checkManaPool("mana prevent", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10);
    // counter by X=3
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{X}: Counter");
    setChoice(playerB, "X=3");
    addTarget(playerB, "Lightning Bolt");
    // pay to prevent
    // pay 3 to prevent counter
    setChoice(playerA, true);
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 + 1 - 1 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 3);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) Ability(mage.abilities.Ability) AddConditionalManaEffect(mage.abilities.effects.mana.AddConditionalManaEffect) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) SimpleActivatedAbilityManaBuilder(mage.abilities.mana.builder.common.SimpleActivatedAbilityManaBuilder) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetSpell(mage.target.TargetSpell) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget) Test(org.junit.Test)

Example 44 with ManaCostsImpl

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

the class HornOfPlentyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player caster = game.getPlayer(targetPointer.getFirst(game, source));
    if (caster != null) {
        if (caster.chooseUse(Outcome.DrawCard, "Pay {1} to draw a card at the beginning of the next end step?", source, game)) {
            Cost cost = new ManaCostsImpl("{1}");
            if (cost.pay(source, game, source, caster.getId(), false, null)) {
                Effect effect = new DrawCardTargetEffect(1);
                effect.setTargetPointer(new FixedTarget(caster.getId()));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 45 with ManaCostsImpl

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

the class LazavTheMultifariousCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(new LazavTheMultifariousEffect(), new ManaCostsImpl("{X}"));
    ability.setTargetAdjuster(LazavTheMultifariousAdjuster.instance);
    blueprint.getAbilities().add(ability);
    blueprint.setName("Lazav, the Multifarious");
    blueprint.addSuperType(SuperType.LEGENDARY);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)98 Player (mage.players.Player)63 Permanent (mage.game.permanent.Permanent)33 Ability (mage.abilities.Ability)26 Cost (mage.abilities.costs.Cost)26 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)23 UUID (java.util.UUID)16 Card (mage.cards.Card)16 ManaCosts (mage.abilities.costs.mana.ManaCosts)15 SpellAbility (mage.abilities.SpellAbility)14 FixedTarget (mage.target.targetpointer.FixedTarget)13 Test (org.junit.Test)13 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)12 ManaCost (mage.abilities.costs.mana.ManaCost)11 ContinuousEffect (mage.abilities.effects.ContinuousEffect)8 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)7 TargetPermanent (mage.target.TargetPermanent)7 MageObjectReference (mage.MageObjectReference)6 Effect (mage.abilities.effects.Effect)6 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)6