Search in sources :

Example 11 with Mana

use of mage.Mana in project mage by magefree.

the class EnergyTapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    boolean applied = false;
    Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source));
    if (targetCreature != null) {
        applied = targetCreature.tap(source, game);
        if (applied) {
            player.getManaPool().addMana(new Mana(0, 0, 0, 0, 0, 0, 0, targetCreature.getManaValue()), game, source);
        }
    }
    return applied;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 12 with Mana

use of mage.Mana in project mage by magefree.

the class FoodChainManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int manaCostExiled = 0;
        for (Cost cost : source.getCosts()) {
            if (cost.isPaid() && cost instanceof ExileTargetCost) {
                for (Card card : ((ExileTargetCost) cost).getPermanents()) {
                    manaCostExiled += card.getManaValue();
                }
            }
        }
        ChoiceColor choice = new ChoiceColor();
        if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
            return mana;
        }
        Mana chosen = choice.getMana(manaCostExiled + 1);
        return manaBuilder.setMana(chosen, source, game).build();
    }
    return mana;
}
Also used : Player(mage.players.Player) ExileTargetCost(mage.abilities.costs.common.ExileTargetCost) CreatureCastConditionalMana(mage.abilities.mana.conditional.CreatureCastConditionalMana) ConditionalMana(mage.ConditionalMana) Mana(mage.Mana) ChoiceColor(mage.choices.ChoiceColor) Cost(mage.abilities.costs.Cost) ExileTargetCost(mage.abilities.costs.common.ExileTargetCost) Card(mage.cards.Card)

Example 13 with Mana

use of mage.Mana in project mage by magefree.

the class JeweledAmuletAddManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Permanent jeweledAmulet = game.getPermanent(source.getSourceId());
    Player controller = game.getPlayer(source.getControllerId());
    if (jeweledAmulet != null && controller != null) {
        storedMana = (Mana) game.getState().getValue("JeweledAmulet" + source.getSourceId().toString());
        if (storedMana != null) {
            return storedMana.copy();
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent)

Example 14 with Mana

use of mage.Mana in project mage by magefree.

the class JeganthaTheWellspringManaCondition method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    mana.add(new JeganthaTheWellspringConditionalMana("W"));
    mana.add(new JeganthaTheWellspringConditionalMana("U"));
    mana.add(new JeganthaTheWellspringConditionalMana("B"));
    mana.add(new JeganthaTheWellspringConditionalMana("R"));
    mana.add(new JeganthaTheWellspringConditionalMana("G"));
    return mana;
}
Also used : ConditionalMana(mage.ConditionalMana) Mana(mage.Mana)

Example 15 with Mana

use of mage.Mana in project mage by magefree.

the class MadScienceFairProjectEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (controller == null || player == null) {
        return false;
    }
    int amount = controller.rollDice(outcome, source, game, 6);
    Mana mana = amount <= 3 ? Mana.ColorlessMana(1) : ManaChoice.chooseAnyColor(player, game, 1);
    player.getManaPool().addMana(mana, game, source);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Mana(mage.Mana)

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