- 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

@@ -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(' ');