mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
- Fixing Colorless costs so they can't be paid by Colored mana for Humans (This may prevent AI from paying Colorless costs)
This commit is contained in:
@@ -9,12 +9,13 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
*/
|
*/
|
||||||
public final class MagicColor {
|
public final class MagicColor {
|
||||||
|
|
||||||
public static final byte COLORLESS = 0;
|
// Colorless value synchronized with value in ManaAtom
|
||||||
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 COLORLESS = 1 << 5;
|
||||||
|
|
||||||
public static final int NUMBER_OR_COLORS = 5;
|
public static final int NUMBER_OR_COLORS = 5;
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ public final class MagicColor {
|
|||||||
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 "C";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import forge.card.MagicColor;
|
|||||||
|
|
||||||
/** A bitmask to represent any mana symbol as an integer. */
|
/** A bitmask to represent any mana symbol as an integer. */
|
||||||
public abstract class ManaAtom {
|
public abstract class ManaAtom {
|
||||||
public static final int GENERIC = 1 << 6;
|
|
||||||
|
|
||||||
/** The Constant WHITE. */
|
/** The Constant WHITE. */
|
||||||
public static final int WHITE = MagicColor.WHITE;
|
public static final int WHITE = MagicColor.WHITE;
|
||||||
|
|
||||||
@@ -21,6 +19,9 @@ public abstract class ManaAtom {
|
|||||||
/** The Constant GREEN. */
|
/** The Constant GREEN. */
|
||||||
public static final int GREEN = MagicColor.GREEN;
|
public static final int GREEN = MagicColor.GREEN;
|
||||||
|
|
||||||
|
public static final int COLORLESS = MagicColor.COLORLESS;
|
||||||
|
public static final int GENERIC = 1 << 6;
|
||||||
|
|
||||||
/** The Constant IS_X. */
|
/** The Constant IS_X. */
|
||||||
public static final int IS_X = 1 << 8;
|
public static final int IS_X = 1 << 8;
|
||||||
|
|
||||||
@@ -32,6 +33,4 @@ public abstract class ManaAtom {
|
|||||||
|
|
||||||
/** The Constant IS_SNOW. */
|
/** The Constant IS_SNOW. */
|
||||||
public static final int IS_SNOW = 1 << 11;
|
public static final int IS_SNOW = 1 << 11;
|
||||||
|
|
||||||
public static final int COLORLESS = 1 << 12;
|
|
||||||
}
|
}
|
||||||
@@ -289,6 +289,7 @@ public enum ManaCostShard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBePaidWithManaOfColor(byte colorCode) {
|
public boolean canBePaidWithManaOfColor(byte colorCode) {
|
||||||
return this.isOr2Generic() || (COLORS_SUPERPOSITION & this.shard) == 0 || (colorCode & this.shard) > 0;
|
return this.isOr2Generic() || ((COLORS_SUPERPOSITION | ManaAtom.COLORLESS) & this.shard) == 0 ||
|
||||||
|
(colorCode & this.shard) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,8 +348,8 @@ public class ManaPool implements Iterable<Mana> {
|
|||||||
|
|
||||||
// Conversion matrix ORs byte values to make mana more payable
|
// Conversion matrix ORs byte values to make mana more payable
|
||||||
// Restrictive matrix ANDs byte values to make mana less payable
|
// Restrictive matrix ANDs byte values to make mana less payable
|
||||||
private final byte[] colorConversionMatrix = new byte[MagicColor.WUBRG.length + 1];
|
private final byte[] colorConversionMatrix = new byte[MagicColor.WUBRGC.length];
|
||||||
private final byte[] colorRestrictionMatrix = new byte[MagicColor.WUBRG.length + 1];
|
private final byte[] colorRestrictionMatrix = new byte[MagicColor.WUBRGC.length];
|
||||||
private static final byte[] identityMatrix = { MagicColor.WHITE, MagicColor.BLUE, MagicColor.BLACK, MagicColor.RED, MagicColor.GREEN, 0 };
|
private static final byte[] identityMatrix = { MagicColor.WHITE, MagicColor.BLUE, MagicColor.BLACK, MagicColor.RED, MagicColor.GREEN, 0 };
|
||||||
|
|
||||||
public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) {
|
public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) {
|
||||||
@@ -391,6 +391,11 @@ public class ManaPool implements Iterable<Mana> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (((color & (byte) MagicColor.COLORLESS) != 0) && shard.canBePaidWithManaOfColor((byte) MagicColor.COLORLESS)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return shard.canBePaidWithManaOfColor((byte)0);
|
return shard.canBePaidWithManaOfColor((byte)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte colorCanUse = 0;
|
byte colorCanUse = 0;
|
||||||
for (final byte color : MagicColor.WUBRG) {
|
for (final byte color : MagicColor.WUBRGC) {
|
||||||
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) {
|
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) {
|
||||||
colorCanUse |= color;
|
colorCanUse |= color;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
byte colorCanUse = 0;
|
byte colorCanUse = 0;
|
||||||
byte colorNeeded = 0;
|
byte colorNeeded = 0;
|
||||||
|
|
||||||
for (final byte color : MagicColor.WUBRG) {
|
for (final byte color : MagicColor.WUBRGC) {
|
||||||
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) { colorCanUse |= color; }
|
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) { colorCanUse |= color; }
|
||||||
if (manaCost.needsColor(color, player.getManaPool())) { colorNeeded |= color; }
|
if (manaCost.needsColor(color, player.getManaPool())) { colorNeeded |= color; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user