From cd5ee18525c436a7e309295f00c6ee5c0ea5e39c Mon Sep 17 00:00:00 2001 From: Sol Date: Thu, 14 Jan 2016 21:26:27 +0000 Subject: [PATCH] - Fixing Colorless costs so they can't be paid by Colored mana for Humans (This may prevent AI from paying Colorless costs) --- forge-core/src/main/java/forge/card/MagicColor.java | 5 +++-- forge-core/src/main/java/forge/card/mana/ManaAtom.java | 7 +++---- .../src/main/java/forge/card/mana/ManaCostShard.java | 3 ++- forge-game/src/main/java/forge/game/mana/ManaPool.java | 9 +++++++-- .../src/main/java/forge/match/input/InputPayMana.java | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/forge-core/src/main/java/forge/card/MagicColor.java b/forge-core/src/main/java/forge/card/MagicColor.java index 05daf58e602..5e7824c9bec 100644 --- a/forge-core/src/main/java/forge/card/MagicColor.java +++ b/forge-core/src/main/java/forge/card/MagicColor.java @@ -9,12 +9,13 @@ import com.google.common.collect.ImmutableMap; */ 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 BLUE = 1 << 1; public static final byte BLACK = 1 << 2; public static final byte RED = 1 << 3; public static final byte GREEN = 1 << 4; + public static final byte COLORLESS = 1 << 5; public static final int NUMBER_OR_COLORS = 5; @@ -82,7 +83,7 @@ public final class MagicColor { case BLACK: return "B"; case RED: return "R"; case GREEN: return "G"; - default: return "1"; + default: return "C"; } } diff --git a/forge-core/src/main/java/forge/card/mana/ManaAtom.java b/forge-core/src/main/java/forge/card/mana/ManaAtom.java index 68c7306d94e..bdf52e1cfd9 100644 --- a/forge-core/src/main/java/forge/card/mana/ManaAtom.java +++ b/forge-core/src/main/java/forge/card/mana/ManaAtom.java @@ -4,8 +4,6 @@ import forge.card.MagicColor; /** A bitmask to represent any mana symbol as an integer. */ public abstract class ManaAtom { - public static final int GENERIC = 1 << 6; - /** The Constant WHITE. */ public static final int WHITE = MagicColor.WHITE; @@ -21,6 +19,9 @@ public abstract class ManaAtom { /** The Constant 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. */ public static final int IS_X = 1 << 8; @@ -32,6 +33,4 @@ public abstract class ManaAtom { /** The Constant IS_SNOW. */ public static final int IS_SNOW = 1 << 11; - - public static final int COLORLESS = 1 << 12; } \ No newline at end of file diff --git a/forge-core/src/main/java/forge/card/mana/ManaCostShard.java b/forge-core/src/main/java/forge/card/mana/ManaCostShard.java index 76f2ff932b4..8683d89eff6 100644 --- a/forge-core/src/main/java/forge/card/mana/ManaCostShard.java +++ b/forge-core/src/main/java/forge/card/mana/ManaCostShard.java @@ -289,6 +289,7 @@ public enum ManaCostShard { } 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; } } diff --git a/forge-game/src/main/java/forge/game/mana/ManaPool.java b/forge-game/src/main/java/forge/game/mana/ManaPool.java index f3e822f75db..b51b7eb1ed8 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -348,8 +348,8 @@ public class ManaPool implements Iterable { // Conversion matrix ORs byte values to make mana more payable // Restrictive matrix ANDs byte values to make mana less payable - private final byte[] colorConversionMatrix = new byte[MagicColor.WUBRG.length + 1]; - private final byte[] colorRestrictionMatrix = new byte[MagicColor.WUBRG.length + 1]; + private final byte[] colorConversionMatrix = new byte[MagicColor.WUBRGC.length]; + 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 }; public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) { @@ -391,6 +391,11 @@ public class ManaPool implements Iterable { return true; } } + + if (((color & (byte) MagicColor.COLORLESS) != 0) && shard.canBePaidWithManaOfColor((byte) MagicColor.COLORLESS)) { + return true; + } + return shard.canBePaidWithManaOfColor((byte)0); } diff --git a/forge-gui/src/main/java/forge/match/input/InputPayMana.java b/forge-gui/src/main/java/forge/match/input/InputPayMana.java index 2da53483a14..59efb5cb2c4 100644 --- a/forge-gui/src/main/java/forge/match/input/InputPayMana.java +++ b/forge-gui/src/main/java/forge/match/input/InputPayMana.java @@ -124,7 +124,7 @@ public abstract class InputPayMana extends InputSyncronizedBase { } byte colorCanUse = 0; - for (final byte color : MagicColor.WUBRG) { + for (final byte color : MagicColor.WUBRGC) { if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) { colorCanUse |= color; } @@ -179,7 +179,7 @@ public abstract class InputPayMana extends InputSyncronizedBase { byte colorCanUse = 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.needsColor(color, player.getManaPool())) { colorNeeded |= color; } }