Search in sources :

Example 36 with Mana

use of mage.Mana in project mage by magefree.

the class BasicManaEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    if (game != null && game.inCheckPlayableState() && netAmount != null) {
        // calculate the maximum available mana
        int count = netAmount.calculate(game, source, this);
        // Copy to get condition
        Mana computedMana = manaTemplate.copy();
        if (count > 0) {
            if (manaTemplate.getBlack() > 0) {
                computedMana.setBlack(count * manaTemplate.getBlack());
            }
            if (manaTemplate.getBlue() > 0) {
                computedMana.setBlue(count * manaTemplate.getBlue());
            }
            if (manaTemplate.getGreen() > 0) {
                computedMana.setGreen(count * manaTemplate.getGreen());
            }
            if (manaTemplate.getRed() > 0) {
                computedMana.setRed(count * manaTemplate.getRed());
            }
            if (manaTemplate.getWhite() > 0) {
                computedMana.setWhite(count * manaTemplate.getWhite());
            }
            if (manaTemplate.getColorless() > 0) {
                computedMana.setColorless(count * manaTemplate.getColorless());
            }
            if (manaTemplate.getAny() > 0) {
                throw new IllegalArgumentException("BasicManaEffect does not support {Any} mana!");
            }
            if (manaTemplate.getGeneric() > 0) {
                computedMana.setGeneric(count * manaTemplate.getGeneric());
            }
        }
        return new ArrayList<>(Arrays.asList(computedMana));
    }
    return super.getNetMana(game, source);
}
Also used : Mana(mage.Mana) ConditionalMana(mage.ConditionalMana) ArrayList(java.util.ArrayList)

Example 37 with Mana

use of mage.Mana in project mage by magefree.

the class DynamicManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana computedMana = new Mana();
    if (game == null) {
        return computedMana;
    }
    int count = amount.calculate(game, source, this);
    if (baseMana.getBlack() > 0) {
        computedMana.setBlack(count);
    } else if (baseMana.getBlue() > 0) {
        computedMana.setBlue(count);
    } else if (baseMana.getGreen() > 0) {
        computedMana.setGreen(count);
    } else if (baseMana.getRed() > 0) {
        computedMana.setRed(count);
    } else if (baseMana.getWhite() > 0) {
        computedMana.setWhite(count);
    } else if (baseMana.getColorless() > 0) {
        computedMana.setColorless(count);
    } else if (baseMana.getAny() > 0) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null && count > 0) {
            if (oneChoice || count == 1) {
                ChoiceColor choice = new ChoiceColor(true);
                controller.choose(outcome, choice, game);
                if (choice.getChoice() == null) {
                    return computedMana;
                }
                computedMana.add(choice.getMana(count));
            } else {
                List<String> manaStrings = new ArrayList<>(5);
                manaStrings.add("W");
                manaStrings.add("U");
                manaStrings.add("B");
                manaStrings.add("R");
                manaStrings.add("G");
                List<Integer> choices = controller.getMultiAmount(this.outcome, manaStrings, 0, count, MultiAmountType.MANA, game);
                computedMana.add(new Mana(choices.get(0), choices.get(1), choices.get(2), choices.get(3), choices.get(4), 0, 0, 0));
            }
        }
    } else {
        computedMana.setGeneric(count);
    }
    return computedMana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ArrayList(java.util.ArrayList) ChoiceColor(mage.choices.ChoiceColor)

Example 38 with Mana

use of mage.Mana in project mage by magefree.

the class CatalystStoneCostRaiseEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    Player controller = game.getPlayer(abilityToModify.getControllerId());
    if (controller != null) {
        Mana mana = abilityToModify.getManaCostsToPay().getMana();
        int reduceMax = mana.getGeneric();
        if (reduceMax > 2) {
            reduceMax = 2;
        }
        if (reduceMax > 0) {
            int reduce;
            if (game.inCheckPlayableState()) {
                reduce = reduceMax;
            } else {
                ChoiceImpl choice = new ChoiceImpl(true);
                Set<String> set = new LinkedHashSet<>();
                for (int i = 0; i <= reduceMax; i++) {
                    set.add(String.valueOf(i));
                }
                choice.setChoices(set);
                choice.setMessage("Reduce flashback cost");
                if (controller.choose(Outcome.Benefit, choice, game)) {
                    reduce = Integer.parseInt(choice.getChoice());
                } else {
                    return false;
                }
            }
            CardUtil.reduceCost(abilityToModify, reduce);
        }
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Mana(mage.Mana) ChoiceImpl(mage.choices.ChoiceImpl)

Example 39 with Mana

use of mage.Mana in project mage by magefree.

the class GauntletOfPowerManaEffect2 method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    if (game == null) {
        return new Mana();
    }
    Permanent land = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    Mana mana = (Mana) getValue("mana");
    if (land == null || mana == null) {
        return new Mana();
    }
    return mana.copy();
}
Also used : Mana(mage.Mana) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent)

Example 40 with Mana

use of mage.Mana in project mage by magefree.

the class GauntletOfPowerManaEffect2 method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    List<Mana> netMana = new ArrayList<>();
    if (game == null) {
        return netMana;
    }
    Mana mana = (Mana) getValue("mana");
    if (mana == null) {
        return netMana;
    }
    netMana.add(mana.copy());
    return netMana;
}
Also used : Mana(mage.Mana) ArrayList(java.util.ArrayList)

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