mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Mostly cosmetic changes to color code
This commit is contained in:
@@ -3,6 +3,7 @@ package forge.ai;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
@@ -696,7 +697,7 @@ public class ComputerUtilMana {
|
|||||||
// * pay hybrids
|
// * pay hybrids
|
||||||
// * pay phyrexian, keep mana for colorless
|
// * pay phyrexian, keep mana for colorless
|
||||||
// * pay colorless
|
// * pay colorless
|
||||||
return cost.getShardToPayByPriority(cost.getDistinctShards(), MagicColor.ALL_COLORS);
|
return cost.getShardToPayByPriority(cost.getDistinctShards(), ColorSet.ALL_COLORS.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card, Player ai) {
|
private static void adjustManaCostToAvoidNegEffects(ManaCostBeingPaid cost, final Card card, Player ai) {
|
||||||
|
|||||||
@@ -42,21 +42,11 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
private final byte myColor;
|
private final byte myColor;
|
||||||
private final float orderWeight;
|
private final float orderWeight;
|
||||||
|
|
||||||
private static final ColorSet[] allColors = new ColorSet[32];
|
private static final ColorSet[] cache = new ColorSet[32];
|
||||||
private static final ColorSet noColor = new ColorSet();
|
|
||||||
|
|
||||||
// TODO: some cards state "CardName is %color%" (e.g. pacts of...) - fix
|
private static final byte ALL_COLORS_MASK = MagicColor.WHITE | MagicColor.BLUE | MagicColor.BLACK | MagicColor.RED | MagicColor.GREEN;
|
||||||
// this later
|
public static final ColorSet ALL_COLORS = fromMask(ALL_COLORS_MASK);
|
||||||
/**
|
private static final ColorSet NO_COLORS = fromMask(MagicColor.COLORLESS);
|
||||||
* Instantiates a new card color.
|
|
||||||
*
|
|
||||||
* @param mana
|
|
||||||
* the mana
|
|
||||||
*/
|
|
||||||
private ColorSet() {
|
|
||||||
myColor = 0;
|
|
||||||
orderWeight = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ColorSet(final byte mask) {
|
private ColorSet(final byte mask) {
|
||||||
this.myColor = mask;
|
this.myColor = mask;
|
||||||
@@ -64,11 +54,11 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ColorSet fromMask(final int mask) {
|
public static ColorSet fromMask(final int mask) {
|
||||||
final int mask32 = mask & MagicColor.ALL_COLORS;
|
final int mask32 = mask & ALL_COLORS_MASK;
|
||||||
if (allColors[mask32] == null) {
|
if (cache[mask32] == null) {
|
||||||
allColors[mask32] = new ColorSet((byte) mask);
|
cache[mask32] = new ColorSet((byte) mask32);
|
||||||
}
|
}
|
||||||
return allColors[mask32];
|
return cache[mask32];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ColorSet fromNames(final String... colors) {
|
public static ColorSet fromNames(final String... colors) {
|
||||||
@@ -113,6 +103,11 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
return (this.myColor & colormask) == colormask;
|
return (this.myColor & colormask) == colormask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** this has no other colors except defined by operand. */
|
||||||
|
public boolean hasNoColorsExcept(final ColorSet other) {
|
||||||
|
return hasNoColorsExcept(other.getColor());
|
||||||
|
}
|
||||||
|
|
||||||
/** this has no other colors except defined by operand. */
|
/** this has no other colors except defined by operand. */
|
||||||
public boolean hasNoColorsExcept(final int colormask) {
|
public boolean hasNoColorsExcept(final int colormask) {
|
||||||
return (this.myColor & ~colormask) == 0;
|
return (this.myColor & ~colormask) == 0;
|
||||||
@@ -139,7 +134,7 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
*
|
*
|
||||||
* @return the order weight
|
* @return the order weight
|
||||||
*/
|
*/
|
||||||
public float getOrderWeight() {
|
private float getOrderWeight() {
|
||||||
float res = this.countColors();
|
float res = this.countColors();
|
||||||
if(hasWhite()) {
|
if(hasWhite()) {
|
||||||
res += 0.0005f;
|
res += 0.0005f;
|
||||||
@@ -255,7 +250,7 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
|
|
||||||
public ColorSet inverse() {
|
public ColorSet inverse() {
|
||||||
byte mask = this.myColor;
|
byte mask = this.myColor;
|
||||||
mask ^= MagicColor.ALL_COLORS;
|
mask ^= ALL_COLORS_MASK;
|
||||||
return fromMask(mask);
|
return fromMask(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +281,7 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
* @return the nullColor
|
* @return the nullColor
|
||||||
*/
|
*/
|
||||||
public static ColorSet getNullColor() {
|
public static ColorSet getNullColor() {
|
||||||
return noColor;
|
return NO_COLORS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,8 +294,12 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
return (this.myColor & ccOther.myColor) != 0;
|
return (this.myColor & ccOther.myColor) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ColorSet getSharedColors(final ColorSet ccOther) {
|
||||||
|
return fromMask(getColor() & ccOther.getColor());
|
||||||
|
}
|
||||||
|
|
||||||
public ColorSet getOffColors(final ColorSet ccOther) {
|
public ColorSet getOffColors(final ColorSet ccOther) {
|
||||||
return ColorSet.fromMask(~this.myColor & ccOther.myColor);
|
return fromMask(~this.myColor & ccOther.myColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -313,8 +312,8 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
|||||||
|
|
||||||
private int getIndexOfNextColor(){
|
private int getIndexOfNextColor(){
|
||||||
int nextBit = currentBit + 1;
|
int nextBit = currentBit + 1;
|
||||||
while(nextBit < MagicColor.NUMBER_OR_COLORS) {
|
while (nextBit < MagicColor.NUMBER_OR_COLORS) {
|
||||||
if((myColor & MagicColor.WUBRG[nextBit]) != 0) {
|
if ((myColor & MagicColor.WUBRG[nextBit]) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nextBit++;
|
nextBit++;
|
||||||
|
|||||||
@@ -6,16 +6,15 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
/**
|
/**
|
||||||
* Holds byte values for each color magic has.
|
* Holds byte values for each color magic has.
|
||||||
*/
|
*/
|
||||||
public class MagicColor {
|
public final class MagicColor {
|
||||||
|
|
||||||
public static final byte COLORLESS = 0;
|
public static final byte COLORLESS = 0;
|
||||||
public static final byte WHITE = 1 << 0;
|
public static final byte WHITE = 1 << 0;
|
||||||
public static final byte BLUE = 1 << 1;
|
public static final byte BLUE = 1 << 1;
|
||||||
public static final byte BLACK = 1 << 2;
|
public static final byte BLACK = 1 << 2;
|
||||||
public static final byte RED = 1 << 3;
|
public static final byte RED = 1 << 3;
|
||||||
public static final byte GREEN = 1 << 4;
|
public static final byte GREEN = 1 << 4;
|
||||||
|
|
||||||
public static final byte ALL_COLORS = WHITE | BLUE | BLACK | RED | GREEN;
|
|
||||||
public static final int NUMBER_OR_COLORS = 5;
|
public static final int NUMBER_OR_COLORS = 5;
|
||||||
|
|
||||||
public static final byte[] WUBRG = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
public static final byte[] WUBRG = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
||||||
@@ -37,30 +36,19 @@ public class MagicColor {
|
|||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
if (s.length() == 1) {
|
if (s.length() == 1) {
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case "w":
|
case "w": return MagicColor.WHITE;
|
||||||
return MagicColor.WHITE;
|
case "u": return MagicColor.BLUE;
|
||||||
case "u":
|
case "b": return MagicColor.BLACK;
|
||||||
return MagicColor.BLUE;
|
case "r": return MagicColor.RED;
|
||||||
case "b":
|
case "g": return MagicColor.GREEN;
|
||||||
return MagicColor.BLACK;
|
|
||||||
case "r":
|
|
||||||
return MagicColor.RED;
|
|
||||||
case "g":
|
|
||||||
return MagicColor.GREEN;
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case Constant.WHITE:
|
case Constant.WHITE: return MagicColor.WHITE;
|
||||||
return MagicColor.WHITE;
|
case Constant.BLUE: return MagicColor.BLUE;
|
||||||
case Constant.BLUE:
|
case Constant.BLACK: return MagicColor.BLACK;
|
||||||
return MagicColor.BLUE;
|
case Constant.RED: return MagicColor.RED;
|
||||||
case Constant.BLACK:
|
case Constant.GREEN: return MagicColor.GREEN;
|
||||||
return MagicColor.BLACK;
|
|
||||||
case Constant.RED:
|
|
||||||
return MagicColor.RED;
|
|
||||||
case Constant.GREEN:
|
|
||||||
return MagicColor.GREEN;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0; // colorless
|
return 0; // colorless
|
||||||
@@ -68,39 +56,41 @@ public class MagicColor {
|
|||||||
|
|
||||||
public static byte fromName(final char c) {
|
public static byte fromName(final char c) {
|
||||||
switch (Character.toLowerCase(c)) {
|
switch (Character.toLowerCase(c)) {
|
||||||
case 'w': return MagicColor.WHITE;
|
case 'w': return MagicColor.WHITE;
|
||||||
case 'u': return MagicColor.BLUE;
|
case 'u': return MagicColor.BLUE;
|
||||||
case 'b': return MagicColor.BLACK;
|
case 'b': return MagicColor.BLACK;
|
||||||
case 'r': return MagicColor.RED;
|
case 'r': return MagicColor.RED;
|
||||||
case 'g': return MagicColor.GREEN;
|
case 'g': return MagicColor.GREEN;
|
||||||
}
|
}
|
||||||
return 0; // unknown means 'colorless'
|
return 0; // unknown means 'colorless'
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toShortString(final String color) {
|
public static String toShortString(final String color) {
|
||||||
if (color.equalsIgnoreCase(Constant.SNOW)) { return "S"; } // compatibility
|
if (color.equalsIgnoreCase(Constant.SNOW)) {
|
||||||
|
return "S";
|
||||||
|
} // compatibility
|
||||||
return toShortString(fromName(color));
|
return toShortString(fromName(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toShortString(final byte color) {
|
public static String toShortString(final byte color) {
|
||||||
switch (color){
|
switch (color){
|
||||||
case WHITE: return "W";
|
case WHITE: return "W";
|
||||||
case BLUE: return "U";
|
case BLUE: return "U";
|
||||||
case BLACK: return "B";
|
case BLACK: return "B";
|
||||||
case RED: return "R";
|
case RED: return "R";
|
||||||
case GREEN: return "G";
|
case GREEN: return "G";
|
||||||
default: return "1";
|
default: return "1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toLongString(final byte color) {
|
public static String toLongString(final byte color) {
|
||||||
switch (color){
|
switch (color){
|
||||||
case WHITE: return Constant.WHITE;
|
case WHITE: return Constant.WHITE;
|
||||||
case BLUE: return Constant.BLUE;
|
case BLUE: return Constant.BLUE;
|
||||||
case BLACK: return Constant.BLACK;
|
case BLACK: return Constant.BLACK;
|
||||||
case RED: return Constant.RED;
|
case RED: return Constant.RED;
|
||||||
case GREEN: return Constant.GREEN ;
|
case GREEN: return Constant.GREEN ;
|
||||||
default: return Constant.COLORLESS;
|
default: return Constant.COLORLESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.game.ability;
|
|||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
@@ -1494,9 +1495,9 @@ public class AbilityUtils {
|
|||||||
String convertTo = params.get(key);
|
String convertTo = params.get(key);
|
||||||
byte convertByte = 0;
|
byte convertByte = 0;
|
||||||
if ("All".equals(convertTo)) {
|
if ("All".equals(convertTo)) {
|
||||||
convertByte = MagicColor.ALL_COLORS;
|
convertByte = ColorSet.ALL_COLORS.getColor();
|
||||||
} else{
|
} else {
|
||||||
for(String convertColor : convertTo.split(",")) {
|
for (final String convertColor : convertTo.split(",")) {
|
||||||
convertByte |= MagicColor.fromName(convertColor);
|
convertByte |= MagicColor.fromName(convertColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
|||||||
final String[] changedColorWordsArray = sa.getParam("ChangeColorWord").split(" ");
|
final String[] changedColorWordsArray = sa.getParam("ChangeColorWord").split(" ");
|
||||||
if (changedColorWordsArray[0].equals("Choose")) {
|
if (changedColorWordsArray[0].equals("Choose")) {
|
||||||
originalColor = sa.getActivatingPlayer().getController().chooseColor(
|
originalColor = sa.getActivatingPlayer().getController().chooseColor(
|
||||||
"Choose a color word to replace", sa, ColorSet.fromMask(MagicColor.ALL_COLORS));
|
"Choose a color word to replace", sa, ColorSet.ALL_COLORS);
|
||||||
changedColorWordOriginal = TextUtil.capitalize(MagicColor.toLongString(originalColor));
|
changedColorWordOriginal = TextUtil.capitalize(MagicColor.toLongString(originalColor));
|
||||||
} else {
|
} else {
|
||||||
changedColorWordOriginal = changedColorWordsArray[0];
|
changedColorWordOriginal = changedColorWordsArray[0];
|
||||||
@@ -43,7 +43,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
|||||||
if (changedColorWordsArray[1].equals("Choose")) {
|
if (changedColorWordsArray[1].equals("Choose")) {
|
||||||
final ColorSet possibleNewColors;
|
final ColorSet possibleNewColors;
|
||||||
if (originalColor == 0) { // no original color (ie. any or absent)
|
if (originalColor == 0) { // no original color (ie. any or absent)
|
||||||
possibleNewColors = ColorSet.fromMask(MagicColor.ALL_COLORS);
|
possibleNewColors = ColorSet.ALL_COLORS;
|
||||||
} else { // may choose any except original color
|
} else { // may choose any except original color
|
||||||
possibleNewColors = ColorSet.fromMask(originalColor).inverse();
|
possibleNewColors = ColorSet.fromMask(originalColor).inverse();
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
|||||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected String getStackDescription(SpellAbility sa) {
|
protected String getStackDescription(final SpellAbility sa) {
|
||||||
final String changedColorWordOriginal, changedColorWordNew;
|
final String changedColorWordOriginal, changedColorWordNew;
|
||||||
if (sa.hasParam("ChangeColorWord")) {
|
if (sa.hasParam("ChangeColorWord")) {
|
||||||
final String[] changedColorWordsArray = sa.getParam("ChangeColorWord").split(" ");
|
final String[] changedColorWordsArray = sa.getParam("ChangeColorWord").split(" ");
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class ManaEffect extends SpellAbilityEffect {
|
|||||||
for (int nChar = 0; nChar < colorsNeeded.length(); nChar++) {
|
for (int nChar = 0; nChar < colorsNeeded.length(); nChar++) {
|
||||||
mask |= MagicColor.fromName(colorsNeeded.charAt(nChar));
|
mask |= MagicColor.fromName(colorsNeeded.charAt(nChar));
|
||||||
}
|
}
|
||||||
colorMenu = ColorSet.fromMask(mask == 0 ? MagicColor.ALL_COLORS : mask);
|
colorMenu = mask == 0 ? ColorSet.ALL_COLORS : ColorSet.fromMask(mask);
|
||||||
byte val = act.getController().chooseColor("Select Mana to Produce", sa, colorMenu);
|
byte val = act.getController().chooseColor("Select Mana to Produce", sa, colorMenu);
|
||||||
if (0 == val) {
|
if (0 == val) {
|
||||||
throw new RuntimeException("ManaEffect::resolve() /*any mana*/ - " + act + " color mana choice is empty for " + card.getName());
|
throw new RuntimeException("ManaEffect::resolve() /*any mana*/ - " + act + " color mana choice is empty for " + card.getName());
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ public class ManaCostBeingPaid {
|
|||||||
|
|
||||||
if (bill.isMonoColor()) {
|
if (bill.isMonoColor()) {
|
||||||
if (bill.isOr2Colorless()) {
|
if (bill.isOr2Colorless()) {
|
||||||
return (bill.getColorMask() & paymentColor & MagicColor.ALL_COLORS) != 0? 9 : 4;
|
return !ColorSet.fromMask(bill.getColorMask() & paymentColor).isColorless() ? 9 : 4;
|
||||||
}
|
}
|
||||||
if (!bill.isPhyrexian()) {
|
if (!bill.isPhyrexian()) {
|
||||||
return 10;
|
return 10;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
import forge.game.GlobalRuleChange;
|
import forge.game.GlobalRuleChange;
|
||||||
@@ -368,7 +369,7 @@ public class ManaPool implements Iterable<Mana> {
|
|||||||
colorConversionMatrix[i] = identityMatrix[i];
|
colorConversionMatrix[i] = identityMatrix[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
|
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
|
||||||
colorRestrictionMatrix[i] = MagicColor.ALL_COLORS;
|
colorRestrictionMatrix[i] = ColorSet.ALL_COLORS.getColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package forge.game.player;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import forge.card.MagicColor;
|
import forge.card.ColorSet;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
@@ -15,17 +15,17 @@ public class AchievementTracker {
|
|||||||
public int maxStormCount = 0;
|
public int maxStormCount = 0;
|
||||||
public int landsPlayed = 0;
|
public int landsPlayed = 0;
|
||||||
|
|
||||||
public void onSpellAbilityPlayed(SpellAbility sa) {
|
public void onSpellAbilityPlayed(final SpellAbility sa) {
|
||||||
final Card card = sa.getHostCard();
|
final Card card = sa.getHostCard();
|
||||||
if (sa.getRestrictions().isPwAbility() && sa.hasParam("Ultimate")) {
|
if (sa.getRestrictions().isPwAbility() && sa.hasParam("Ultimate")) {
|
||||||
activatedUltimates.add(card.getName());
|
activatedUltimates.add(card.getName());
|
||||||
}
|
}
|
||||||
if (card.determineColor().getColor() == MagicColor.ALL_COLORS) {
|
if (card.determineColor().equals(ColorSet.ALL_COLORS)) {
|
||||||
challengesCompleted.add("Chromatic");
|
challengesCompleted.add("Chromatic");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSpellResolve(SpellAbility spell) {
|
public void onSpellResolve(final SpellAbility spell) {
|
||||||
final Card card = spell.getHostCard();
|
final Card card = spell.getHostCard();
|
||||||
if (card.hasKeyword("Epic")) {
|
if (card.hasKeyword("Epic")) {
|
||||||
challengesCompleted.add("Epic");
|
challengesCompleted.add("Epic");
|
||||||
|
|||||||
@@ -619,14 +619,14 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
if (manaReplace.startsWith("Any")) {
|
if (manaReplace.startsWith("Any")) {
|
||||||
// Replace any type and amount
|
// Replace any type and amount
|
||||||
String replaced = manaReplace.split("->")[1];
|
String replaced = manaReplace.split("->")[1];
|
||||||
if (replaced.equals("Any")) {
|
if (replaced.equals("Any")) {
|
||||||
byte rs = MagicColor.GREEN;
|
byte rs = MagicColor.GREEN;
|
||||||
if (act != null) {
|
if (act != null) {
|
||||||
rs = act.getController().chooseColor("Choose a color", sa, ColorSet.fromMask(MagicColor.ALL_COLORS));
|
rs = act.getController().chooseColor("Choose a color", sa, ColorSet.ALL_COLORS);
|
||||||
}
|
}
|
||||||
replaced = MagicColor.toShortString(rs);
|
replaced = MagicColor.toShortString(rs);
|
||||||
}
|
}
|
||||||
return replaced;
|
return replaced;
|
||||||
}
|
}
|
||||||
final Pattern splitter = Pattern.compile("->");
|
final Pattern splitter = Pattern.compile("->");
|
||||||
@@ -657,7 +657,7 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
while (replaced.contains("Any")) {
|
while (replaced.contains("Any")) {
|
||||||
byte rs = MagicColor.GREEN;
|
byte rs = MagicColor.GREEN;
|
||||||
if (act != null) {
|
if (act != null) {
|
||||||
rs = act.getController().chooseColor("Choose a color", sa, ColorSet.fromMask(MagicColor.ALL_COLORS));
|
rs = act.getController().chooseColor("Choose a color", sa, ColorSet.ALL_COLORS);
|
||||||
}
|
}
|
||||||
replaced = replaced.replaceFirst("Any", MagicColor.toShortString(rs));
|
replaced = replaced.replaceFirst("Any", MagicColor.toShortString(rs));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,29 +176,25 @@ public class SFilterUtil {
|
|||||||
if (wantMulticolor) {
|
if (wantMulticolor) {
|
||||||
if (colors == 0) { //handle showing all multi-color cards if all 5 colors are filtered
|
if (colors == 0) { //handle showing all multi-color cards if all 5 colors are filtered
|
||||||
result = color.isMulticolor() || (wantColorless && color.isColorless());
|
result = color.isMulticolor() || (wantColorless && color.isColorless());
|
||||||
}
|
} else if (colors != ColorSet.ALL_COLORS.getColor()) {
|
||||||
else if (colors != MagicColor.ALL_COLORS) {
|
|
||||||
if (useColorIdentity) {
|
if (useColorIdentity) {
|
||||||
result = color.hasAllColors(colors);
|
result = color.hasAllColors(colors);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result = rules.canCastWithAvailable(colors);
|
result = rules.canCastWithAvailable(colors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result = !color.isMulticolor();
|
result = !color.isMulticolor();
|
||||||
if (colors != MagicColor.ALL_COLORS) {
|
if (colors != ColorSet.ALL_COLORS.getColor()) {
|
||||||
if (useColorIdentity) {
|
if (useColorIdentity) {
|
||||||
result = result && color.hasAnyColor(colors);
|
result = result && color.hasAnyColor(colors);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result = result && rules.canCastWithAvailable(colors);
|
result = result && rules.canCastWithAvailable(colors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!wantColorless) {
|
if (!wantColorless) {
|
||||||
if (colors != 0 && colors != MagicColor.ALL_COLORS) {
|
if (colors != 0 && colors != ColorSet.ALL_COLORS.getColor()) {
|
||||||
//if colorless filtered out ensure phyrexian cards don't appear
|
//if colorless filtered out ensure phyrexian cards don't appear
|
||||||
//unless at least one of their colors is selected
|
//unless at least one of their colors is selected
|
||||||
result = result && color.hasAnyColor(colors);
|
result = result && color.hasAnyColor(colors);
|
||||||
|
|||||||
@@ -6,75 +6,67 @@
|
|||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.limited;
|
package forge.limited;
|
||||||
|
|
||||||
import forge.card.ColorSet;
|
|
||||||
import forge.card.MagicColor;
|
|
||||||
import forge.card.mana.ManaCost;
|
|
||||||
import forge.item.IPaperCard;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
import forge.card.ColorSet;
|
||||||
* Created by IntelliJ IDEA. User: dhudson Date: 6/24/11 Time: 8:42 PM To change
|
import forge.card.MagicColor;
|
||||||
* this template use File | Settings | File Templates.
|
import forge.item.IPaperCard;
|
||||||
*/
|
|
||||||
class DeckColors {
|
class DeckColors {
|
||||||
|
|
||||||
private ColorSet chosen;
|
private ColorSet chosen;
|
||||||
private int colorMask;
|
private int colorMask;
|
||||||
|
|
||||||
public final static int MAX_COLORS = 2;
|
public final static int MAX_COLORS = 2;
|
||||||
// public String Splash = "none";
|
|
||||||
|
|
||||||
public ColorSet getChosenColors() {
|
public ColorSet getChosenColors() {
|
||||||
if ( null == chosen )
|
if (null == chosen) {
|
||||||
chosen = ColorSet.fromMask(colorMask);
|
chosen = ColorSet.fromMask(colorMask);
|
||||||
return chosen;
|
}
|
||||||
|
return chosen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void addColorsOf(final IPaperCard pickedCard) {
|
||||||
* TODO: Write javadoc for this method.
|
final ColorSet colorsCanAdd = chosen.inverse();
|
||||||
* @param pickedCard
|
final ColorSet toAdd = colorsCanAdd.getSharedColors(pickedCard.getRules().getColor());
|
||||||
*/
|
|
||||||
public void addColorsOf(IPaperCard pickedCard) {
|
|
||||||
|
|
||||||
ManaCost colorsInCard = pickedCard.getRules().getManaCost();
|
|
||||||
|
|
||||||
int colorsCanAdd = MagicColor.ALL_COLORS & ~getChosenColors().getColor();
|
|
||||||
int colorsWantAdd = colorsInCard.getColorProfile() & colorsCanAdd;
|
|
||||||
ColorSet toAdd = ColorSet.fromMask(colorsWantAdd);
|
|
||||||
|
|
||||||
int cntColorsAssigned = getChosenColors().countColors();
|
int cntColorsAssigned = getChosenColors().countColors();
|
||||||
boolean haveSpace = cntColorsAssigned < MAX_COLORS;
|
final boolean haveSpace = cntColorsAssigned < MAX_COLORS;
|
||||||
if( !haveSpace || toAdd.isColorless() )
|
if (!haveSpace || toAdd.isColorless()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < MagicColor.NUMBER_OR_COLORS && cntColorsAssigned < MAX_COLORS; i++ )
|
for (final byte color : MagicColor.WUBRG) {
|
||||||
if (( colorsWantAdd & MagicColor.WHITE << i ) > 0) {
|
if (toAdd.hasAnyColor(color)) {
|
||||||
colorMask |= MagicColor.WHITE << i;
|
colorMask |= color;
|
||||||
chosen = null; // invalidate color set
|
chosen = null; // invalidate color set
|
||||||
cntColorsAssigned++;
|
cntColorsAssigned++;
|
||||||
|
}
|
||||||
|
if (cntColorsAssigned >= MAX_COLORS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColorsByList(List<Byte> colors) {
|
public void setColorsByList(final List<Byte> colors) {
|
||||||
colorMask = 0;
|
colorMask = 0;
|
||||||
for (Byte col : colors) {
|
for (final Byte col : colors) {
|
||||||
colorMask |= col;
|
colorMask |= col.byteValue();
|
||||||
}
|
}
|
||||||
chosen = null;
|
chosen = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean canChoseMoreColors() {
|
public boolean canChoseMoreColors() {
|
||||||
return getChosenColors().countColors() < MAX_COLORS;
|
return getChosenColors().countColors() < MAX_COLORS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
|
|
||||||
// If the card has any ability that tracks mana spent, skip express Mana choice
|
// If the card has any ability that tracks mana spent, skip express Mana choice
|
||||||
if (saPaidFor.tracksManaSpent()) {
|
if (saPaidFor.tracksManaSpent()) {
|
||||||
colorCanUse = MagicColor.ALL_COLORS;
|
colorCanUse = ColorSet.ALL_COLORS.getColor();
|
||||||
guessAbilityWithRequiredColors = false;
|
guessAbilityWithRequiredColors = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public enum ConquestPlane {
|
|||||||
new Region("Auntie's Hovel", "Auntie's Hovel", MagicColor.BLACK | MagicColor.RED),
|
new Region("Auntie's Hovel", "Auntie's Hovel", MagicColor.BLACK | MagicColor.RED),
|
||||||
new Region("Gilt-Leaf Palace", "Gilt-Leaf Palace", MagicColor.BLACK | MagicColor.GREEN),
|
new Region("Gilt-Leaf Palace", "Gilt-Leaf Palace", MagicColor.BLACK | MagicColor.GREEN),
|
||||||
new Region("Murmuring Bosk", "Murmuring Bosk", MagicColor.WHITE | MagicColor.BLACK | MagicColor.GREEN),
|
new Region("Murmuring Bosk", "Murmuring Bosk", MagicColor.WHITE | MagicColor.BLACK | MagicColor.GREEN),
|
||||||
new Region("Primal Beyond", "Primal Beyond", MagicColor.ALL_COLORS),
|
new Region("Primal Beyond", "Primal Beyond", ColorSet.ALL_COLORS.getColor()),
|
||||||
new Region("Rustic Clachan", "Rustic Clachan", MagicColor.GREEN | MagicColor.WHITE),
|
new Region("Rustic Clachan", "Rustic Clachan", MagicColor.GREEN | MagicColor.WHITE),
|
||||||
new Region("Secluded Glen", "Secluded Glen", MagicColor.BLUE | MagicColor.BLACK),
|
new Region("Secluded Glen", "Secluded Glen", MagicColor.BLUE | MagicColor.BLACK),
|
||||||
new Region("Wanderwine Hub", "Wanderwine Hub", MagicColor.WHITE | MagicColor.BLUE),
|
new Region("Wanderwine Hub", "Wanderwine Hub", MagicColor.WHITE | MagicColor.BLUE),
|
||||||
@@ -116,7 +116,7 @@ public enum ConquestPlane {
|
|||||||
new Region("Ish Sah", "Vault of Whispers", MagicColor.BLACK),
|
new Region("Ish Sah", "Vault of Whispers", MagicColor.BLACK),
|
||||||
new Region("Kuldotha", "Great Furnace", MagicColor.RED),
|
new Region("Kuldotha", "Great Furnace", MagicColor.RED),
|
||||||
new Region("Tel-Jilad", "Tree of Tales", MagicColor.GREEN),
|
new Region("Tel-Jilad", "Tree of Tales", MagicColor.GREEN),
|
||||||
new Region("Glimmervoid", "Glimmervoid", MagicColor.ALL_COLORS)
|
new Region("Glimmervoid", "Glimmervoid", ColorSet.ALL_COLORS.getColor())
|
||||||
}),
|
}),
|
||||||
Rath("Rath", new String[] {
|
Rath("Rath", new String[] {
|
||||||
"TMP", "STH", "EXO"
|
"TMP", "STH", "EXO"
|
||||||
@@ -299,7 +299,7 @@ public enum ConquestPlane {
|
|||||||
name = name0;
|
name = name0;
|
||||||
artCardName = artCardName0;
|
artCardName = artCardName0;
|
||||||
pred = pred0;
|
pred = pred0;
|
||||||
colorSet = ColorSet.fromMask(MagicColor.ALL_COLORS);
|
colorSet = ColorSet.fromMask(ColorSet.ALL_COLORS.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ public class ConquestUtil {
|
|||||||
availableCards.remove(commander);
|
availableCards.remove(commander);
|
||||||
|
|
||||||
//remove any cards that aren't allowed in deck due to color identity
|
//remove any cards that aren't allowed in deck due to color identity
|
||||||
byte colorIdentity = commander.getRules().getColorIdentity().getColor();
|
final ColorSet colorIdentity = commander.getRules().getColorIdentity();
|
||||||
if (colorIdentity != MagicColor.ALL_COLORS) {
|
if (!colorIdentity.equals(ColorSet.ALL_COLORS)) {
|
||||||
List<PaperCard> invalidCards = new ArrayList<PaperCard>();
|
List<PaperCard> invalidCards = new ArrayList<PaperCard>();
|
||||||
for (PaperCard pc : availableCards) {
|
for (PaperCard pc : availableCards) {
|
||||||
if (!pc.getRules().getColorIdentity().hasNoColorsExcept(colorIdentity)) {
|
if (!pc.getRules().getColorIdentity().hasNoColorsExcept(colorIdentity)) {
|
||||||
@@ -119,7 +119,7 @@ public class ConquestUtil {
|
|||||||
|
|
||||||
String setCode = FModel.getConquest().getModel().getCurrentPlane().getEditions().get(0).getCode();
|
String setCode = FModel.getConquest().getModel().getCurrentPlane().getEditions().get(0).getCode();
|
||||||
for (int i = 0; i < MagicColor.WUBRG.length; i++) {
|
for (int i = 0; i < MagicColor.WUBRG.length; i++) {
|
||||||
if ((colorIdentity & MagicColor.WUBRG[i]) != 0) {
|
if (colorIdentity.hasAnyColor(MagicColor.WUBRG[i])) {
|
||||||
pool.add(MagicColor.Constant.BASIC_LANDS.get(i), setCode, 50);
|
pool.add(MagicColor.Constant.BASIC_LANDS.get(i), setCode, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user