Search in sources :

Example 1 with ExileTargetCost

use of mage.abilities.costs.common.ExileTargetCost 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)

Aggregations

ConditionalMana (mage.ConditionalMana)1 Mana (mage.Mana)1 Cost (mage.abilities.costs.Cost)1 ExileTargetCost (mage.abilities.costs.common.ExileTargetCost)1 CreatureCastConditionalMana (mage.abilities.mana.conditional.CreatureCastConditionalMana)1 Card (mage.cards.Card)1 ChoiceColor (mage.choices.ChoiceColor)1 Player (mage.players.Player)1