From c8eed79a2a7812d0c1d0dd65b2806756dc498ebd Mon Sep 17 00:00:00 2001 From: Sol Date: Sun, 9 Feb 2014 02:37:09 +0000 Subject: [PATCH] - Initial checkin for Additive Mana Conversion Static Ability (Restrictive Conversions currently not 100% correct) - Added Mycosynth Lattice - Fixed Sunglasses of Urza --- .gitattributes | 1 + .../src/main/java/forge/card/MagicColor.java | 1 + .../src/main/java/forge/game/GameAction.java | 4 +++ .../main/java/forge/game/mana/ManaPool.java | 10 ++++-- .../StaticAbilityContinuous.java | 34 +++++++++++++++++++ .../res/cardsfolder/m/mycosynth_lattice.txt | 10 ++++++ .../res/cardsfolder/s/sunglasses_of_urza.txt | 3 +- 7 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 forge-gui/res/cardsfolder/m/mycosynth_lattice.txt diff --git a/.gitattributes b/.gitattributes index c3b5fd92b0e..11ed998636b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8211,6 +8211,7 @@ forge-gui/res/cardsfolder/m/mycologist.txt svneol=native#text/plain forge-gui/res/cardsfolder/m/mycoloth.txt svneol=native#text/plain forge-gui/res/cardsfolder/m/mycosynth_fiend.txt svneol=native#text/plain forge-gui/res/cardsfolder/m/mycosynth_golem.txt svneol=native#text/plain +forge-gui/res/cardsfolder/m/mycosynth_lattice.txt -text forge-gui/res/cardsfolder/m/mycosynth_wellspring.txt svneol=native#text/plain forge-gui/res/cardsfolder/m/myojin_of_cleansing_fire.txt -text forge-gui/res/cardsfolder/m/myojin_of_infinite_rage.txt -text diff --git a/forge-core/src/main/java/forge/card/MagicColor.java b/forge-core/src/main/java/forge/card/MagicColor.java index 759ac729509..3a670d6916c 100644 --- a/forge-core/src/main/java/forge/card/MagicColor.java +++ b/forge-core/src/main/java/forge/card/MagicColor.java @@ -119,6 +119,7 @@ public class MagicColor { /** The only colors. */ public static final ImmutableList ONLY_COLORS = ImmutableList.of(WHITE, BLUE, BLACK, RED, GREEN); + public static final ImmutableList COLORS_AND_COLORLESS = ImmutableList.of(WHITE, BLUE, BLACK, RED, GREEN, COLORLESS); /** The Snow. */ public static final String SNOW = "snow"; diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 3ed72d87da4..a84b1f68c6f 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -695,6 +695,10 @@ public class GameAction { game.getTriggerHandler().cleanUpTemporaryTriggers(); game.getReplacementHandler().cleanUpTemporaryReplacements(); + for(Player p : game.getPlayers()) { + p.getManaPool().restoreColorReplacements(); + } + // search for cards with static abilities final List allCards = game.getCardsInGame(); final ArrayList staticAbilities = new ArrayList(); 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 ebe1fef22f7..965b21ae8fa 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -421,9 +421,13 @@ public class ManaPool { private final byte[] colorConversionMatrix = new byte[6]; private static final byte[] identityMatrix = { MagicColor.WHITE, MagicColor.BLUE, MagicColor.BLACK, MagicColor.RED, MagicColor.GREEN, 0 }; - public void addColorReplacement(byte originalColor, byte replacementColor) { - int rowIdx = MagicColor.getIndexOfFirstColor(originalColor); - colorConversionMatrix[rowIdx] |= replacementColor; + public void adjustColorReplacement(byte originalColor, byte replacementColor, boolean additive) { + // Fix the index based on a 6 length array with colorless in the last slot + int rowIdx = (MagicColor.getIndexOfFirstColor(originalColor) + 6) % 6; + if (additive) + colorConversionMatrix[rowIdx] |= replacementColor; + else + colorConversionMatrix[rowIdx] &= replacementColor; } public void restoreColorReplacements() { diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 0b699a6e6f4..f5ae654be8e 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -23,11 +23,13 @@ import java.util.HashMap; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.text.WordUtils; import com.google.common.collect.Lists; import forge.card.CardType; import forge.card.ColorSet; +import forge.card.MagicColor; import forge.card.mana.ManaCostShard; import forge.game.Game; import forge.game.GlobalRuleChange; @@ -40,6 +42,7 @@ import forge.game.card.Card; import forge.game.card.CardFactoryUtil; import forge.game.card.CardLists; import forge.game.card.CardUtil; +import forge.game.mana.ManaPool; import forge.game.player.Player; import forge.game.replacement.ReplacementEffect; import forge.game.replacement.ReplacementHandler; @@ -344,6 +347,37 @@ public class StaticAbilityContinuous { int rmax = AbilityUtils.calculateAmount(hostCard, rmhs, null); p.setMaxHandSize(p.getMaxHandSize() + rmax); } + + if (params.containsKey("ManaColorConversion")) { + String conversionType = params.get("ManaColorConversion"); + + // Choices are Additives(OR) or Restrictive(AND) + boolean additive = "Additive".equals(conversionType); + ManaPool pool = p.getManaPool(); + + for(String c : MagicColor.Constant.COLORS_AND_COLORLESS) { + // Use the strings from MagicColor, since that's how the Script will be coming in as + String key = WordUtils.capitalize(c) + "Conversion"; + if (params.containsKey(key)) { + String convertTo = params.get(key); + byte convertByte = 0; + if ("All".equals(convertTo)) { + convertByte = MagicColor.ALL_COLORS; + } else{ + for(String convertColor : convertTo.split(",")) { + convertByte |= MagicColor.fromName(convertColor); + } + } + + // Celestial Dawn won't be 100% correct with this implementation + // Since all the additives need to happen first + // And all the restrictions need to happen second + // But this would mostly work unless a conflicting mana conversion card + // Is also out in play CD + Mycosynth Lattice depending on timestamps might be incorrect + pool.adjustColorReplacement(MagicColor.fromName(c), convertByte, additive); + } + } + } } // start modifying the cards diff --git a/forge-gui/res/cardsfolder/m/mycosynth_lattice.txt b/forge-gui/res/cardsfolder/m/mycosynth_lattice.txt new file mode 100644 index 00000000000..66e48bc528c --- /dev/null +++ b/forge-gui/res/cardsfolder/m/mycosynth_lattice.txt @@ -0,0 +1,10 @@ +Name:Mycosynth Lattice +ManaCost:6 +Types:Artifact +S:Mode$ Continuous | Affected$ Permanent | AddType$ Artifact | Description$ All permanents are artifact in addition to their other types. +S:Mode$ Continuous| Affected$ Card | SetColor$ Colorless | AffectedZone$ Battlefield,Hand,Library,Graveyard,Exile,Stack,Command | Description$ All cards that aren't on the battlefield, spells, and permanents are colorless. +S:Mode$ Continuous | Affected$ Player | ManaColorConversion$ Additive | WhiteConversion$ All | BlueConversion$ All | BlackConversion$ All | RedConversion$ All | GreenConversion$ All | ColorlessConversion$ All | Description$ Players may spend mana as though it were mana of any color. +SVar:NonStackingEffect:True +SVar:RemRandomDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/mycosynth_lattice.jpg +Oracle:All permanents are artifacts in addition to their other types.\nAll cards that aren't on the battlefield, spells, and permanents are colorless.\nPlayers may spend mana as though it were mana of any color. diff --git a/forge-gui/res/cardsfolder/s/sunglasses_of_urza.txt b/forge-gui/res/cardsfolder/s/sunglasses_of_urza.txt index 64dcce1ac20..f2296827311 100644 --- a/forge-gui/res/cardsfolder/s/sunglasses_of_urza.txt +++ b/forge-gui/res/cardsfolder/s/sunglasses_of_urza.txt @@ -1,8 +1,7 @@ Name:Sunglasses of Urza ManaCost:3 Types:Artifact -Text:You may spend white mana as though it were red mana. -A:AB$ Mana | Cost$ W | Produced$ R | SpellDescription$ Add {R} to your mana pool. +S:Mode$ Continuous | Affected$ You | ManaColorConversion$ Additive | WhiteConversion$ Red | Description$ You may spend white mana as though it were red mana. SVar:RemRandomDeck:True SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/sunglasses_of_urza.jpg