mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
- Fixed AddManaInAnyCombinationEffect and DynamicManaEffect to not let you click Choose until you've selected the correct amount.
- Added an extra constructor to Mana using ColoredManaSymbols and a count so that a for loop isn't needed in AddManaInAnyCombinationEffect.
This commit is contained in:
parent
7566115121
commit
7643ff5597
3 changed files with 38 additions and 25 deletions
|
@ -91,31 +91,38 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
this.flag = mana.flag;
|
||||
}
|
||||
|
||||
|
||||
public Mana(final ColoredManaSymbol color) {
|
||||
this(color, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link Mana} object from {@link ColoredManaSymbol}. Created
|
||||
* {@link Mana} will have a single mana of the passed in
|
||||
* {@link ColoredManaSymbol} color.
|
||||
*
|
||||
* @param color The color to create the {@link Mana} object with.
|
||||
* @param color the color to create the {@link Mana} object with.
|
||||
* @param amount the number of mana to add of the given color
|
||||
*/
|
||||
public Mana(final ColoredManaSymbol color) {
|
||||
|
||||
public Mana(final ColoredManaSymbol color, int amount) {
|
||||
this();
|
||||
Objects.requireNonNull(color, "The passed in ColoredManaSymbol can not be null");
|
||||
switch (color) {
|
||||
case W:
|
||||
white = CardUtil.overflowInc(white, 1);
|
||||
white = CardUtil.overflowInc(white, amount);
|
||||
break;
|
||||
case U:
|
||||
blue = CardUtil.overflowInc(blue, 1);
|
||||
blue = CardUtil.overflowInc(blue, amount);
|
||||
break;
|
||||
case B:
|
||||
black = CardUtil.overflowInc(black, 1);
|
||||
black = CardUtil.overflowInc(black, amount);
|
||||
break;
|
||||
case R:
|
||||
red = CardUtil.overflowInc(red, 1);
|
||||
red = CardUtil.overflowInc(red, amount);
|
||||
break;
|
||||
case G:
|
||||
green = CardUtil.overflowInc(green, 1);
|
||||
green = CardUtil.overflowInc(green, amount);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown mana color: " + color);
|
||||
|
|
|
@ -113,24 +113,30 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
int size = manaSymbols.size();
|
||||
Mana mana = new Mana();
|
||||
List<String> manaStrings = new ArrayList<>(size);
|
||||
for (ColoredManaSymbol coloredManaSymbol : manaSymbols) {
|
||||
manaStrings.add(coloredManaSymbol.toString());
|
||||
}
|
||||
List<Integer> manaList = player.getMultiAmount(this.outcome, manaStrings, 0, amount.calculate(game, source, this), MultiAmountType.MANA, game);
|
||||
for (int i = 0; i < size; i++) {
|
||||
ColoredManaSymbol coloredManaSymbol = manaSymbols.get(i);
|
||||
int amount = manaList.get(i);
|
||||
for (int j = 0; j < amount; j++) {
|
||||
mana.add(new Mana(coloredManaSymbol));
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
// Calculate which mana colors are available as options
|
||||
int size = manaSymbols.size();
|
||||
Mana mana = new Mana();
|
||||
List<String> manaStrings = new ArrayList<>(size);
|
||||
for (ColoredManaSymbol coloredManaSymbol : manaSymbols) {
|
||||
manaStrings.add(coloredManaSymbol.toString());
|
||||
}
|
||||
|
||||
// Ask player for color distribution
|
||||
int manaAmount = amount.calculate(game, source, this);
|
||||
List<Integer> manaList = player.getMultiAmount(this.outcome, manaStrings, manaAmount, manaAmount, MultiAmountType.MANA, game);
|
||||
|
||||
// Covert choices to mana
|
||||
for (int i = 0; i < size; i++) {
|
||||
ColoredManaSymbol coloredManaSymbol = manaSymbols.get(i);
|
||||
int amount = manaList.get(i);
|
||||
|
||||
mana.add(new Mana(coloredManaSymbol, amount));
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -158,7 +158,7 @@ public class DynamicManaEffect extends ManaEffect {
|
|||
manaStrings.add("B");
|
||||
manaStrings.add("R");
|
||||
manaStrings.add("G");
|
||||
List<Integer> choices = controller.getMultiAmount(this.outcome, manaStrings, 0, count, MultiAmountType.MANA, game);
|
||||
List<Integer> choices = controller.getMultiAmount(this.outcome, manaStrings, count, 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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue