From d47bd3daf632c637246241c39ecb06a45f770b8f Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Feb 2021 09:28:16 +0100 Subject: [PATCH] add MayPlaySnowIgnoreColor for Draugr Necromancer --- .../java/forge/game/card/CardPlayOption.java | 8 ++++-- .../forge/game/mana/ManaConversionMatrix.java | 26 +++++++++++++++++-- .../forge/game/mana/ManaCostBeingPaid.java | 5 ++++ .../main/java/forge/game/mana/ManaPool.java | 10 ------- .../upcoming/draugr_necromancer.txt | 11 ++++++++ .../forge/player/HumanPlaySpellAbility.java | 4 +++ 6 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 forge-gui/res/cardsfolder/upcoming/draugr_necromancer.txt diff --git a/forge-game/src/main/java/forge/game/card/CardPlayOption.java b/forge-game/src/main/java/forge/game/card/CardPlayOption.java index 3c2cb2e699e..8692ffaf709 100644 --- a/forge-game/src/main/java/forge/game/card/CardPlayOption.java +++ b/forge-game/src/main/java/forge/game/card/CardPlayOption.java @@ -54,11 +54,15 @@ public final class CardPlayOption { public boolean isIgnoreManaCostColor() { return sta.hasParam("MayPlayIgnoreColor"); } - + public boolean isIgnoreManaCostType() { return sta.hasParam("MayPlayIgnoreType"); } - + + public boolean isIgnoreSnowSourceManaCostColor() { + return sta.hasParam("MayPlaySnowIgnoreColor"); + } + public boolean isWithFlash() { return withFlash; } diff --git a/forge-game/src/main/java/forge/game/mana/ManaConversionMatrix.java b/forge-game/src/main/java/forge/game/mana/ManaConversionMatrix.java index e8caf56d774..76938cafcd5 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaConversionMatrix.java +++ b/forge-game/src/main/java/forge/game/mana/ManaConversionMatrix.java @@ -7,8 +7,28 @@ public class ManaConversionMatrix { // Conversion matrix ORs byte values to make mana more payable // Restrictive matrix ANDs byte values to make mana less payable - byte[] colorConversionMatrix = new byte[ManaAtom.MANATYPES.length]; - byte[] colorRestrictionMatrix = new byte[ManaAtom.MANATYPES.length]; + protected byte[] colorConversionMatrix = new byte[ManaAtom.MANATYPES.length]; + protected byte[] colorRestrictionMatrix = new byte[ManaAtom.MANATYPES.length]; + + protected boolean snowForColor = false; + + public boolean isSnowForColor() { + return snowForColor; + } + + public void setSnowForColor(boolean value) { + snowForColor = value; + } + + public byte getPossibleColorUses(byte color) { + // Take the current conversion value, AND with restrictions to get mana usage + int rowIdx = ManaAtom.getIndexOfFirstManaType(color); + int matrixIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx; + + byte colorUse = colorConversionMatrix[matrixIdx]; + colorUse &= colorRestrictionMatrix[matrixIdx]; + return colorUse; + } public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) { // Fix the index without hardcodes @@ -30,6 +50,7 @@ public class ManaConversionMatrix { for (int i = 0; i < colorRestrictionMatrix.length; i++) { colorRestrictionMatrix[i] &= extraMatrix.colorRestrictionMatrix[i]; } + setSnowForColor(extraMatrix.isSnowForColor()); } public void restoreColorReplacements() { @@ -41,5 +62,6 @@ public class ManaConversionMatrix { for (int i = 0; i < colorRestrictionMatrix.length; i++) { colorRestrictionMatrix[i] = ManaAtom.ALL_MANA_TYPES; } + snowForColor = false; } } \ No newline at end of file diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index acb70163baf..6ab3e39c5dd 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -547,6 +547,11 @@ public class ManaCostBeingPaid { return false; } + // snow can be paid for any color + if (shard.getColorMask() != 0 && mana.isSnow() && pool.isSnowForColor()) { + return true; + } + byte color = mana.getColor(); return pool.canPayForShardWithColor(shard, color); } 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 3d91659245e..48cf1e038b4 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -298,16 +298,6 @@ public class ManaPool extends ManaConversionMatrix implements Iterable { p.getGame().fireEvent(new GameEventZone(ZoneType.Battlefield, p, EventValueChangeType.ComplexUpdate, null)); } - public byte getPossibleColorUses(byte color) { - // Take the current conversion value, AND with restrictions to get mana usage - int rowIdx = ManaAtom.getIndexOfFirstManaType(color); - int matrixIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx; - - byte colorUse = colorConversionMatrix[matrixIdx]; - colorUse &= colorRestrictionMatrix[matrixIdx]; - return colorUse; - } - public boolean canPayForShardWithColor(ManaCostShard shard, byte color) { if (shard.isOfKind(ManaAtom.COLORLESS) && color == ManaAtom.GENERIC) { return false; // FIXME: testing Colorless against Generic is a recipe for disaster, but probably there should be a better fix. diff --git a/forge-gui/res/cardsfolder/upcoming/draugr_necromancer.txt b/forge-gui/res/cardsfolder/upcoming/draugr_necromancer.txt new file mode 100644 index 00000000000..391a6384db8 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/draugr_necromancer.txt @@ -0,0 +1,11 @@ +Name:Draugr Necromancer +ManaCost:3 B +Types:Snow Creature Zombie Cleric +PT:4/4 +R:Event$ Moved | ActiveZones$ Battlefield | Origin$ Battlefield | Destination$ Graveyard | ValidLKI$ Creature.nonToken+OppCtrl | ReplaceWith$ Exile | CheckSelfLKIZone$ True | Description$ If a nontoken creature an opponent controls would die, exile that card with an ice counter on it instead. +SVar:Exile:DB$ ChangeZone | Origin$ Battlefield | Destination$ Exile | Defined$ ReplacedCard | SubAbility$ DBPutCounter +SVar:DBPutCounter:DB$ PutCounter | Defined$ ReplacedCard | CounterType$ ICE | CounterNum$ 1 +S:Mode$ Continuous | Affected$ Card.OppOwn+counters_GE1_ICE+nonLand | AffectedZone$ Exile | MayPlay$ True | MayPlaySnowIgnoreColor$ True | Description$ You may cast spells from among cards in exile your opponents own with ice counters on them, and you may spend mana from snow sources as though it were mana of any color to cast those spells. +DeckNeeds:Type$Snow +DeckHas:Ability$Counters +Oracle:If a nontoken creature an opponent controls would die, exile that card with an ice counter on it instead.\nYou may cast spells from among cards in exile your opponents own with ice counters on them, and you may spend mana from snow sources as though it were mana of any color to cast those spells. diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index 699ff204ed7..25ff2a44d7a 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -119,6 +119,10 @@ public class HumanPlaySpellAbility { human.incNumManaConversion(); } + if (option != null && option.isIgnoreSnowSourceManaCostColor()) { + payment.setSnowForColor(true); + } + if (ability.isAbility() && ability.isActivatedAbility()) { final Map params = Maps.newHashMap(); params.put("ManaColorConversion", "Additive");