Some changes to mana handling to handle {C} mana.

This commit is contained in:
LevelX2 2016-01-08 23:25:42 +01:00
parent 7a3c0bb884
commit 782190bac3
185 changed files with 700 additions and 566 deletions

View file

@ -148,8 +148,8 @@ public class ConditionalMana extends Mana implements Serializable {
if (filter.isRed()) {
red = 0;
}
if (filter.isColorless()) {
colorless = 0;
if (filter.isGeneric()) {
generic = 0;
}
}
@ -187,7 +187,7 @@ public class ConditionalMana extends Mana implements Serializable {
white = 0;
break;
case COLORLESS:
colorless = 0;
generic = 0;
break;
}
}
@ -210,7 +210,7 @@ public class ConditionalMana extends Mana implements Serializable {
white += amount;;
break;
case COLORLESS:
colorless += amount;;
generic += amount;;
break;
}
}

View file

@ -29,12 +29,9 @@ package mage;
import java.io.Serializable;
import java.util.Objects;
import mage.constants.ColoredManaSymbol;
import mage.constants.ManaType;
import static mage.constants.ManaType.COLORLESS;
import mage.filter.FilterMana;
import mage.util.Copyable;
import org.apache.log4j.Logger;
@ -51,6 +48,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
protected int blue;
protected int white;
protected int black;
protected int generic;
protected int colorless;
protected int any;
protected boolean flag;
@ -70,16 +68,17 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* @param blue total Blue mana to have.
* @param white total White mana to have.
* @param black total Black mana to have.
* @param colorless total Colorless mana to have.
* @param generic total Generic mana to have.
* @param any total Any mana to have.
* @param colorless total Colorless mana to have.
*/
public Mana(final int red, final int green, final int blue, final int white,
final int black, final int colorless, final int any) {
public Mana(final int red, final int green, final int blue, final int white, final int black, final int generic, final int any, final int colorless) {
this.red = notNegative(red, "Red");
this.green = notNegative(green, "Green");
this.blue = notNegative(blue, "Blue");
this.white = notNegative(white, "White");
this.black = notNegative(black, "Black");
this.generic = notNegative(generic, "Generic");
this.colorless = notNegative(colorless, "Colorless");
this.any = notNegative(any, "Any");
}
@ -97,6 +96,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
this.blue = mana.blue;
this.white = mana.white;
this.black = mana.black;
this.generic = mana.generic;
this.colorless = mana.colorless;
this.any = mana.any;
this.flag = mana.flag;
@ -141,7 +141,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* @return a {@link Mana} object with the passed in {@code num} of Red mana.
*/
public static Mana RedMana(int num) {
return new Mana(notNegative(num, "Red"), 0, 0, 0, 0, 0, 0);
return new Mana(notNegative(num, "Red"), 0, 0, 0, 0, 0, 0, 0);
}
/**
@ -154,7 +154,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* mana.
*/
public static Mana GreenMana(int num) {
return new Mana(0, notNegative(num, "Green"), 0, 0, 0, 0, 0);
return new Mana(0, notNegative(num, "Green"), 0, 0, 0, 0, 0, 0);
}
/**
@ -167,7 +167,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* mana.
*/
public static Mana BlueMana(int num) {
return new Mana(0, 0, notNegative(num, "Blue"), 0, 0, 0, 0);
return new Mana(0, 0, notNegative(num, "Blue"), 0, 0, 0, 0, 0);
}
/**
@ -180,7 +180,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* mana.
*/
public static Mana WhiteMana(int num) {
return new Mana(0, 0, 0, notNegative(num, "White"), 0, 0, 0);
return new Mana(0, 0, 0, notNegative(num, "White"), 0, 0, 0, 0);
}
/**
@ -193,7 +193,20 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* mana.
*/
public static Mana BlackMana(int num) {
return new Mana(0, 0, 0, 0, notNegative(num, "Black"), 0, 0);
return new Mana(0, 0, 0, 0, notNegative(num, "Black"), 0, 0, 0);
}
/**
* Creates a {@link Mana} object with the passed in {@code num} of Generic
* mana. {@code num} can not be a negative value. Negative values will be
* logged and set to 0.
*
* @param num value of Generic mana to create.
* @return a {@link Mana} object with the passed in {@code num} of Generic
* mana.
*/
public static Mana GenericMana(int num) {
return new Mana(0, 0, 0, 0, 0, notNegative(num, "Generic"), 0, 0);
}
/**
@ -206,7 +219,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* mana.
*/
public static Mana ColorlessMana(int num) {
return new Mana(0, 0, 0, 0, 0, notNegative(num, "Colorless"), 0);
return new Mana(0, 0, 0, 0, 0, 0, 0, notNegative(num, "Colorless"));
}
/**
@ -220,6 +233,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
blue += mana.getBlue();
white += mana.getWhite();
black += mana.getBlack();
generic += mana.getGeneric();
colorless += mana.getColorless();
any += mana.getAny();
}
@ -259,6 +273,13 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
black++;
}
/**
* Increases the Generic mana by one.
*/
public void increaseGeneric() {
generic++;
}
/**
* Increases the Colorless mana by one.
*/
@ -277,6 +298,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
blue -= mana.blue;
white -= mana.white;
black -= mana.black;
generic -= mana.generic;
colorless -= mana.colorless;
any -= mana.any;
}
@ -284,12 +306,11 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
/**
* Subtracts the passed in mana values from this instance. The difference
* between this and {@code subtract()} is that if we do not have the
* available colorless mana to pay, we take mana from our colored mana
* pools.
* available generic mana to pay, we take mana from our colored mana pools.
*
* @param mana mana values to subtract
* @throws ArithmeticException thrown if there is not enough available
* colored mana to pay the colorless cost
* colored mana to pay the generic cost
*/
public void subtractCost(final Mana mana) throws ArithmeticException {
red -= mana.red;
@ -298,39 +319,44 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
white -= mana.white;
black -= mana.black;
any -= mana.any;
generic -= mana.generic;
colorless -= mana.colorless;
while (colorless < 0) {
int oldColorless = colorless;
while (generic < 0) {
int oldColorless = generic;
if (red > 0) {
red--;
colorless++;
generic++;
continue;
}
if (green > 0) {
green--;
colorless++;
generic++;
continue;
}
if (blue > 0) {
blue--;
colorless++;
generic++;
continue;
}
if (white > 0) {
white--;
colorless++;
generic++;
continue;
}
if (black > 0) {
black--;
colorless++;
generic++;
}
if (colorless > 0) {
colorless--;
generic++;
}
if (any > 0) {
any--;
colorless++;
generic++;
}
if (oldColorless == colorless) {
if (oldColorless == generic) {
throw new ArithmeticException("Not enough mana to pay colorless");
}
}
@ -342,7 +368,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* @return the total count of all combined mana.
*/
public int count() {
return red + green + blue + white + black + colorless + any;
return red + green + blue + white + black + generic + colorless + any;
}
/**
@ -383,6 +409,9 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
if (filter.isRed()) {
count += red;
}
if (filter.isGeneric()) {
count += generic;
}
if (filter.isColorless()) {
count += colorless;
}
@ -398,6 +427,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
blue = 0;
white = 0;
black = 0;
generic = 0;
colorless = 0;
any = 0;
}
@ -410,8 +440,11 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
@Override
public String toString() {
StringBuilder sbMana = new StringBuilder();
if (colorless > 0) {
sbMana.append("{").append(Integer.toString(colorless)).append("}");
if (generic > 0) {
sbMana.append("{").append(Integer.toString(generic)).append("}");
}
for (int i = 0; i < colorless; i++) {
sbMana.append("{C}");
}
for (int i = 0; i < red; i++) {
sbMana.append("{R}");
@ -490,8 +523,15 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
compare.white = 0;
}
if (compare.colorless < 0) {
int remaining = compare.red + compare.green + compare.black + compare.blue + compare.white + compare.any;
if (compare.colorless + remaining < 0) {
compare.any = compare.getAny() + compare.getColorless();
if (compare.any < 0) {
return false;
}
compare.colorless = 0;
}
if (compare.generic < 0) {
int remaining = compare.red + compare.green + compare.black + compare.blue + compare.white + compare.colorless + compare.any;
if (compare.generic + remaining < 0) {
return false;
}
}
@ -532,17 +572,23 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
compare.any = compare.any - diff;
compare.white = compare.white + diff;
}
if (compare.colorless < 0) {
if (compare.colorless < 0 && compare.any > 0) {
int diff = Math.min(compare.any, Math.abs(compare.colorless));
compare.any = compare.any - diff;
compare.colorless = compare.colorless + diff;
}
if (compare.generic < 0) {
int remaining = 0;
remaining += Math.min(0, compare.red);
remaining += Math.min(0, compare.white);
remaining += Math.min(0, compare.green);
remaining += Math.min(0, compare.black);
remaining += Math.min(0, compare.blue);
remaining += Math.min(0, compare.colorless);
remaining += Math.min(0, compare.any);
if (remaining > 0) {
int diff = Math.min(remaining, Math.abs(compare.colorless));
compare.colorless = compare.colorless + diff;
int diff = Math.min(remaining, Math.abs(compare.generic));
compare.generic = compare.generic + diff;
}
}
Mana needed = new Mana();
@ -564,6 +610,9 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
if (compare.colorless < 0) {
needed.colorless = Math.abs(compare.colorless);
}
if (compare.generic < 0) {
needed.generic = Math.abs(compare.generic);
}
return needed;
}
@ -662,6 +711,25 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
this.black = notNegative(black, "Black");
}
/**
* Returns total Generic mana.
*
* @return total Generic mana.
*/
public int getGeneric() {
return generic;
}
/**
* Sets the total Generic mana. Can not be negative. Negative values will be
* logged and set to 0.
*
* @param generic total Generic mana.
*/
public void setGeneric(int generic) {
this.generic = notNegative(generic, "Generic");
}
/**
* Returns total Colorless mana.
*
@ -734,7 +802,10 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
if (mana.green > 0 && this.green > 0) {
return true;
}
if (mana.colorless > 0 && this.count() > 0) {
if (mana.colorless > 0 && this.colorless > 0) {
return true;
}
if (mana.generic > 0 && this.count() > 0) {
return true;
}
@ -789,7 +860,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
case WHITE:
return white;
case COLORLESS:
return colorless;
return generic + colorless;
}
return 0;
}
@ -847,6 +918,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
this.blue = mana.blue;
this.black = mana.black;
this.colorless = mana.colorless;
this.generic = mana.generic;
}
/**
@ -862,7 +934,8 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
&& this.white == mana.white
&& this.blue == mana.blue
&& this.black == mana.black
&& this.colorless == mana.colorless;
&& this.colorless == mana.colorless
&& this.generic == mana.generic;
}
/**
@ -879,14 +952,15 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
&& this.white >= mana.white
&& this.black >= mana.black
&& this.red >= mana.red
&& (this.colorless >= mana.colorless
|| this.countColored() >= mana.countColored() + mana.colorless);
&& this.colorless >= mana.colorless
&& (this.generic >= mana.generic
|| this.countColored() >= mana.countColored() + mana.generic);
}
/**
* Returns the mana that is more colored or has a greater amount but does
* not contain one less mana in any color but colorless if you call with
* not contain one less mana in any color but generic if you call with
* {1}{W}{R} and {G}{W}{R} you get back {G}{W}{R} if you call with {G}{W}{R}
* and {G}{W}{R} you get back {G}{W}{R} if you call with {G}{W}{B} and
* {G}{W}{R} you get back null
@ -910,6 +984,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|| lessMana.getGreen() > moreMana.getGreen()
|| lessMana.getBlue() > moreMana.getBlue()
|| lessMana.getBlack() > moreMana.getBlack()
|| lessMana.getColorless() > moreMana.getColorless()
|| lessMana.getAny() > moreMana.getAny()) {
return null;
}
@ -970,6 +1045,9 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
if (colorless != mana.colorless) {
return false;
}
if (generic != mana.generic) {
return false;
}
if (any != mana.any) {
return false;
}
@ -984,6 +1062,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
result = 31 * result + blue;
result = 31 * result + white;
result = 31 * result + black;
result = 31 * result + generic;
result = 31 * result + colorless;
result = 31 * result + any;
result = 31 * result + (flag ? 1 : 0);

View file

@ -554,7 +554,7 @@ public abstract class AbilityImpl implements Ability {
xValue = controller.announceXMana(variableManaCost.getMinX(), variableManaCost.getMaxX(), "Announce the value for " + variableManaCost.getText(), game, this);
int amountMana = xValue * variableManaCost.getMultiplier();
StringBuilder manaString = threadLocalBuilder.get();
if (variableManaCost.getFilter() == null || variableManaCost.getFilter().isColorless()) {
if (variableManaCost.getFilter() == null || variableManaCost.getFilter().isGeneric()) {
manaString.append("{").append(amountMana).append("}");
} else {
String manaSymbol = null;

View file

@ -40,8 +40,8 @@ public class GenericManaCost extends ManaCostImpl {
public GenericManaCost(int mana) {
this.mana = mana;
this.cost = Mana.ColorlessMana(mana);
this.options.addMana(Mana.ColorlessMana(mana));
this.cost = Mana.GenericMana(mana);
this.options.addMana(Mana.GenericMana(mana));
}
public GenericManaCost(GenericManaCost manaCost) {

View file

@ -225,13 +225,11 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
return;
}
// attempt to pay colorless costs (not generic) mana costs first
if (pool.getColorless() > 0) {
for (ManaCost cost : this) {
if (!cost.isPaid() && cost instanceof ColorlessManaCost) {
cost.assignPayment(game, ability, pool);
if (pool.count() == 0) {
return;
}
for (ManaCost cost : this) {
if (!cost.isPaid() && cost instanceof ColorlessManaCost) {
cost.assignPayment(game, ability, pool);
if (pool.count() == 0) {
return;
}
}
}

View file

@ -43,9 +43,9 @@ public class MonoHybridManaCost extends ManaCostImpl {
public MonoHybridManaCost(ColoredManaSymbol mana) {
this.mana = mana;
this.cost = new Mana(mana);
this.cost.add(Mana.ColorlessMana(2));
this.cost.add(Mana.GenericMana(2));
addColoredOption(mana);
options.add(Mana.ColorlessMana(2));
options.add(Mana.GenericMana(2));
}
public MonoHybridManaCost(MonoHybridManaCost manaCost) {
@ -125,7 +125,7 @@ public class MonoHybridManaCost extends ManaCostImpl {
public List<Mana> getManaOptions() {
List<Mana> manaList = new ArrayList<>();
manaList.add(new Mana(mana));
manaList.add(Mana.ColorlessMana(2));
manaList.add(Mana.GenericMana(2));
return manaList;
}
}

View file

@ -45,7 +45,7 @@ public class PhyrexianManaCost extends ColoredManaCost {
public PhyrexianManaCost(ColoredManaSymbol mana) {
super(mana);
options.add(Mana.ColorlessMana(0));
options.add(Mana.GenericMana(0));
}
public PhyrexianManaCost(PhyrexianManaCost manaCost) {

View file

@ -44,8 +44,8 @@ public class SnowManaCost extends ManaCostImpl {
}
public SnowManaCost() {
this.cost = Mana.ColorlessMana(1);
this.options.addMana(Mana.ColorlessMana(1));
this.cost = Mana.GenericMana(1);
this.options.addMana(Mana.GenericMana(1));
this.setSourceFilter(filter);
}

View file

@ -106,7 +106,7 @@ public class VariableManaCost extends ManaCostImpl implements VariableCost {
@Override
public void setAmount(int amount) {
payment.setColorless(amount);
payment.setGeneric(amount);
}
@Override

View file

@ -24,7 +24,9 @@ public class AddConditionalColorlessManaEffect extends ManaEffect {
super();
this.amount = amount;
this.manaBuilder = manaBuilder;
staticText = "Add {" + amount + "} to your mana pool. " + manaBuilder.getRule();
staticText = "Add " + String.format(String.format("%%%ds", amount), " ").replace(" ", "{C}")
+ " to your mana pool. " + manaBuilder.getRule();
}
public AddConditionalColorlessManaEffect(final AddConditionalColorlessManaEffect effect) {
@ -54,6 +56,6 @@ public class AddConditionalColorlessManaEffect extends ManaEffect {
}
public Mana getMana() {
return new Mana(0, 0, 0, 0, 0, amount, 0);
return new Mana(0, 0, 0, 0, 0, 0, 0, amount);
}
}

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));
super(new Mana(0,0,0,0,0,0, amount, 0));
this.amount = amount;
this.staticText = new StringBuilder("add ")
.append(CardUtil.numberToText(amount))
@ -103,7 +103,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
@Override
public Mana getMana() {
return (new Mana(0,0,0,0,0,0,amount));
return (new Mana(0,0,0,0,0,0,amount, 0));
}
}

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.Mana;
@ -40,7 +39,6 @@ import mage.players.Player;
*
* @author LevelX2
*/
public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
public AddManaOfAnyTypeProducedEffect() {
@ -78,7 +76,7 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (types.getColorless() > 0) {
if (types.getGeneric() > 0) {
choice.getChoices().add("Colorless");
}
if (choice.getChoices().size() > 0) {
@ -110,10 +108,10 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
case "Colorless":
newMana.setColorless(1);
break;
}
}
checkToFirePossibleEvents(newMana, game, source);
targetController.getManaPool().addMana(newMana, game, source);
}
return true;
}

View file

@ -29,13 +29,13 @@ public class AffinityEffect extends CostModificationEffectImpl {
public boolean apply(Game game, Ability source, Ability abilityToModify) {
SpellAbility spellAbility = (SpellAbility)abilityToModify;
Mana mana = spellAbility.getManaCostsToPay().getMana();
if (mana.getColorless() > 0) {
if (mana.getGeneric() > 0) {
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
int newCount = mana.getColorless() - count;
int newCount = mana.getGeneric() - count;
if (newCount < 0) {
newCount = 0;
}
mana.setColorless(newCount);
mana.setGeneric(newCount);
spellAbility.getManaCostsToPay().load(mana.toString());
return true;
}

View file

@ -171,7 +171,7 @@ public class DynamicManaEffect extends BasicManaEffect {
}
}
} else {
computedMana.setColorless(count);
computedMana.setGeneric(count);
}
return computedMana;
}

View file

@ -81,31 +81,31 @@ public class CommanderManaReplacementEffect extends ReplacementEffectImpl {
Mana mana = ((ManaEvent) event).getMana();
if (mana.getBlack() > 0 && !commanderMana.isBlack()) {
for (int i = 0; i < mana.getBlack(); i++) {
mana.increaseColorless();
mana.increaseGeneric();
}
mana.setBlack(0);
}
if (mana.getBlue() > 0 && !commanderMana.isBlue()) {
for (int i = 0; i < mana.getBlue(); i++) {
mana.increaseColorless();
mana.increaseGeneric();
}
mana.setBlue(0);
}
if (mana.getGreen() > 0 && !commanderMana.isGreen()) {
for (int i = 0; i < mana.getGreen(); i++) {
mana.increaseColorless();
mana.increaseGeneric();
}
mana.setGreen(0);
}
if (mana.getRed() > 0 && !commanderMana.isRed()) {
for (int i = 0; i < mana.getRed(); i++) {
mana.increaseColorless();
mana.increaseGeneric();
}
mana.setRed(0);
}
if (mana.getWhite() > 0 && !commanderMana.isWhite()) {
for (int i = 0; i < mana.getWhite(); i++) {
mana.increaseColorless();
mana.increaseGeneric();
}
mana.setWhite(0);
}

View file

@ -81,7 +81,7 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
public boolean apply(Game game, Ability source, Ability abilityToModify) {
if (upTo) {
Mana mana = abilityToModify.getManaCostsToPay().getMana();
int reduceMax = mana.getColorless();
int reduceMax = mana.getGeneric();
if (reduceMax > 2) {
reduceMax = 2;
}

View file

@ -101,7 +101,7 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
} else {
if (upTo) {
Mana mana = abilityToModify.getManaCostsToPay().getMana();
int reduceMax = mana.getColorless();
int reduceMax = mana.getGeneric();
if (reduceMax > amount) {
reduceMax = amount;
}

View file

@ -122,7 +122,7 @@ public class ConvokeAbility extends SimpleStaticAbility implements AlternateMana
// create filter for possible creatures to tap
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(Predicates.not(new TappedPredicate()));
if (unpaid.getMana().getColorless() == 0) {
if (unpaid.getMana().getGeneric() == 0) {
List<ColorPredicate> colorPredicates = new ArrayList<>();
if (unpaid.getMana().getBlack() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
@ -182,7 +182,7 @@ class ConvokeEffect extends OneShotEffect {
public ConvokeEffect(ManaCost unpaid) {
super(Outcome.Benefit);
this.unpaid = unpaid;
this.staticText = "Convoke (Your creatures can help cast this spell. Each creature you tap while casting this spell pays for {1} or one mana of that creature's color.)";
this.staticText = "Convoke (Your creatures can help cast this spell. Each creature you tap while casting this spell pays for {C} or one mana of that creature's color.)";
}
public ConvokeEffect(final ConvokeEffect effect) {

View file

@ -98,11 +98,11 @@ public class DelveAbility extends SimpleStaticAbility implements AlternateManaPa
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.getGraveyard().size() > 0) {
if (unpaid.getMana().getColorless() > 0 && source.getAbilityType().equals(AbilityType.SPELL)) {
if (unpaid.getMana().getGeneric() > 0 && source.getAbilityType().equals(AbilityType.SPELL)) {
SpecialAction specialAction = new DelveSpecialAction();
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
int unpaidAmount = unpaid.getMana().getColorless();
int unpaidAmount = unpaid.getMana().getGeneric();
if (!controller.getManaPool().isAutoPayment() && unpaidAmount > 1) {
unpaidAmount = 1;
}
@ -157,7 +157,7 @@ class DelveEffect extends OneShotEffect {
List<Card> exiledCards = exileFromGraveCost.getExiledCards();
if (exiledCards.size() > 0) {
ManaPool manaPool = controller.getManaPool();
manaPool.addMana(new Mana(0, 0, 0, 0, 0, exiledCards.size(), 0), game, source);
manaPool.addMana(new Mana(0, 0, 0, 0, 0, 0, 0, exiledCards.size()), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game);
@SuppressWarnings("unchecked")

View file

@ -61,7 +61,7 @@ public class ActivateOncePerTurnManaAbility extends ManaAbility {
public ActivateOncePerTurnManaAbility(Zone zone, AddManaOfAnyColorEffect effect, Cost cost) {
super(zone, effect, cost);
this.netMana.add(new Mana(0,0,0,0,0,0,effect.getAmount()));
this.netMana.add(new Mana(0,0,0,0,0,0,effect.getAmount(), 0));
}
public ActivateOncePerTurnManaAbility(ActivateOncePerTurnManaAbility ability) {

View file

@ -50,7 +50,6 @@ import mage.players.Player;
*
* @author LevelX2
*/
public class AnyColorLandsProduceManaAbility extends ManaAbility {
public AnyColorLandsProduceManaAbility(TargetController targetController) {
@ -68,7 +67,7 @@ public class AnyColorLandsProduceManaAbility extends ManaAbility {
@Override
public List<Mana> getNetMana(Game game) {
return ((AnyColorLandsProduceManaEffect)getEffects().get(0)).getNetMana(game, this);
return ((AnyColorLandsProduceManaEffect) getEffects().get(0)).getNetMana(game, this);
}
}
@ -161,7 +160,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
if (!ability.equals(source) && ability.definesMana()) {
for (Mana netMana: ability.getNetMana(game)) {
for (Mana netMana : ability.getNetMana(game)) {
types.add(netMana);
}
}
@ -170,7 +169,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
return types;
}
public List<Mana> getNetMana(Game game, Ability source) {
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
@ -189,7 +188,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(new Mana(0,0,0,0,0,1,0));
netManas.add(new Mana(0, 0, 0, 0, 0, 0, 0, 1));
}
return netManas;
}

View file

@ -40,7 +40,7 @@ public class AnyColorManaAbility extends ManaAbility {
public AnyColorManaAbility(Cost cost) {
super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), cost);
this.netMana.add(new Mana(0,0,0,0,0,0,1));
this.netMana.add(new Mana(0,0,0,0,0,0,1, 0));
}
public AnyColorManaAbility(final AnyColorManaAbility ability) {

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.mana;
import mage.Mana;
@ -39,7 +38,7 @@ public class ColorlessManaAbility extends BasicManaAbility {
public ColorlessManaAbility() {
super(new BasicManaEffect(Mana.ColorlessMana(1)));
this.netMana.add(new Mana(0,0,0,0,0,1,0));
this.netMana.add(new Mana(0, 0, 0, 0, 0, 0, 0, 1));
}
public ColorlessManaAbility(ColorlessManaAbility ability) {

View file

@ -73,7 +73,7 @@ public class ConditionalAnyColorManaAbility extends ManaAbility {
@Override
public List<Mana> getNetMana(Game game) {
this.netMana.clear();
this.netMana.add(new Mana(0,0,0,0,0,0, amount.calculate(game, this, null)));
this.netMana.add(new Mana(0,0,0,0,0,0, amount.calculate(game, this, null), 0));
return super.getNetMana(game);
}

View file

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.mana;
import mage.Mana;
@ -17,7 +16,6 @@ import mage.constants.Zone;
*
* @author LevelX2
*/
public class ConditionalColorlessManaAbility extends ManaAbility {
public ConditionalColorlessManaAbility(int amount, ConditionalManaBuilder manaBuilder) {
@ -25,8 +23,8 @@ public class ConditionalColorlessManaAbility extends ManaAbility {
}
public ConditionalColorlessManaAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) {
super(Zone.BATTLEFIELD, new AddConditionalColorlessManaEffect(amount, manaBuilder), cost);
this.netMana.add(new Mana(0,0,0,0,0,amount,0));
super(Zone.BATTLEFIELD, new AddConditionalColorlessManaEffect(amount, manaBuilder), cost);
this.netMana.add(new Mana(0, 0, 0, 0, 0, 0, 0, amount));
}
public ConditionalColorlessManaAbility(final ConditionalColorlessManaAbility ability) {

View file

@ -248,11 +248,11 @@ public class ManaOptions extends ArrayList<Mana> {
Mana oldMan = mana.copy();
if (mana.includesMana(cost)) {
// colorless costs can be paid with different colored mana, can lead to different color combinations
if (cost.getColorless() > 0 && cost.getColorless() > mana.getColorless()) {
if (cost.getGeneric() > 0 && cost.getGeneric() > mana.getGeneric()) {
Mana coloredCost = cost.copy();
coloredCost.setColorless(0);
coloredCost.setGeneric(0);
mana.subtract(coloredCost);
for (Mana payCombination : getPossiblePayCombinations(cost.getColorless(), mana)) {
for (Mana payCombination : getPossiblePayCombinations(cost.getGeneric(), mana)) {
Mana newMana = mana.copy();
newMana.subtract(payCombination);
newMana.add(addMana);
@ -319,7 +319,7 @@ public class ManaOptions extends ArrayList<Mana> {
}
}
} else {
payCombinations.add(new Mana(0, 0, 0, 0, 0, number, 0));
payCombinations.add(new Mana(0, 0, 0, 0, 0, 0, 0, number));
}
return payCombinations;
}

View file

@ -5,11 +5,12 @@ package mage.constants;
* @author North
*/
public enum ManaType {
BLACK ("black"),
BLUE ("blue"),
GREEN ("green"),
RED ("red"),
WHITE ("white"),
BLACK("black"),
BLUE("blue"),
GREEN("green"),
RED("red"),
WHITE("white"),
COLORLESS("colorless");
private final String text;
@ -22,4 +23,4 @@ public enum ManaType {
public String toString() {
return text;
}
};
};

View file

@ -39,6 +39,7 @@ public class FilterMana implements Serializable {
protected boolean white;
protected boolean red;
protected boolean blue;
protected boolean generic;
protected boolean colorless;
public FilterMana() {
@ -50,6 +51,7 @@ public class FilterMana implements Serializable {
white = filter.white;
red = filter.red;
blue = filter.blue;
generic = filter.generic;
colorless = filter.colorless;
}
@ -93,6 +95,14 @@ public class FilterMana implements Serializable {
this.blue = blue;
}
public boolean isGeneric() {
return generic;
}
public void setGeneric(boolean generic) {
this.generic = generic;
}
public boolean isColorless() {
return colorless;
}

View file

@ -48,7 +48,7 @@ public class EldraziScionToken extends Token {
subtype.add("Scion");
power = new MageInt(1);
toughness = new MageInt(1);
addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), new SacrificeSourceCost()));
addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GenericMana(1), new SacrificeSourceCost()));
setOriginalExpansionSetCode("BFZ");
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,24 +20,23 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.MageInt;
import mage.Mana;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.mana.SimpleManaAbility;
import mage.constants.CardType;
import mage.constants.Zone;
/**
*

View file

@ -310,7 +310,7 @@ public class ManaPool implements Serializable {
total += item.getGreen();
item.removeGreen();
}
if (filter.isColorless()) {
if (filter.isGeneric()) {
total += item.getColorless();
item.removeColorless();
}
@ -342,9 +342,6 @@ public class ManaPool implements Serializable {
if (filter.isBlue()) {
m.setBlue(test.getBlue());
}
if (filter.isColorless()) {
m.setColorless(test.getColorless());
}
if (filter.isGreen()) {
m.setGreen(test.getGreen());
}
@ -354,12 +351,18 @@ public class ManaPool implements Serializable {
if (filter.isWhite()) {
m.setWhite(test.getWhite());
}
if (filter.isColorless()) {
m.setColorless(test.getColorless());
}
if (filter.isGeneric()) {
m.setGeneric(test.getGeneric());
}
return m;
}
public Mana getAllConditionalMana(Ability ability, Game game, FilterMana filter) {
Mana m = new Mana();
m.setColorless(getConditionalCount(ability, game, filter));
m.setGeneric(getConditionalCount(ability, game, filter));
return m;
}
@ -377,7 +380,7 @@ public class ManaPool implements Serializable {
}
this.manaItems.add(item);
} else {
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getColorless(), source.getSourceId(), source.getOriginalId(), mana.getFlag());
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getGeneric() + mana.getColorless(), source.getSourceId(), source.getOriginalId(), mana.getFlag());
if (emptyOnTurnsEnd) {
item.setDuration(Duration.EndOfTurn);
}

View file

@ -181,7 +181,7 @@ public class ManaPoolItem implements Serializable {
}
public Mana getMana() {
return new Mana(red, green, blue, white, black, colorless, 0);
return new Mana(red, green, blue, white, black, 0, 0, colorless);
}
public int count() {

View file

@ -42,6 +42,7 @@ import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import mage.ConditionalMana;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Abilities;
@ -2532,7 +2533,9 @@ public abstract class PlayerImpl implements Player, Serializable {
ManaOptions availableMana = getManaAvailable(game);
availableMana.addMana(manaPool.getMana());
for (ConditionalMana conditionalMana : manaPool.getConditionalMana()) {
availableMana.addMana(conditionalMana);
}
if (hidden) {
for (Card card : hand.getUniqueCards(game)) {
for (Ability ability : card.getAbilities(game)) { // gets this activated ability from hand? (Morph?)

View file

@ -187,7 +187,7 @@ public class CardUtil {
if (object instanceof ManaCost) {
ManaCost manaCost = (ManaCost) object;
Mana mana = manaCost.getOptions().get(0);
int colorless = mana != null ? mana.getColorless() : 0;
int colorless = mana != null ? mana.getGeneric() : 0;
if (!updated && colorless > 0) {
if ((colorless - reduceCount) > 0) {
int newColorless = colorless - reduceCount;
@ -225,7 +225,7 @@ public class CardUtil {
boolean updated = false;
for (ManaCost manaCost : manaCosts) {
Mana mana = manaCost.getOptions().get(0);
int colorless = mana != null ? mana.getColorless() : 0;
int colorless = mana != null ? mana.getGeneric() : 0;
if (restToReduce != 0 && colorless > 0) {
if ((colorless - restToReduce) > 0) {
int newColorless = colorless - restToReduce;
@ -294,7 +294,7 @@ public class CardUtil {
Mana reduceMana = new Mana();
for (ManaCost manaCost : manaCostsToReduce) {
if (manaCost instanceof MonoHybridManaCost) {
reduceMana.add(Mana.ColorlessMana(2));
reduceMana.add(Mana.GenericMana(2));
} else {
reduceMana.add(manaCost.getMana());
}
@ -303,7 +303,7 @@ public class CardUtil {
// subtract colored mana
for (ManaCost newManaCost : previousCost) {
Mana mana = newManaCost.getMana();
if (!(newManaCost instanceof MonoHybridManaCost) && mana.getColorless() > 0) {
if (!(newManaCost instanceof MonoHybridManaCost) && mana.getGeneric() > 0) {
manaCostToCheckForColorless.add(newManaCost);
continue;
}
@ -371,7 +371,7 @@ public class CardUtil {
if (mana.count() > 0) {
if (newManaCost instanceof MonoHybridManaCost) {
if (mana.count() == 2) {
reduceMana.setColorless(reduceMana.getColorless() - 2);
reduceMana.setGeneric(reduceMana.getGeneric() - 2);
continue;
}
}
@ -385,12 +385,12 @@ public class CardUtil {
if (convertToGeneric) {
reduceAmount = reduceMana.count();
} else {
reduceAmount = reduceMana.getColorless();
reduceAmount = reduceMana.getGeneric();
}
if (reduceAmount > 0) {
for (ManaCost newManaCost : manaCostToCheckForColorless) {
Mana mana = newManaCost.getMana();
if (mana.getColorless() == 0 || reduceAmount == 0) {
if (mana.getGeneric() == 0 || reduceAmount == 0) {
adjustedCost.add(newManaCost);
continue;
}
@ -401,12 +401,12 @@ public class CardUtil {
}
continue;
}
if (mana.getColorless() > 0) {
if (reduceAmount > mana.getColorless()) {
reduceAmount -= mana.getColorless();
mana.setColorless(0);
if (mana.getGeneric() > 0) {
if (reduceAmount > mana.getGeneric()) {
reduceAmount -= mana.getGeneric();
mana.setGeneric(0);
} else {
mana.setColorless(mana.getColorless() - reduceAmount);
mana.setGeneric(mana.getGeneric() - reduceAmount);
reduceAmount = 0;
}
}

View file

@ -152,7 +152,7 @@ public class ManaUtil {
if (countColored.isEmpty()) { // seems there is no colorful mana we can pay for
// try to pay {1}
if (unpaidMana.getColorless() > 0) {
if (unpaidMana.getGeneric() > 0) {
// use any (lets choose first)
return replace(useableAbilities, useableAbilities.values().iterator().next());
}
@ -375,7 +375,7 @@ public class ManaUtil {
if (countColorfull == 0) { // seems there is no colorful mana we can use
// try to pay {1}
if (mana.getColorless() > 0) {
if (mana.getGeneric() > 0) {
// use any (lets choose first)
return replace(useableAbilities, useableAbilities.values().iterator().next());
}