Search in sources :

Example 46 with ManaCostsImpl

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

the class NilsDisciplineEnforcerEffect method getManaCostToPay.

@Override
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
    Permanent permanent = game.getPermanent(event.getSourceId());
    if (permanent == null) {
        return null;
    }
    int count = permanent.getCounters(game).keySet().stream().mapToInt(permanent.getCounters(game)::getCount).sum();
    if (count < 1) {
        return null;
    }
    return new ManaCostsImpl("{" + count + '}');
}
Also used : FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 47 with ManaCostsImpl

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

the class RootwaterThiefEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player damagedPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller == null || damagedPlayer == null) {
        return false;
    }
    String message = "Pay {2} to exile a card from damaged player's library?";
    Cost cost = new ManaCostsImpl("{2}");
    if (controller.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source, controller.getId(), false, null)) {
        TargetCardInLibrary target = new TargetCardInLibrary();
        if (controller.searchLibrary(target, source, game, damagedPlayer.getId())) {
            if (!target.getTargets().isEmpty()) {
                Card card = damagedPlayer.getLibrary().remove(target.getFirstTarget(), game);
                if (card != null) {
                    controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.LIBRARY, true);
                }
            }
        }
        damagedPlayer.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Card(mage.cards.Card)

Example 48 with ManaCostsImpl

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

the class StenchOfEvilEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, game)) {
        UUID landControllerId = land.getControllerId();
        if (land.destroy(source, game, false)) {
            Cost cost = new ManaCostsImpl("{2}");
            Player landController = game.getPlayer(landControllerId);
            if (landController != null && cost.canPay(source, source, landControllerId, game) && !cost.pay(source, game, source, landControllerId, false)) {
                landController.damage(1, source.getSourceId(), source, game);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 49 with ManaCostsImpl

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

the class VaporousDjinnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cost cost = new ManaCostsImpl("{U}{U}");
        String message = "Pay {U}{U} to prevent this permanent from phasing out?";
        if (!(controller.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source, controller.getId(), false, null))) {
            permanent.phaseOut(game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 50 with ManaCostsImpl

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

the class ManaPoolTest method test_ConditionalMana_OneXSpell.

@Test
public void test_ConditionalMana_OneXSpell() {
    addCustomCardWithAbility("add 10", playerA, new SimpleActivatedAbility(Zone.ALL, new AddConditionalManaEffect(Mana.RedMana(10), new InstantOrSorcerySpellManaBuilder()), new ManaCostsImpl("")));
    // {X}{R}{R}
    addCard(Zone.HAND, playerA, "Volcanic Geyser");
    // make mana
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Add {R}");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10);
    // use for spell
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB);
    setChoice(playerA, "X=1");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 1);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : AddConditionalManaEffect(mage.abilities.effects.mana.AddConditionalManaEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) InstantOrSorcerySpellManaBuilder(mage.abilities.mana.builder.common.InstantOrSorcerySpellManaBuilder) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

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