1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-02 11:25:59 -09:00

add mana-generation helpers to ChoiceColor

This commit is contained in:
Neil Gentleman 2016-07-17 23:27:09 -07:00
parent ec87dd4c94
commit 0125f88611
12 changed files with 55 additions and 144 deletions

View file

@ -107,17 +107,7 @@ class CoalitionRelicEffect extends OneShotEffect {
}
player.choose(outcome, choice, game);
}
if (choice.getColor().isBlack()) {
mana.increaseBlack();
} else if (choice.getColor().isBlue()) {
mana.increaseBlue();
} else if (choice.getColor().isRed()) {
mana.increaseRed();
} else if (choice.getColor().isGreen()) {
mana.increaseGreen();
} else if (choice.getColor().isWhite()) {
mana.increaseWhite();
}
choice.increaseMana(mana);
choice.clearChoice();
}
player.getManaPool().addMana(mana, game, source);

View file

@ -140,17 +140,7 @@ class DawnsReflectionManaEffect extends ManaEffect {
while (controller.canRespond() && !controller.choose(Outcome.Benefit, choiceColor, game)) {
}
if (choiceColor.getColor().isBlack()) {
mana.increaseBlack();
} else if (choiceColor.getColor().isBlue()) {
mana.increaseBlue();
} else if (choiceColor.getColor().isRed()) {
mana.increaseRed();
} else if (choiceColor.getColor().isGreen()) {
mana.increaseGreen();
} else if (choiceColor.getColor().isWhite()) {
mana.increaseWhite();
}
choiceColor.increaseMana(mana);
}
controller.getManaPool().addMana(mana, game, source);

View file

@ -30,7 +30,6 @@ package mage.cards.f;
import java.util.UUID;
import mage.ConditionalMana;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.ExileTargetCost;
@ -116,22 +115,11 @@ class FoodChainManaEffect extends ManaEffect {
}
ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.PutManaInPool, choice, game);
ObjectColor chosenColor = choice.getColor();
if (chosenColor == null) {
if (choice.getColor() == null) {
return false;
}
Mana mana = null;
if (chosenColor.isBlack()) {
mana = new FoodChainManaBuilder().setMana(Mana.BlackMana(manaCostExiled + 1), source, game).build();
} else if (chosenColor.isBlue()) {
mana = new FoodChainManaBuilder().setMana(Mana.BlueMana(manaCostExiled + 1), source, game).build();
} else if (chosenColor.isRed()) {
mana = new FoodChainManaBuilder().setMana(Mana.RedMana(manaCostExiled + 1), source, game).build();
} else if (chosenColor.isGreen()) {
mana = new FoodChainManaBuilder().setMana(Mana.GreenMana(manaCostExiled + 1), source, game).build();
} else if (chosenColor.isWhite()) {
mana = new FoodChainManaBuilder().setMana(Mana.WhiteMana(manaCostExiled + 1), source, game).build();
}
Mana chosen = choice.getMana(manaCostExiled + 1);
Mana mana = new FoodChainManaBuilder().setMana(chosen, source, game).build();
if (mana != null) {
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);

View file

@ -135,11 +135,11 @@ class MarketFestivalManaEffect extends ManaEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if(controller != null && sourceObject != null){
int x = 2;
if (controller != null && sourceObject != null) {
int x = 2;
Mana mana = new Mana();
for(int i = 0; i < x; i++){
for (int i = 0; i < x; i++) {
ChoiceColor choiceColor = new ChoiceColor();
if (i == 0) {
choiceColor.setMessage("First mana color for " + sourceObject.getLogName());
@ -152,22 +152,11 @@ class MarketFestivalManaEffect extends ManaEffect {
}
}
if (choiceColor.getColor().isBlack()) {
mana.increaseBlack();
} else if (choiceColor.getColor().isBlue()) {
mana.increaseBlue();
} else if (choiceColor.getColor().isRed()) {
mana.increaseRed();
} else if (choiceColor.getColor().isGreen()) {
mana.increaseGreen();
} else if (choiceColor.getColor().isWhite()) {
mana.increaseWhite();
}
choiceColor.increaseMana(mana);
}
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);
return true;
}
return false;
}

View file

@ -134,17 +134,7 @@ class PlasmCaptureManaEffect extends ManaEffect {
}
}
if (choiceColor.getColor().isBlack()) {
mana.increaseBlack();
} else if (choiceColor.getColor().isBlue()) {
mana.increaseBlue();
} else if (choiceColor.getColor().isRed()) {
mana.increaseRed();
} else if (choiceColor.getColor().isGreen()) {
mana.increaseGreen();
} else if (choiceColor.getColor().isWhite()) {
mana.increaseWhite();
}
choiceColor.increaseMana(mana);
}
player.getManaPool().addMana(mana, game, source);

View file

@ -156,24 +156,13 @@ class VedalkenEngineerEffect extends ManaEffect {
return false;
}
Mana mana = new Mana();
ChoiceColor choiceColor = new ChoiceColor(true);
while (!controller.choose(Outcome.Benefit, choiceColor, game)) {
if (!controller.canRespond()) {
return false;
}
}
if (choiceColor.getColor().isBlack()) {
mana.setBlack(amount);
} else if (choiceColor.getColor().isBlue()) {
mana.setBlue(amount);
} else if (choiceColor.getColor().isRed()) {
mana.setRed(amount);
} else if (choiceColor.getColor().isGreen()) {
mana.setGreen(amount);
} else if (choiceColor.getColor().isWhite()) {
mana.setWhite(amount);
}
Mana mana = choiceColor.getMana(amount);
Mana condMana = manaBuilder.setMana(mana, source, game).build();
checkToFirePossibleEvents(condMana, game, source);
controller.getManaPool().addMana(condMana, game, source);

View file

@ -90,17 +90,7 @@ public class ConditionalManaEffect extends ManaEffect {
return false; // it happens, don't know how
}
if (choice.getColor().isBlack()) {
createdMana = Mana.BlackMana(amount);
} else if (choice.getColor().isBlue()) {
createdMana = Mana.BlueMana(amount);
} else if (choice.getColor().isRed()) {
createdMana = Mana.RedMana(amount);
} else if (choice.getColor().isGreen()) {
createdMana = Mana.GreenMana(amount);
} else if (choice.getColor().isWhite()) {
createdMana = Mana.WhiteMana(amount);
}
createdMana = choice.getMana(amount);
}
mana = createdMana;
}
@ -117,8 +107,7 @@ public class ConditionalManaEffect extends ManaEffect {
}
@Override
public Mana getMana(Game game, Ability source
) {
public Mana getMana(Game game, Ability source) {
Mana mana = null;
if (condition.apply(game, source)) {
mana = effect.getMana();

View file

@ -94,19 +94,10 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
return false;
}
}
Mana mana = null;
if (choice.getColor().isBlack()) {
mana = manaBuilder.setMana(Mana.BlackMana(1), source, game).build();
} else if (choice.getColor().isBlue()) {
mana = manaBuilder.setMana(Mana.BlueMana(1), source, game).build();
} else if (choice.getColor().isRed()) {
mana = manaBuilder.setMana(Mana.RedMana(1), source, game).build();
} else if (choice.getColor().isGreen()) {
mana = manaBuilder.setMana(Mana.GreenMana(1), source, game).build();
} else if (choice.getColor().isWhite()) {
mana = manaBuilder.setMana(Mana.WhiteMana(1), source, game).build();
Mana mana = choice.getMana(1);
if (mana != null) {
mana = manaBuilder.setMana(mana, source, game).build();
}
if (mana != null) {
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);

View file

@ -64,22 +64,10 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
return false;
}
}
int amount = 1;
Mana mana = null;
if (choice.getColor().isBlack()) {
mana = Mana.BlackMana(amount);
} else if (choice.getColor().isBlue()) {
mana = Mana.BlueMana(amount);
} else if (choice.getColor().isRed()) {
mana = Mana.RedMana(amount);
} else if (choice.getColor().isGreen()) {
mana = Mana.GreenMana(amount);
} else if (choice.getColor().isWhite()) {
mana = Mana.WhiteMana(amount);
}
Mana mana = choice.getMana(1);
if (mana != null) {
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
player.getManaPool().addMana(mana, game, source);
return true;
}
}

View file

@ -46,7 +46,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
}
public AddManaOfAnyColorEffect(final int amount) {
super(new Mana(0,0,0,0,0,0, amount, 0));
super(new Mana(0, 0, 0, 0, 0, 0, amount, 0));
this.amount = amount;
this.staticText = new StringBuilder("add ")
.append(CardUtil.numberToText(amount))
@ -75,18 +75,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
if (choice.getColor() == null) {
return false; // it happens, don't know how
}
Mana createdMana = null;
if (choice.getColor().isBlack()) {
createdMana = Mana.BlackMana(amount);
} else if (choice.getColor().isBlue()) {
createdMana = Mana.BlueMana(amount);
} else if (choice.getColor().isRed()) {
createdMana = Mana.RedMana(amount);
} else if (choice.getColor().isGreen()) {
createdMana = Mana.GreenMana(amount);
} else if (choice.getColor().isWhite()) {
createdMana = Mana.WhiteMana(amount);
}
Mana createdMana = choice.getMana(amount);
if (createdMana != null) {
checkToFirePossibleEvents(createdMana, game, source);
controller.getManaPool().addMana(createdMana, game, source);
@ -103,7 +92,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
@Override
public Mana getMana() {
return (new Mana(0,0,0,0,0,0,amount, 0));
return new Mana(0, 0, 0, 0, 0, 0, amount, 0);
}
}

View file

@ -42,7 +42,6 @@ import mage.players.Player;
*/
public class DynamicManaEffect extends BasicManaEffect {
private final Mana computedMana;
private final DynamicValue amount;
private final DynamicValue netAmount;
private String text = null;
@ -73,7 +72,6 @@ public class DynamicManaEffect extends BasicManaEffect {
public DynamicManaEffect(Mana mana, DynamicValue amount, String text, boolean oneChoice, DynamicValue netAmount) {
super(mana);
this.amount = amount;
computedMana = new Mana();
this.text = text;
this.oneChoice = oneChoice;
this.netAmount = netAmount;
@ -81,7 +79,6 @@ public class DynamicManaEffect extends BasicManaEffect {
public DynamicManaEffect(final DynamicManaEffect effect) {
super(effect);
this.computedMana = effect.computedMana.copy();
this.amount = effect.amount.copy();
this.text = effect.text;
this.oneChoice = effect.oneChoice;
@ -99,7 +96,7 @@ public class DynamicManaEffect extends BasicManaEffect {
@Override
public boolean apply(Game game, Ability source) {
computeMana(false, game, source);
Mana computedMana = computeMana(false, game, source);
checkToFirePossibleEvents(computedMana, game, source);
game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source);
return true;
@ -119,7 +116,7 @@ public class DynamicManaEffect extends BasicManaEffect {
}
public Mana computeMana(boolean netMana, Game game, Ability source) {
this.computedMana.clear();
Mana computedMana = new Mana();
int count;
if (netMana && netAmount != null) {
// calculate the maximum available mana
@ -155,17 +152,7 @@ public class DynamicManaEffect extends BasicManaEffect {
}
}
}
if (choiceColor.getColor().isBlack()) {
computedMana.increaseBlack();
} else if (choiceColor.getColor().isBlue()) {
computedMana.increaseBlue();
} else if (choiceColor.getColor().isRed()) {
computedMana.increaseRed();
} else if (choiceColor.getColor().isGreen()) {
computedMana.increaseGreen();
} else if (choiceColor.getColor().isWhite()) {
computedMana.increaseWhite();
}
choiceColor.increaseMana(computedMana);
if (!oneChoice) {
choiceColor.clearChoice();
}

View file

@ -29,6 +29,8 @@
package mage.choices;
import java.util.ArrayList;
import mage.Mana;
import mage.ObjectColor;
/**
@ -90,4 +92,33 @@ public class ChoiceColor extends ChoiceImpl {
return color;
}
public Mana getMana(int amount) {
Mana mana = null;
if (getColor().isBlack()) {
mana = Mana.BlackMana(amount);
} else if (getColor().isBlue()) {
mana = Mana.BlueMana(amount);
} else if (getColor().isRed()) {
mana = Mana.RedMana(amount);
} else if (getColor().isGreen()) {
mana = Mana.GreenMana(amount);
} else if (getColor().isWhite()) {
mana = Mana.WhiteMana(amount);
}
return mana;
}
public void increaseMana(Mana mana) {
if (getColor().isBlack()) {
mana.increaseBlack();
} else if (getColor().isBlue()) {
mana.increaseBlue();
} else if (getColor().isRed()) {
mana.increaseRed();
} else if (getColor().isGreen()) {
mana.increaseGreen();
} else if (getColor().isWhite()) {
mana.increaseWhite();
}
}
}