- Synchronize nomenclature of Generic Cost

- Add new Colorless Cost
- Start displaying of colorless mana with new symbol (with backwards compatibility for existing scripts that produce "{1}" instead of "{C}")
This commit is contained in:
Sol
2015-12-29 16:37:22 +00:00
parent 3cc5f6495b
commit ff73eb78eb
31 changed files with 129 additions and 134 deletions

View File

@@ -1297,9 +1297,9 @@ public class AiController {
return null;
}
public CardCollection chooseCardsToDelve(int colorlessCost, CardCollection grave) {
public CardCollection chooseCardsToDelve(int genericCost, CardCollection grave) {
CardCollection toExile = new CardCollection();
int numToExile = Math.min(grave.size(), colorlessCost);
int numToExile = Math.min(grave.size(), genericCost);
for (int i = 0; i < numToExile; i++) {
Card chosen = null;

View File

@@ -348,7 +348,7 @@ public class ComputerUtilMana {
Collection<SpellAbility> saList = null;
if (hasConverge &&
(toPay == ManaCostShard.COLORLESS || toPay == ManaCostShard.X)) {
(toPay == ManaCostShard.GENERIC || toPay == ManaCostShard.X)) {
final int unpaidColors = cost.getUnpaidColors() + cost.getColorsPaid() ^ ManaCostShard.COLORS_SUPERPOSITION;
for (final byte b : ColorSet.fromMask(unpaidColors)) { // try and pay other colors for converge
final ManaCostShard shard = ManaCostShard.valueOf(b);
@@ -358,7 +358,7 @@ public class ComputerUtilMana {
break;
}
}
if (saList == null || saList.isEmpty()) { // failed to converge, revert to paying colorless
if (saList == null || saList.isEmpty()) { // failed to converge, revert to paying generic
saList = sourcesForShards.get(toPay);
hasConverge = false;
}
@@ -666,7 +666,7 @@ public class ComputerUtilMana {
}
else if (m.isAnyMana()) {
byte colorChoice = 0;
if (toPay.isOr2Colorless())
if (toPay.isOr2Generic())
colorChoice = toPay.getColorMask();
else {
for (byte c : MagicColor.WUBRG) {
@@ -775,7 +775,7 @@ public class ComputerUtilMana {
// * Pay 2/C with matching colors
// * pay hybrids
// * pay phyrexian, keep mana for colorless
// * pay colorless
// * pay generic
return cost.getShardToPayByPriority(cost.getDistinctShards(), ColorSet.ALL_COLORS.getColor());
}
@@ -786,10 +786,10 @@ public class ComputerUtilMana {
byte mask = MagicColor.fromName(manaPart);
// make mana mandatory for AI
if (!cost.needsColor(mask, ai.getManaPool()) && cost.getColorlessManaAmount() > 0) {
if (!cost.needsColor(mask, ai.getManaPool()) && cost.getGenericManaAmount() > 0) {
ManaCostShard shard = ManaCostShard.valueOf(mask);
cost.increaseShard(shard, 1);
cost.decreaseColorlessMana(1);
cost.decreaseGenericMana(1);
}
}
}
@@ -909,8 +909,8 @@ public class ComputerUtilMana {
final ManaCostBeingPaid cost) {
ListMultimap<ManaCostShard, SpellAbility> res = ArrayListMultimap.create();
if (cost.getColorlessManaAmount() > 0 && manaAbilityMap.containsKey(ManaAtom.COLORLESS)) {
res.putAll(ManaCostShard.COLORLESS, manaAbilityMap.get(ManaAtom.COLORLESS));
if (cost.getGenericManaAmount() > 0 && manaAbilityMap.containsKey(ManaAtom.GENERIC)) {
res.putAll(ManaCostShard.GENERIC, manaAbilityMap.get(ManaAtom.GENERIC));
}
// loop over cost parts
@@ -923,16 +923,16 @@ public class ComputerUtilMana {
continue;
}
if (shard.isOr2Colorless()) {
if (shard.isOr2Generic()) {
Integer colorKey = (int) shard.getColorMask();
if (manaAbilityMap.containsKey(colorKey))
res.putAll(shard, manaAbilityMap.get(colorKey));
if (manaAbilityMap.containsKey(ManaAtom.COLORLESS))
res.putAll(shard, manaAbilityMap.get(ManaAtom.COLORLESS));
if (manaAbilityMap.containsKey(ManaAtom.GENERIC))
res.putAll(shard, manaAbilityMap.get(ManaAtom.GENERIC));
continue;
}
if (shard == ManaCostShard.COLORLESS) {
if (shard == ManaCostShard.GENERIC) {
continue;
}
@@ -1176,7 +1176,7 @@ public class ComputerUtilMana {
}
}
manaMap.get(ManaAtom.COLORLESS).add(manaMap.get(ManaAtom.COLORLESS).size(), m); // add to colorless source list
manaMap.get(ManaAtom.GENERIC).add(manaMap.get(ManaAtom.GENERIC).size(), m); // add to generic source list
AbilityManaPart mp = m.getManaPart();
// setup produce mana replacement effects
@@ -1314,7 +1314,7 @@ public class ComputerUtilMana {
convoked = null;
}
for (int i = 0; i < list.size() && i < cost.getGenericCost(); i++) {
convoke.put(list.get(i), ManaCostShard.COLORLESS);
convoke.put(list.get(i), ManaCostShard.GENERIC);
}
return convoke;
}

View File

@@ -320,8 +320,8 @@ public class PlayerControllerAi extends PlayerController {
}
@Override
public CardCollectionView chooseCardsToDelve(int colorlessCost, CardCollection grave) {
return getAi().chooseCardsToDelve(colorlessCost, grave);
public CardCollectionView chooseCardsToDelve(int genericAmount, CardCollection grave) {
return getAi().chooseCardsToDelve(genericAmount, grave);
}
@Override

View File

@@ -427,19 +427,19 @@ public final class CardRules implements ICardCharacteristics {
*/
private static class ManaCostParser implements IParserManaCost {
private final StringTokenizer st;
private int colorlessCost;
private int genericCost;
public ManaCostParser(final String cost) {
st = new StringTokenizer(cost, " ");
this.colorlessCost = 0;
this.genericCost = 0;
}
@Override
public final int getTotalColorlessCost() {
public final int getTotalGenericCost() {
if (this.hasNext()) {
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
throw new RuntimeException("Generic cost should be obtained after iteration is complete");
}
return this.colorlessCost;
return this.genericCost;
}
/*
@@ -463,7 +463,7 @@ public final class CardRules implements ICardCharacteristics {
// System.out.println(unparsed);
try {
int iVal = Integer.parseInt(unparsed);
this.colorlessCost += iVal;
this.genericCost += iVal;
return null;
}
catch (NumberFormatException nex) { }

View File

@@ -394,7 +394,7 @@ public final class CardRulesPredicates {
public static class LeafNumber implements Predicate<CardRules> {
public enum CardField {
CMC, COLORLESS_COST, POWER, TOUGHNESS
CMC, GENERIC_COST, POWER, TOUGHNESS
}
private final LeafNumber.CardField field;
@@ -413,7 +413,7 @@ public final class CardRulesPredicates {
switch (this.field) {
case CMC:
return this.op(card.getManaCost().getCMC(), this.operand);
case COLORLESS_COST:
case GENERIC_COST:
return this.op(card.getManaCost().getGenericCost(), this.operand);
case POWER:
value = card.getIntPower();

View File

@@ -7,11 +7,5 @@ import java.util.Iterator;
* The Interface ManaParser.
*/
public interface IParserManaCost extends Iterator<ManaCostShard> {
/**
* Gets the total colorless cost.
*
* @return the total colorless cost
*/
int getTotalColorlessCost();
int getTotalGenericCost();
}

View File

@@ -4,7 +4,7 @@ import forge.card.MagicColor;
/** A bitmask to represent any mana symbol as an integer. */
public abstract class ManaAtom {
public static final int COLORLESS = 1 << 6;
public static final int GENERIC = 1 << 6;
/** The Constant WHITE. */
public static final int WHITE = MagicColor.WHITE;
@@ -24,12 +24,14 @@ public abstract class ManaAtom {
/** The Constant IS_X. */
public static final int IS_X = 1 << 8;
/** The Constant OR_2_COLORLESS. */
public static final int OR_2_COLORLESS = 1 << 9;
/** The Constant OR_2_GENERIC. */
public static final int OR_2_GENERIC = 1 << 9;
/** The Constant OR_2_LIFE. */
public static final int OR_2_LIFE = 1 << 10;
/** The Constant IS_SNOW. */
public static final int IS_SNOW = 1 << 11;
public static final int COLORLESS = 1 << 12;
}

View File

@@ -48,7 +48,6 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
private Float compareWeight = null;
/** The Constant empty. */
public static final ManaCost NO_COST = new ManaCost(-1);
public static final ManaCost ZERO = new ManaCost(0);
public static final ManaCost ONE = new ManaCost(1);
@@ -56,15 +55,15 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
public static final ManaCost THREE = new ManaCost(3);
public static final ManaCost FOUR = new ManaCost(4);
public static ManaCost get(int cntColorless) {
switch (cntColorless) {
public static ManaCost get(int cntGeneric) {
switch (cntGeneric) {
case 0: return ZERO;
case 1: return ONE;
case 2: return TWO;
case 3: return THREE;
case 4: return FOUR;
}
return cntColorless > 0 ? new ManaCost(cntColorless) : NO_COST;
return cntGeneric > 0 ? new ManaCost(cntGeneric) : NO_COST;
}
// pass mana cost parser here
@@ -91,11 +90,11 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
this.hasNoCost = false;
while (parser.hasNext()) {
final ManaCostShard shard = parser.next();
if (shard != null && shard != ManaCostShard.COLORLESS) {
if (shard != null && shard != ManaCostShard.GENERIC) {
shardsTemp.add(shard);
} // null is OK - that was generic mana
}
this.genericCost = parser.getTotalColorlessCost(); // collect generic mana
this.genericCost = parser.getTotalGenericCost(); // collect generic mana
// here
sealClass(shardsTemp);
}
@@ -149,7 +148,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
}
public int getShardCount(ManaCostShard which) {
if (which == ManaCostShard.COLORLESS) {
if (which == ManaCostShard.GENERIC) {
return genericCost;
}

View File

@@ -9,7 +9,7 @@ import org.apache.commons.lang3.StringUtils;
public class ManaCostParser implements IParserManaCost {
private final String[] cost;
private int nextToken;
private int colorlessCost;
private int genericCost;
/**
* Parse the given cost and output formatted cost string
@@ -32,20 +32,20 @@ public class ManaCostParser implements IParserManaCost {
this.cost = cost.split(" ");
// System.out.println(cost);
this.nextToken = 0;
this.colorlessCost = 0;
this.genericCost = 0;
}
/*
* (non-Javadoc)
*
* @see forge.card.CardManaCost.ManaParser#getTotalColorlessCost()
* @see forge.card.CardManaCost.ManaParser#getTotalGenericCost()
*/
@Override
public final int getTotalColorlessCost() {
public final int getTotalGenericCost() {
if (this.hasNext()) {
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
throw new RuntimeException("Generic cost should be obtained after iteration is complete");
}
return this.colorlessCost;
return this.genericCost;
}
/*
@@ -68,7 +68,7 @@ public class ManaCostParser implements IParserManaCost {
final String unparsed = this.cost[this.nextToken++];
// System.out.println(unparsed);
if (StringUtils.isNumeric(unparsed)) {
this.colorlessCost += Integer.parseInt(unparsed);
this.genericCost += Integer.parseInt(unparsed);
return null;
}

View File

@@ -45,15 +45,16 @@ public enum ManaCostShard {
GU(ManaAtom.GREEN | ManaAtom.BLUE, "G/U", "GU"),
/* Or 2 colorless */
W2(ManaAtom.WHITE | ManaAtom.OR_2_COLORLESS, "2/W", "2W"),
U2(ManaAtom.BLUE | ManaAtom.OR_2_COLORLESS, "2/U", "2U"),
B2(ManaAtom.BLACK | ManaAtom.OR_2_COLORLESS, "2/B", "2B"),
R2(ManaAtom.RED | ManaAtom.OR_2_COLORLESS, "2/R", "2R"),
G2(ManaAtom.GREEN | ManaAtom.OR_2_COLORLESS, "2/G", "2G"),
W2(ManaAtom.WHITE | ManaAtom.OR_2_GENERIC, "2/W", "2W"),
U2(ManaAtom.BLUE | ManaAtom.OR_2_GENERIC, "2/U", "2U"),
B2(ManaAtom.BLACK | ManaAtom.OR_2_GENERIC, "2/B", "2B"),
R2(ManaAtom.RED | ManaAtom.OR_2_GENERIC, "2/R", "2R"),
G2(ManaAtom.GREEN | ManaAtom.OR_2_GENERIC, "2/G", "2G"),
// Snow and colorless
S(ManaAtom.IS_SNOW, "S"),
COLORLESS(ManaAtom.COLORLESS, "1"),
GENERIC(ManaAtom.GENERIC, "1"),
COLORLESS(ManaAtom.COLORLESS, "C"),
/* Phyrexian */
PW(ManaAtom.WHITE | ManaAtom.OR_2_LIFE, "P/W", "PW"),
@@ -112,7 +113,7 @@ public enum ManaCostShard {
if (0 != (this.shard & ManaAtom.IS_X)) {
return 0;
}
if (0 != (this.shard & ManaAtom.OR_2_COLORLESS)) {
if (0 != (this.shard & ManaAtom.OR_2_GENERIC)) {
return 2;
}
return 1;
@@ -130,7 +131,7 @@ public enum ManaCostShard {
if (0 != (this.shard & ManaAtom.IS_X)) {
return 0.0001f;
}
float cost = 0 != (this.shard & ManaAtom.OR_2_COLORLESS) ? 2 : 1;
float cost = 0 != (this.shard & ManaAtom.OR_2_GENERIC) ? 2 : 1;
// yes, these numbers are magic, slightly-magic
if (0 != (this.shard & ManaAtom.WHITE)) {
cost += 0.0005f;
@@ -170,7 +171,7 @@ public enum ManaCostShard {
* @return the card mana cost shard
*/
public static ManaCostShard valueOf(final int atoms) {
if ( atoms == 0 ) return ManaCostShard.COLORLESS;
if ( atoms == 0 ) return ManaCostShard.GENERIC;
for (final ManaCostShard element : ManaCostShard.values()) {
if (element.shard == atoms) {
return element;
@@ -194,17 +195,18 @@ public enum ManaCostShard {
case 'P': atoms |= ManaAtom.OR_2_LIFE; break;
case 'S': atoms |= ManaAtom.IS_SNOW; break;
case 'X': atoms |= ManaAtom.IS_X; break;
case '2': atoms |= ManaAtom.OR_2_COLORLESS; break;
case 'C': atoms |= ManaAtom.COLORLESS; break;
case '2': atoms |= ManaAtom.OR_2_GENERIC; break;
default:
if (c <= '9' && c >= '0') {
atoms |= ManaAtom.COLORLESS;
atoms |= ManaAtom.GENERIC;
}
break;
}
}
// for cases when unparsed equals '2' or unparsed is like '12' or '20'
if (atoms == ManaAtom.OR_2_COLORLESS || atoms == (ManaAtom.OR_2_COLORLESS | ManaAtom.COLORLESS)) {
atoms = ManaAtom.COLORLESS;
if (atoms == ManaAtom.OR_2_GENERIC || atoms == (ManaAtom.OR_2_GENERIC | ManaAtom.GENERIC)) {
atoms = ManaAtom.GENERIC;
}
return ManaCostShard.valueOf(atoms);
}
@@ -282,11 +284,11 @@ public enum ManaCostShard {
return BinaryUtil.bitCount(this.shard & COLORS_SUPERPOSITION) == 1;
}
public boolean isOr2Colorless() {
return (this.shard & ManaAtom.OR_2_COLORLESS) != 0;
public boolean isOr2Generic() {
return (this.shard & ManaAtom.OR_2_GENERIC) != 0;
}
public boolean canBePaidWithManaOfColor(byte colorCode) {
return this.isOr2Colorless() || (COLORS_SUPERPOSITION & this.shard) == 0 || (colorCode & this.shard) > 0;
return this.isOr2Generic() || (COLORS_SUPERPOSITION & this.shard) == 0 || (colorCode & this.shard) > 0;
}
}

View File

@@ -255,7 +255,7 @@ public final class GameActionUtil {
final SpellAbility newSA = sa.copy();
newSA.setBasicSpell(false);
ManaCostBeingPaid newCost = new ManaCostBeingPaid(source.getManaCost());
newCost.increaseColorlessMana(2);
newCost.increaseGenericMana(2);
final Cost actualcost = new Cost(newCost.toManaCost(), false);
newSA.setPayCosts(actualcost);
SpellAbilityRestriction sar = new SpellAbilityRestriction();

View File

@@ -1285,7 +1285,7 @@ public class AbilityUtils {
int xPaid = triggeredCard.getXManaCostPaid() * xCount;
ManaCostBeingPaid toPay = new ManaCostBeingPaid(triggeredCard.getManaCost());
toPay.decreaseShard(ManaCostShard.X, xCount);
toPay.increaseColorlessMana(xPaid);
toPay.increaseGenericMana(xPaid);
cost = new Cost(toPay.toManaCost(), true);
}
}
@@ -1305,7 +1305,7 @@ public class AbilityUtils {
return;
}
ManaCostBeingPaid newCost = new ManaCostBeingPaid(rememberedCard.getManaCost());
newCost.decreaseColorlessMana(2);
newCost.decreaseGenericMana(2);
cost = new Cost(newCost.toManaCost(), true);
}
else if (!StringUtils.isBlank(sa.getSVar(unlessCost)) || !StringUtils.isBlank(source.getSVar(unlessCost))) {

View File

@@ -438,7 +438,7 @@ public class CardFactoryUtil {
final StringBuilder sb = new StringBuilder();
if (Character.isDigit(tokenized[0].charAt(0))) {
// cost starts with "colorless" number cost
// cost starts with "generic" number cost
int cost = Integer.parseInt(tokenized[0]);
cost = multiplier * cost;
tokenized[0] = "" + cost;

View File

@@ -407,7 +407,8 @@ public final class CardUtil {
colors.add(col);
}
}
if (maxChoices == 6 && producedColors.contains("1")) {
// TODO Sol Remove production of "1" Generic Mana
if (maxChoices == 6 && (producedColors.contains("1") || producedColors.contains("C"))) {
colors.add(MagicColor.Constant.COLORLESS);
}
} else if (reflectProperty.equals("Produce")) {
@@ -461,7 +462,8 @@ public final class CardUtil {
}
}
if (maxChoices == 6 && ab.canProduce("1")) {
// TODO Sol Remove production of "1" Generic Mana
if (maxChoices == 6 && (ab.canProduce("1") || ab.canProduce("C"))) {
colors.add(MagicColor.Constant.COLORLESS);
}

View File

@@ -114,13 +114,14 @@ public class Cost {
return manapart == null ? ManaCost.ZERO : manapart.getManaToPay();
}
private Cost(int colorlessmana) {
costParts.add(new CostPartMana(ManaCost.get(colorlessmana), null));
private Cost(int genericMana) {
costParts.add(new CostPartMana(ManaCost.get(genericMana), null));
}
// Parsing Strings
public Cost(ManaCost cost, final boolean bAbility) {
this.isAbility = bAbility;
costParts.add(new CostPartMana(cost, null));
}

View File

@@ -94,9 +94,9 @@ public class ManaCostAdjustment {
sa.getHostCard().clearDelved();
final Player pc = sa.getActivatingPlayer();
final CardCollection mutableGrave = new CardCollection(pc.getCardsIn(ZoneType.Graveyard));
final CardCollectionView toExile = pc.getController().chooseCardsToDelve(cost.getUnpaidShards(ManaCostShard.COLORLESS), mutableGrave);
final CardCollectionView toExile = pc.getController().chooseCardsToDelve(cost.getUnpaidShards(ManaCostShard.GENERIC), mutableGrave);
for (final Card c : toExile) {
cost.decreaseColorlessMana(1);
cost.decreaseGenericMana(1);
if (cardsToDelveOut != null) {
cardsToDelveOut.add(c);
} else if (!test) {
@@ -328,15 +328,15 @@ public class ManaCostAdjustment {
}
if (!params.containsKey("Color")) {
manaCost.increaseColorlessMana(value);
manaCost.increaseGenericMana(value);
if (manaCost.toString().equals("{0}") && params.containsKey("MinMana")) {
manaCost.increaseColorlessMana(Integer.valueOf(params.get("MinMana")));
manaCost.increaseGenericMana(Integer.valueOf(params.get("MinMana")));
}
} else {
final String color = params.get("Color");
for (final String cost : color.split(" ")) {
if (StringUtils.isNumeric(cost)) {
manaCost.increaseColorlessMana(Integer.parseInt(cost) * value);
manaCost.increaseGenericMana(Integer.parseInt(cost) * value);
} else {
manaCost.increaseShard(ManaCostShard.parseNonGeneric(cost), value);
}
@@ -463,13 +463,13 @@ public class ManaCostAdjustment {
final int maxReduction = Math.max(0, manaCost.getConvertedManaCost() - minMana);
if (maxReduction > 0) {
manaCost.decreaseColorlessMana(Math.min(value, maxReduction));
manaCost.decreaseGenericMana(Math.min(value, maxReduction));
}
} else {
final String color = params.get("Color");
for (final String cost : color.split(" ")) {
if (StringUtils.isNumeric(cost)) {
manaCost.decreaseColorlessMana(Integer.parseInt(cost) * value);
manaCost.decreaseGenericMana(Integer.parseInt(cost) * value);
} else {
manaCost.decreaseShard(ManaCostShard.parseNonGeneric(cost), value);
}

View File

@@ -80,16 +80,16 @@ public class ManaCostBeingPaid {
if (!mch.hasNext()) { return false; }
nextShard = mch.next();
if (nextShard == ManaCostShard.COLORLESS) {
return this.hasNext(); // skip colorless
if (nextShard == ManaCostShard.GENERIC) {
return this.hasNext(); // skip generic
}
remainingShards = unpaidShards.get(nextShard).totalCount;
return true;
}
@Override
public int getTotalColorlessCost() {
ShardCount c = unpaidShards.get(ManaCostShard.COLORLESS);
public int getTotalGenericCost() {
ShardCount c = unpaidShards.get(ManaCostShard.GENERIC);
return c == null ? 0 : c.totalCount;
}
}
@@ -107,7 +107,7 @@ public class ManaCostBeingPaid {
}
// holds Mana_Part objects
// ManaPartColor is stored before ManaPartColorless
// ManaPartColor is stored before ManaPartGeneric
private final Map<ManaCostShard, ShardCount> unpaidShards = new HashMap<ManaCostShard, ShardCount>();
private Map<String, Integer> xManaCostPaidByColor;
private final String sourceRestriction;
@@ -145,7 +145,7 @@ public class ManaCostBeingPaid {
increaseShard(shard, 1, false);
}
}
increaseColorlessMana(manaCost.getGenericCost());
increaseGenericMana(manaCost.getGenericCost());
}
public Map<String, Integer> getXManaCostPaidByColor() {
@@ -190,10 +190,10 @@ public class ManaCostBeingPaid {
// Easier for split costs
public final boolean needsColor(final byte colorMask, final ManaPool pool) {
for (ManaCostShard shard : unpaidShards.keySet()) {
if (shard == ManaCostShard.COLORLESS) {
if (shard == ManaCostShard.GENERIC) {
continue;
}
if (shard.isOr2Colorless()) {
if (shard.isOr2Generic()) {
if ((shard.getColorMask() & colorMask) != 0) {
return true;
}
@@ -234,7 +234,7 @@ public class ManaCostBeingPaid {
ManaCostShard shard;
if (StringUtils.isEmpty(xColor)) {
shard = ManaCostShard.COLORLESS;
shard = ManaCostShard.GENERIC;
}
else {
shard = ManaCostShard.valueOf(MagicColor.fromName(xColor));
@@ -242,8 +242,8 @@ public class ManaCostBeingPaid {
increaseShard(shard, xCost, true);
}
public final void increaseColorlessMana(final int toAdd) {
increaseShard(ManaCostShard.COLORLESS, toAdd, false);
public final void increaseGenericMana(final int toAdd) {
increaseShard(ManaCostShard.GENERIC, toAdd, false);
}
public final void increaseShard(final ManaCostShard shard, final int toAdd) {
increaseShard(shard, toAdd, false);
@@ -262,8 +262,8 @@ public class ManaCostBeingPaid {
sc.totalCount += toAdd;
}
public final void decreaseColorlessMana(final int manaToSubtract) {
decreaseShard(ManaCostShard.COLORLESS, manaToSubtract);
public final void decreaseGenericMana(final int manaToSubtract) {
decreaseShard(ManaCostShard.GENERIC, manaToSubtract);
}
public final void decreaseShard(final ManaCostShard shard, final int manaToSubtract) {
@@ -289,8 +289,8 @@ public class ManaCostBeingPaid {
}
}
public final int getColorlessManaAmount() {
ShardCount sc = unpaidShards.get(ManaCostShard.COLORLESS);
public final int getGenericManaAmount() {
ShardCount sc = unpaidShards.get(ManaCostShard.GENERIC);
if (sc != null) {
return sc.totalCount;
}
@@ -402,8 +402,8 @@ public class ManaCostBeingPaid {
}
decreaseShard(chosenShard, 1);
if (chosenShard.isOr2Colorless() && ( 0 == (chosenShard.getColorMask() & possibleUses) )) {
this.increaseColorlessMana(1);
if (chosenShard.isOr2Generic() && ( 0 == (chosenShard.getColorMask() & possibleUses) )) {
this.increaseGenericMana(1);
}
this.sunburstMap |= colorMask;
@@ -411,12 +411,12 @@ public class ManaCostBeingPaid {
}
private static int getPayPriority(final ManaCostShard bill, final byte paymentColor) {
if (bill == ManaCostShard.COLORLESS) {
if (bill == ManaCostShard.GENERIC) {
return 0;
}
if (bill.isMonoColor()) {
if (bill.isOr2Colorless()) {
if (bill.isOr2Generic()) {
return !ColorSet.fromMask(bill.getColorMask() & paymentColor).isColorless() ? 9 : 4;
}
if (!bill.isPhyrexian()) {
@@ -445,7 +445,7 @@ public class ManaCostBeingPaid {
increaseShard(shard, 1, false);
}
}
increaseColorlessMana(extra.getGenericCost());
increaseGenericMana(extra.getGenericCost());
}
public final void subtractManaCost(final ManaCost subThisManaCost) {
@@ -457,10 +457,10 @@ public class ManaCostBeingPaid {
decreaseShard(shard, 1);
}
else {
decreaseColorlessMana(1);
decreaseGenericMana(1);
}
}
decreaseColorlessMana(subThisManaCost.getGenericCost());
decreaseGenericMana(subThisManaCost.getGenericCost());
}
/**
@@ -480,12 +480,12 @@ public class ManaCostBeingPaid {
}
}
int nGeneric = getColorlessManaAmount();
int nGeneric = getGenericManaAmount();
if (nGeneric > 0) {
if (nGeneric <= 20) {
sb.append("{" + nGeneric + "}");
}
else { //if no mana symbol exists for colorless amount, use combination of symbols for each digit
else { //if no mana symbol exists for generic amount, use combination of symbols for each digit
String genericStr = String.valueOf(nGeneric);
for (int i = 0; i < genericStr.length(); i++) {
sb.append("{" + genericStr.charAt(i) + "}");
@@ -497,7 +497,7 @@ public class ManaCostBeingPaid {
List<ManaCostShard> shards = new ArrayList<ManaCostShard>(unpaidShards.keySet());
Collections.sort(shards);
for (ManaCostShard shard : shards) {
if (shard == ManaCostShard.COLORLESS) {
if (shard == ManaCostShard.GENERIC) {
continue;
}
@@ -554,15 +554,8 @@ public class ManaCostBeingPaid {
return result;
}
/**
* <p>
* removeColorlessMana.
* </p>
*
* @since 1.0.15
*/
public final void removeColorlessMana() {
unpaidShards.remove(ManaCostShard.COLORLESS);
public final void removeGenericMana() {
unpaidShards.remove(ManaCostShard.GENERIC);
}
public String getSourceRestriction() {

View File

@@ -152,7 +152,7 @@ public abstract class PlayerController {
public abstract CardCollectionView chooseCardsToDiscardFrom(Player playerDiscard, SpellAbility sa, CardCollection validCards, int min, int max);
public abstract void playMiracle(SpellAbility miracle, Card card);
public abstract CardCollectionView chooseCardsToDelve(int colorLessAmount, CardCollection grave);
public abstract CardCollectionView chooseCardsToDelve(int genericAmount, CardCollection grave);
public abstract CardCollectionView chooseCardsToRevealFromHand(int min, int max, CardCollectionView valid);
public abstract CardCollectionView chooseCardsToDiscardUnlessType(int min, CardCollectionView hand, String param, SpellAbility sa);
public abstract List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand);

View File

@@ -521,6 +521,7 @@ public final class StaticAbilityContinuous {
sb.append(generic);
}
for (ManaCostShard s : affectedCard.getManaCost()) {
// TODO Sol Investigate, this loop feels wrong
ColorSet cs = ColorSet.fromMask(s.getColorMask());
if(cs.isColorless()) continue;
sb.append(' ');

View File

@@ -56,7 +56,7 @@ public class ColorSetRenderer extends ItemCellRenderer {
final int offsetIfNoSpace = cntGlyphs > 1 ? (cellWidth - padding0 - elemtWidth) / (cntGlyphs - 1) : elemtWidth + elemtGap;
final int dx = Math.min(elemtWidth + elemtGap, offsetIfNoSpace);
// Display colorless mana before colored mana
// Display generic mana before colored mana
if (cntGlyphs == 0) {
CardFaceSymbols.drawSymbol(ManaCostShard.X.getImageKey(), g, x, y);
x += dx;

View File

@@ -116,7 +116,7 @@ public class ManaCostRenderer extends ItemCellRenderer {
}
}
// Display colorless mana before colored mana
// Display generic mana before colored mana
if (hasGeneric) {
final String sGeneric = Integer.toString(genericManaCost);
CardFaceSymbols.drawSymbol(sGeneric, g, x, y);

View File

@@ -55,6 +55,7 @@ public class CardFaceSymbols {
MANA_IMAGES.put("X", FSkin.getImage(FSkinProp.IMG_MANA_X, manaImageSize, manaImageSize));
MANA_IMAGES.put("Y", FSkin.getImage(FSkinProp.IMG_MANA_Y, manaImageSize, manaImageSize));
MANA_IMAGES.put("Z", FSkin.getImage(FSkinProp.IMG_MANA_Z, manaImageSize, manaImageSize));
MANA_IMAGES.put("C", FSkin.getImage(FSkinProp.IMG_MANA_COLORLESS, manaImageSize, manaImageSize));
MANA_IMAGES.put("B", FSkin.getImage(FSkinProp.IMG_MANA_B, manaImageSize, manaImageSize));
MANA_IMAGES.put("BG", FSkin.getImage(FSkinProp.IMG_MANA_HYBRID_BG, manaImageSize, manaImageSize));

View File

@@ -62,7 +62,7 @@ public class RunTest {
this.check("24", !manaCost.isPaid());
manaCost.payMana(MagicColor.Constant.BLUE);
this.check("25", !manaCost.isPaid());
manaCost.payMana(MagicColor.Constant.COLORLESS);
manaCost.payMana(MagicColor.Constant.GENERIC);
this.check("26", !manaCost.isPaid());
manaCost.payMana(MagicColor.Constant.GREEN);
this.check("27", !manaCost.isPaid());

View File

@@ -273,7 +273,7 @@ public class PlayerControllerForTests extends PlayerController {
}
@Override
public CardCollectionView chooseCardsToDelve(int colorLessAmount, CardCollection grave) {
public CardCollectionView chooseCardsToDelve(int genericAmount, CardCollection grave) {
return CardCollection.EMPTY;
}

View File

@@ -21,12 +21,12 @@ public class CardColorlessCostFilter extends ValueRangeFilter<PaperCard> {
@Override
protected String getCaption() {
return "Colorless Cost";
return "Generic Cost";
}
@Override
protected Predicate<PaperCard> buildPredicate() {
Predicate<CardRules> predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.COLORLESS_COST);
Predicate<CardRules> predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.GENERIC_COST);
if (predicate == null) {
return Predicates.alwaysTrue();
}

View File

@@ -82,7 +82,7 @@ public enum FSkinProp {
IMG_MANA_PHRYX_B (new int[] {320, 360, 40, 40}, PropType.IMAGE),
IMG_MANA_SNOW (new int[] {320, 160, 40, 40}, PropType.IMAGE),
//colorless mana images
//generic mana images
IMG_MANA_0 (new int[] {640, 200, 20, 20}, PropType.IMAGE),
IMG_MANA_1 (new int[] {660, 200, 20, 20}, PropType.IMAGE),
IMG_MANA_2 (new int[] {640, 220, 20, 20}, PropType.IMAGE),

View File

@@ -169,7 +169,7 @@ public class CardDetailUtil {
if (curColors.hasGreen()) { strCurColors += "{G}"; }
if (strCurColors.isEmpty()) {
strCurColors = "{X} (colorless)";
strCurColors = "{C}";
}
return strCurColors;

View File

@@ -168,7 +168,7 @@ public class DeckProxy implements InventoryItem {
else {
for (final ManaCostShard shard : rules.getManaCost()) {
//track phyrexian and hybrid costs separately as they won't always affect color
if (shard.isPhyrexian() || shard.isOr2Colorless() || !shard.isMonoColor()) {
if (shard.isPhyrexian() || shard.isOr2Generic() || !shard.isMonoColor()) {
if (nonReqColors == null) {
nonReqColors = new HashSet<Byte>();
}

View File

@@ -129,8 +129,8 @@ public abstract class InputPayMana extends InputSyncronizedBase {
colorCanUse |= color;
}
}
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.COLORLESS, player.getManaPool())) {
colorCanUse |= ManaAtom.COLORLESS;
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.GENERIC, player.getManaPool())) {
colorCanUse |= ManaAtom.GENERIC;
}
if (colorCanUse == 0) { // no mana cost or something
return abilities;
@@ -183,8 +183,8 @@ public abstract class InputPayMana extends InputSyncronizedBase {
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) { colorCanUse |= color; }
if (manaCost.needsColor(color, player.getManaPool())) { colorNeeded |= color; }
}
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.COLORLESS, player.getManaPool())) {
colorCanUse |= ManaAtom.COLORLESS;
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.GENERIC, player.getManaPool())) {
colorCanUse |= ManaAtom.GENERIC;
}
if (colorCanUse == 0) { // no mana cost or something
@@ -293,7 +293,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
}
private static boolean abilityProducesManaColor(final SpellAbility am, AbilityManaPart m, final byte neededColor) {
if (0 != (neededColor & ManaAtom.COLORLESS)) {
if (0 != (neededColor & ManaAtom.GENERIC)) {
return true;
}

View File

@@ -60,7 +60,7 @@ public final class InputSelectCardsForConvoke extends InputSelectManyBase<Card>
colors = ColorSet.fromMask(colors.getColor() & remainingCost.getUnpaidColors());
}
if (!colors.isMulticolor()) {
// Since the convoke mana logic can use colored mana as colorless if needed,
// Since the convoke mana logic can use colored mana as generic if needed,
// there is no need to prompt the user when convoking with a mono-color creature.
chosenColor = colors.getColor();
}

View File

@@ -701,8 +701,8 @@ public class PlayerControllerHuman
}
@Override
public CardCollectionView chooseCardsToDelve(final int colorLessAmount, final CardCollection grave) {
final int cardsInGrave = Math.min(colorLessAmount, grave.size());
public CardCollectionView chooseCardsToDelve(final int genericAmount, final CardCollection grave) {
final int cardsInGrave = Math.min(genericAmount, grave.size());
if (cardsInGrave == 0) {
return CardCollection.EMPTY;
}
@@ -1437,7 +1437,7 @@ public class PlayerControllerHuman
} else {
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override public final void run() {
getGui().message("Cannot pass priority at this time.");
//getGui().message("Cannot pass priority at this time.");
}
});
}