Search in sources :

Example 41 with Mana

use of mage.Mana in project mage by magefree.

the class PaleMoonReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ManaEvent manaEvent = (ManaEvent) event;
    Mana mana = manaEvent.getMana();
    mana.setToMana(Mana.ColorlessMana(mana.count()));
    return false;
}
Also used : Mana(mage.Mana) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 42 with Mana

use of mage.Mana in project mage by magefree.

the class SelvalaExplorerReturnedEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    if (game != null) {
        int parleyCount = ParleyCount.getInstance().calculate(game, source, this);
        Player player = getPlayer(game, source);
        if (player != null) {
            player.gainLife(parleyCount, game, source);
        }
        return Mana.GreenMana(parleyCount);
    }
    return new Mana();
}
Also used : Player(mage.players.Player) Mana(mage.Mana)

Example 43 with Mana

use of mage.Mana in project mage by magefree.

the class XenagosExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
        if (x == 0) {
            return false;
        }
        Mana mana = new Mana();
        int redCount = player.getAmount(0, x, "How much <b>RED</b> mana add to pool? (available: " + x + ", another mana goes to <b>GREEN</b>)?", game);
        int greenCount = Math.max(0, x - redCount);
        mana.setRed(redCount);
        mana.setGreen(greenCount);
        if (mana.count() > 0) {
            player.getManaPool().addMana(mana, game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) CreaturesYouControlHint(mage.abilities.hint.common.CreaturesYouControlHint)

Example 44 with Mana

use of mage.Mana in project mage by magefree.

the class ManaUtilTest method testManaAvailEnough.

/**
 * Checks if the given available Mana is enough to pay a given mana cost
 *
 * @param manaCostsToPay
 * @param availablyAny
 * @param available
 * @param expected
 */
private void testManaAvailEnough(String manaCostsToPay, int availablyAny, String available, boolean expected) {
    ManaCost unpaid = new ManaCostsImpl(manaCostsToPay);
    ManaCost costAvailable = new ManaCostsImpl(available);
    Mana manaAvailable = costAvailable.getMana();
    manaAvailable.setAny(availablyAny);
    if (expected) {
        Assert.assertTrue("The available Mana " + costAvailable.getText() + " should be enough to pay the costs " + unpaid.getText(), unpaid.getMana().enough(manaAvailable));
    } else {
        Assert.assertFalse("The available Mana " + costAvailable.getText() + " shouldn't be enough to pay the costs " + unpaid.getText(), unpaid.getMana().enough(manaAvailable));
    }
}
Also used : Mana(mage.Mana) ManaCost(mage.abilities.costs.mana.ManaCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 45 with Mana

use of mage.Mana in project mage by magefree.

the class AssistEffect method getManaOptions.

@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
    ManaOptions options = new ManaOptions();
    if (unpaid.getMana().getGeneric() == 0) {
        // nothing to pay
        return options;
    }
    // AI can't use assist (can't ask another player to help), maybe in teammode it can be enabled, but tests must works all the time
    // Outcome.AIDontUseIt
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && controller.isComputer()) {
        return options;
    }
    // search opponents who can help with generic pay
    int opponentCanPayMax = 0;
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(opponentId);
        if (opponent != null) {
            // basic and pool, but no coditional mana
            ManaOptions availableMana = opponent.getManaAvailable(game);
            // availableMana.addMana(opponent.getManaPool().getMana());
            for (Mana mana : availableMana) {
                if (mana.count() > 0) {
                    opponentCanPayMax = Math.max(opponentCanPayMax, mana.count());
                }
            }
        }
    }
    if (opponentCanPayMax > 0) {
        options.addMana(Mana.GenericMana(Math.min(unpaid.getMana().getGeneric(), opponentCanPayMax)));
    }
    return options;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer) Mana(mage.Mana) UUID(java.util.UUID)

Aggregations

Mana (mage.Mana)147 Player (mage.players.Player)76 ConditionalMana (mage.ConditionalMana)33 Permanent (mage.game.permanent.Permanent)32 ArrayList (java.util.ArrayList)26 Choice (mage.choices.Choice)23 ChoiceColor (mage.choices.ChoiceColor)23 ChoiceImpl (mage.choices.ChoiceImpl)14 TappedForManaEvent (mage.game.events.TappedForManaEvent)14 Card (mage.cards.Card)13 ManaEvent (mage.game.events.ManaEvent)11 ObjectColor (mage.ObjectColor)8 ManaOptions (mage.abilities.mana.ManaOptions)8 FilterMana (mage.filter.FilterMana)8 LinkedHashSet (java.util.LinkedHashSet)7 UUID (java.util.UUID)7 FilterPermanent (mage.filter.FilterPermanent)6 MageObject (mage.MageObject)5 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)5 FilterCard (mage.filter.FilterCard)5