use of mage.Mana in project mage by magefree.
the class ChromeMoxManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Permanent permanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (permanent != null && player != null) {
List<UUID> imprinted = permanent.getImprinted();
if (imprinted != null && !imprinted.isEmpty()) {
Card imprintedCard = game.getCard(imprinted.get(0));
if (imprintedCard != null) {
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a mana color");
ObjectColor color = imprintedCard.getColor(game);
if (color.isBlack()) {
choice.getChoices().add("Black");
}
if (color.isRed()) {
choice.getChoices().add("Red");
}
if (color.isBlue()) {
choice.getChoices().add("Blue");
}
if (color.isGreen()) {
choice.getChoices().add("Green");
}
if (color.isWhite()) {
choice.getChoices().add("White");
}
if (!choice.getChoices().isEmpty()) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!player.choose(outcome, choice, game)) {
return mana;
}
}
switch(choice.getChoice()) {
case "Black":
// player.getManaPool().addMana(Mana.BlackMana(1), game, source);
mana.add(Mana.BlackMana(1));
break;
case "Blue":
// player.getManaPool().addMana(Mana.BlueMana(1), game, source);
mana.add(Mana.BlueMana(1));
break;
case "Red":
// player.getManaPool().addMana(Mana.RedMana(1), game, source);
mana.add(Mana.RedMana(1));
break;
case "Green":
// player.getManaPool().addMana(Mana.GreenMana(1), game, source);
mana.add(Mana.GreenMana(1));
break;
case "White":
// player.getManaPool().addMana(Mana.WhiteMana(1), game, source);
mana.add(Mana.WhiteMana(1));
break;
default:
break;
}
}
}
}
}
return mana;
}
use of mage.Mana in project mage by magefree.
the class ConquerorsFlailEffect method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player controller = game.getPlayer(sourceAbility.getControllerId());
int count = 0;
if (controller != null) {
Mana mana = new Mana();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) {
if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) {
mana.increaseBlack();
count++;
}
if (mana.getBlue() == 0 && permanent.getColor(game).isBlue()) {
mana.increaseBlue();
count++;
}
if (mana.getRed() == 0 && permanent.getColor(game).isRed()) {
mana.increaseRed();
count++;
}
if (mana.getGreen() == 0 && permanent.getColor(game).isGreen()) {
mana.increaseGreen();
count++;
}
if (mana.getWhite() == 0 && permanent.getColor(game).isWhite()) {
mana.increaseWhite();
count++;
}
}
}
return count;
}
use of mage.Mana in project mage by magefree.
the class ContaminationReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
ManaEvent manaEvent = (ManaEvent) event;
Mana mana = manaEvent.getMana();
mana.setToMana(Mana.BlackMana(1));
return false;
}
use of mage.Mana in project mage by magefree.
the class EmpoweredAutogeneratorManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
game.getState().processAction(game);
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
return mana;
}
sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source.getControllerId(), source, game);
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
if (counters == 0) {
return mana;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return mana;
}
ChoiceColor choice = new ChoiceColor();
choice.setMessage("Choose a color to add mana of that color");
if (!controller.choose(outcome, choice, game)) {
return mana;
}
if (choice.getChoice() == null) {
return mana;
}
String color = choice.getChoice();
switch(color) {
case "Red":
mana.setRed(counters);
break;
case "Blue":
mana.setBlue(counters);
break;
case "White":
mana.setWhite(counters);
break;
case "Black":
mana.setBlack(counters);
break;
case "Green":
mana.setGreen(counters);
break;
}
return mana;
}
use of mage.Mana in project mage by magefree.
the class RealityTwistEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
TappedForManaEvent manaEvent = (TappedForManaEvent) event;
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = manaEvent.getPermanent();
if (controller == null || permanent == null) {
return false;
}
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a color to produce");
if (permanent.hasSubtype(SubType.PLAINS, game)) {
choice.getChoices().add("Red");
}
if (permanent.hasSubtype(SubType.SWAMP, game)) {
choice.getChoices().add("Green");
}
if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
choice.getChoices().add("White");
}
if (permanent.hasSubtype(SubType.FOREST, game)) {
choice.getChoices().add("Black");
}
String chosenColor;
if (choice.getChoices().size() == 1) {
chosenColor = choice.getChoices().iterator().next();
} else {
controller.choose(Outcome.PutManaInPool, choice, game);
chosenColor = choice.getChoice();
}
if (chosenColor == null) {
return false;
}
Mana mana = manaEvent.getMana();
int amount = mana.count();
switch(chosenColor) {
case "White":
mana.setToMana(Mana.WhiteMana(amount));
break;
case "Black":
mana.setToMana(Mana.BlackMana(amount));
break;
case "Red":
mana.setToMana(Mana.RedMana(amount));
break;
case "Green":
mana.setToMana(Mana.GreenMana(amount));
break;
}
return false;
}
Aggregations