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);
}
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;
}
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;
}
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();
}
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;
}
Aggregations