mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Simplify ManaConvertion scripts
This commit is contained in:
@@ -138,23 +138,11 @@ public final class MagicColor {
|
||||
public static final ImmutableList<String> BASIC_LANDS = ImmutableList.of("Plains", "Island", "Swamp", "Mountain", "Forest");
|
||||
public static final ImmutableList<String> SNOW_LANDS = ImmutableList.of("Snow-Covered Plains", "Snow-Covered Island", "Snow-Covered Swamp", "Snow-Covered Mountain", "Snow-Covered Forest");
|
||||
public static final ImmutableMap<String, String> ANY_COLOR_CONVERSION = new ImmutableMap.Builder<String, String>()
|
||||
.put("ManaColorConversion", "Additive")
|
||||
.put("WhiteConversion", "Color")
|
||||
.put("BlueConversion", "Color")
|
||||
.put("BlackConversion", "Color")
|
||||
.put("RedConversion", "Color")
|
||||
.put("GreenConversion", "Color")
|
||||
.put("ColorlessConversion", "Color")
|
||||
.put("ManaConversion", "AnyType->AnyColor")
|
||||
.build();
|
||||
|
||||
public static final ImmutableMap<String, String> ANY_TYPE_CONVERSION = new ImmutableMap.Builder<String, String>()
|
||||
.put("ManaColorConversion", "Additive")
|
||||
.put("WhiteConversion", "Type")
|
||||
.put("BlueConversion", "Type")
|
||||
.put("BlackConversion", "Type")
|
||||
.put("RedConversion", "Type")
|
||||
.put("GreenConversion", "Type")
|
||||
.put("ColorlessConversion", "Type")
|
||||
.put("ManaConversion", "AnyType->AnyType")
|
||||
.build();
|
||||
/**
|
||||
* Private constructor to prevent instantiation.
|
||||
|
||||
@@ -59,6 +59,18 @@ public abstract class ManaAtom {
|
||||
return 0; // generic
|
||||
}
|
||||
|
||||
public static byte fromConversion(String s) {
|
||||
switch (s) {
|
||||
case "AnyColor": return ALL_MANA_COLORS;
|
||||
case "AnyType": return ALL_MANA_TYPES;
|
||||
}
|
||||
byte b = 0;
|
||||
for (char c : s.toCharArray()) {
|
||||
b |= fromName(c);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static int getIndexOfFirstManaType(final byte color){
|
||||
for (int i = 0; i < MANATYPES.length; i++) {
|
||||
if ((color & MANATYPES[i]) != 0) {
|
||||
|
||||
@@ -1864,30 +1864,19 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
public static final void applyManaColorConversion(ManaConversionMatrix matrix, final Map<String, String> params) {
|
||||
String conversionType = params.get("ManaColorConversion");
|
||||
String conversion = params.get("ManaConversion");
|
||||
|
||||
// Choices are Additives(OR) or Restrictive(AND)
|
||||
boolean additive = "Additive".equals(conversionType);
|
||||
for (String pair : conversion.split(" ")) {
|
||||
// Check if conversion is additive or restrictive and how to split
|
||||
boolean additive = pair.contains("->");
|
||||
String[] sides = pair.split(additive ? "->" : "<-");
|
||||
|
||||
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 = StringUtils.capitalize(c) + "Conversion";
|
||||
if (params.containsKey(key)) {
|
||||
String convertTo = params.get(key);
|
||||
byte convertByte = 0;
|
||||
if ("Type".equals(convertTo)) {
|
||||
// IMPORTANT! We need to use Mana Color here not Card Color.
|
||||
convertByte = ManaAtom.ALL_MANA_TYPES;
|
||||
} else if ("Color".equals(convertTo)) {
|
||||
// IMPORTANT! We need to use Mana Color here not Card Color.
|
||||
convertByte = ManaAtom.ALL_MANA_COLORS;
|
||||
if (sides[0].equals("AnyColor") || sides[0].equals("AnyType")) {
|
||||
for (byte c : (sides[0].equals("AnyColor") ? MagicColor.WUBRG : MagicColor.WUBRGC)) {
|
||||
matrix.adjustColorReplacement(c, ManaAtom.fromConversion(sides[1]), additive);
|
||||
}
|
||||
} else {
|
||||
for (final String convertColor : convertTo.split(",")) {
|
||||
convertByte |= ManaAtom.fromName(convertColor);
|
||||
}
|
||||
}
|
||||
// AdjustColorReplacement has two different matrices handling final mana conversion under the covers
|
||||
matrix.adjustColorReplacement(ManaAtom.fromName(c), convertByte, additive);
|
||||
matrix.adjustColorReplacement(ManaAtom.fromConversion(sides[0]), ManaAtom.fromConversion(sides[1]), additive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ public final class StaticAbilityContinuous {
|
||||
p.setMaxHandSize(p.getMaxHandSize() + rmax);
|
||||
}
|
||||
|
||||
if (params.containsKey("ManaColorConversion")) {
|
||||
if (params.containsKey("ManaConversion")) {
|
||||
AbilityUtils.applyManaColorConversion(p.getManaPool(), params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ Types:Enchantment
|
||||
S:Mode$ Continuous | Affected$ Land.YouCtrl | AddType$ Plains | RemoveLandTypes$ True | Description$ Lands you control are Plains.
|
||||
S:Mode$ Continuous | Affected$ Card.YouOwn+nonLand | SetColor$ White | AffectedZone$ Hand,Library,Graveyard,Exile,Command | Description$ Nonland permanents you control are white. The same is true for spells you control and nonland cards you own that aren't on the battlefield.
|
||||
S:Mode$ Continuous | Affected$ Card.YouCtrl+nonLand | SetColor$ White | AffectedZone$ Battlefield,Stack
|
||||
S:Mode$ Continuous | Affected$ You | ManaColorConversion$ Additive | WhiteConversion$ Color | Description$ You may spend white mana as though it were mana of any color.
|
||||
S:Mode$ Continuous | Affected$ You | ManaColorConversion$ Restrictive | BlueConversion$ Colorless | BlackConversion$ Colorless | RedConversion$ Colorless | GreenConversion$ Colorless | ColorlessConversion$ Colorless | Description$ You may spend other mana only as though it were colorless mana.
|
||||
S:Mode$ Continuous | Affected$ You | ManaConversion$ W->AnyColor | Description$ You may spend white mana as though it were mana of any color.
|
||||
S:Mode$ Continuous | Affected$ You | ManaConversion$ UBRG<-C | Description$ You may spend other mana only as though it were colorless mana.
|
||||
SVar:NonStackingEffect:True
|
||||
AI:RemoveDeck:Random
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/celestial_dawn.jpg
|
||||
Oracle:Lands you control are Plains.\nNonland permanents you control are white. The same is true for spells you control and nonland cards you own that aren't on the battlefield.\nYou may spend white mana as though it were mana of any color. You may spend other mana only as though it were colorless mana.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Name:Chromatic Orrery
|
||||
ManaCost:7
|
||||
Types:Legendary Artifact
|
||||
S:Mode$ Continuous | Affected$ You | ManaColorConversion$ Additive | WhiteConversion$ Color | BlueConversion$ Color | BlackConversion$ Color | RedConversion$ Color | GreenConversion$ Color | ColorlessConversion$ Color | Description$ You may spend mana as though it were mana of any color.
|
||||
S:Mode$ Continuous | Affected$ You | ManaConversion$ AnyType->AnyColor | Description$ You may spend mana as though it were mana of any color.
|
||||
SVar:NonStackingEffect:True
|
||||
A:AB$ Mana | Cost$ T | Produced$ C | Amount$ 5 | SpellDescription$ Add {C}{C}{C}{C}{C}.
|
||||
A:AB$ Draw | Cost$ 5 T | NumCards$ X | SpellDescription$ Draw a card for each color among permanents you control.
|
||||
|
||||
@@ -5,6 +5,6 @@ A:SP$ Effect | Cost$ 1 W | ReplacementEffects$ FDRep | StaticAbilities$ FDManaCo
|
||||
SVar:DBDraw:DB$ Draw | NumCards$ 1
|
||||
SVar:FDRep:Event$ ProduceMana | ActiveZones$ Command | ValidCard$ Card.YouCtrl | ReplaceWith$ ProduceW | Description$ Spells and abilities you control that would add colored mana add that much white mana instead.
|
||||
SVar:ProduceW:DB$ ReplaceMana | ReplaceColor$ W
|
||||
SVar:FDManaConvertion:Mode$ Continuous | EffectZone$ Command | Affected$ You | ManaColorConversion$ Additive | WhiteConversion$ Color | Description$ You may spend white mana as though it were mana of any color.
|
||||
SVar:FDManaConvertion:Mode$ Continuous | EffectZone$ Command | Affected$ You | ManaConversion$ W->AnyColor | Description$ You may spend white mana as though it were mana of any color.
|
||||
AI:RemoveDeck:All
|
||||
Oracle:Until end of turn, spells and abilities you control that would add colored mana instead add that much white mana. Until end of turn, you may spend white mana as though it were mana of any color.\nDraw a card.
|
||||
|
||||
@@ -2,11 +2,7 @@ Name:Manascape Refractor
|
||||
ManaCost:3
|
||||
Types:Artifact
|
||||
K:CARDNAME enters the battlefield tapped.
|
||||
K:ManaConvert:Black:All
|
||||
K:ManaConvert:Blue:All
|
||||
K:ManaConvert:Green:All
|
||||
K:ManaConvert:Red:All
|
||||
K:ManaConvert:White:All
|
||||
K:ManaConvert:AnyType->AnyColor
|
||||
S:Mode$ Continuous | Affected$ Card.Self | EffectZone$ Battlefield | GainsAbilitiesOf$ Land | Description$ CARDNAME has all activated abilities of all lands on the battlefield.
|
||||
Text:You may spend mana as though it were mana of any color to pay the activation costs of CARDNAME's abilities.
|
||||
AI:RemoveDeck:All
|
||||
|
||||
@@ -3,8 +3,7 @@ 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$ Color | BlueConversion$ Color | BlackConversion$ Color | RedConversion$ Color | GreenConversion$ Color | ColorlessConversion$ Color | Description$ Players may spend mana as though it were mana of any color.
|
||||
S:Mode$ Continuous | Affected$ Player | ManaConversion$ AnyType->AnyColor | Description$ Players may spend mana as though it were mana of any color.
|
||||
SVar:NonStackingEffect:True
|
||||
AI:RemoveDeck:Random
|
||||
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.
|
||||
|
||||
@@ -2,9 +2,9 @@ Name:Quicksilver Elemental
|
||||
ManaCost:3 U U
|
||||
Types:Creature Elemental
|
||||
PT:3/4
|
||||
K:ManaConvert:Blue:All
|
||||
K:ManaConvert:U->AnyColor
|
||||
Text:You may spend blue mana as though it were mana of any color to pay the activation costs of CARDNAME's abilities.
|
||||
A:AB$ Effect | Cost$ U | ValidTgts$ Creature | TgtZone$ Battlefield | TgtPrompt$ Select target creature card | StaticAbilities$ STSteal | RememberObjects$ Targeted | SpellDescription$ CARDNAME gains all activated abilities of target creature until end of turn.
|
||||
SVar:STSteal:Mode$ Continuous | Affected$ EffectSource | EffectZone$ Command | GainsAbilitiesOfDefined$ RememberedLKI | Description$ Quicksilver Elemental gains all activated abilities of that card until end of turn.
|
||||
AI:RemoveDeck:All
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/quicksilver_elemental.jpg
|
||||
Oracle:{U}: Quicksilver Elemental gains all activated abilities of target creature until end of turn. (If any of the abilities use that creature's name, use this creature's name instead.)\nYou may spend blue mana as though it were mana of any color to pay the activation costs of Quicksilver Elemental's abilities.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
Name:Sunglasses of Urza
|
||||
ManaCost:3
|
||||
Types:Artifact
|
||||
S:Mode$ Continuous | Affected$ You | ManaColorConversion$ Additive | WhiteConversion$ Red | Description$ You may spend white mana as though it were red mana.
|
||||
AI:RemoveDeck:Random
|
||||
S:Mode$ Continuous | Affected$ You | ManaConversion$ W->R | Description$ You may spend white mana as though it were red mana.
|
||||
AI:RemoveDeck:All
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/sunglasses_of_urza.jpg
|
||||
Oracle:You may spend white mana as though it were red mana.
|
||||
|
||||
@@ -93,11 +93,10 @@ public class HumanPlaySpellAbility {
|
||||
ability = GameActionUtil.addExtraKeywordCost(ability);
|
||||
|
||||
if (ability.isSpell() && !ability.isCopied()) { // These hidden keywords should only apply on the Stack
|
||||
final Card host = ability.getHostCard();
|
||||
if (host.hasKeyword("May spend mana as though it were mana of any type to cast CARDNAME")
|
||||
if (c.hasKeyword("May spend mana as though it were mana of any type to cast CARDNAME")
|
||||
|| (option != null && option.isIgnoreManaCostType())) {
|
||||
manaTypeConversion = true;
|
||||
} else if (host.hasKeyword("May spend mana as though it were mana of any color to cast CARDNAME")
|
||||
} else if (c.hasKeyword("May spend mana as though it were mana of any color to cast CARDNAME")
|
||||
|| (option != null && option.isIgnoreManaCostColor())) {
|
||||
manaColorConversion = true;
|
||||
}
|
||||
@@ -127,13 +126,12 @@ public class HumanPlaySpellAbility {
|
||||
|
||||
if (ability.isAbility() && ability.isActivatedAbility()) {
|
||||
final Map<String, String> params = Maps.newHashMap();
|
||||
params.put("ManaColorConversion", "Additive");
|
||||
|
||||
for (KeywordInterface inst : c.getKeywords()) {
|
||||
String keyword = inst.getOriginal();
|
||||
if (keyword.startsWith("ManaConvert")) {
|
||||
final String[] k = keyword.split(":");
|
||||
params.put(k[1] + "Conversion", k[2]);
|
||||
params.put("ManaConversion", k[1]);
|
||||
keywordColor = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user