- GlobalRuleChange enum now has an associated text.

This commit is contained in:
Sloth
2012-11-14 21:37:58 +00:00
parent 38dfe16017
commit c154b872dc
2 changed files with 26 additions and 28 deletions

View File

@@ -95,25 +95,7 @@ public class StaticAbilityContinuous {
//Global rules changes
if (params.containsKey("GlobalRule")) {
final StaticEffects effects = Singletons.getModel().getGame().getStaticEffects();
if (params.get("GlobalRule").equals("Damage can't be prevented.")) {
effects.setGlobalRuleChange(GlobalRuleChange.noPrevention);
} else if (params.get("GlobalRule").equals("All damage is dealt as though it's source had wither.")) {
effects.setGlobalRuleChange(GlobalRuleChange.alwaysWither);
} else if (params.get("GlobalRule").equals("The legend rule doesn't apply.")) {
effects.setGlobalRuleChange(GlobalRuleChange.noLegendRule);
} else if (params.get("GlobalRule").equals("Mana pools don't empty as steps and phases end.")) {
effects.setGlobalRuleChange(GlobalRuleChange.manapoolsDontEmpty);
} else if (params.get("GlobalRule").equals("Players can't cycle cards.")) {
effects.setGlobalRuleChange(GlobalRuleChange.noCycling);
} else if (params.get("GlobalRule").equals("Creatures entering the battlefield don't cause abilities to trigger.")) {
effects.setGlobalRuleChange(GlobalRuleChange.noCreatureETBTriggers);
} else if (params.get("GlobalRule").equals("No more than one creature can block each combat.")) {
effects.setGlobalRuleChange(GlobalRuleChange.onlyOneBlocker);
} else if (params.get("GlobalRule").equals("No more than one creature can attack each turn.")) {
effects.setGlobalRuleChange(GlobalRuleChange.onlyOneAttackerATurn);
} else if (params.get("GlobalRule").equals("No more than one creature can attack each combat.")) {
effects.setGlobalRuleChange(GlobalRuleChange.onlyOneAttackerACombat);
}
effects.setGlobalRuleChange(GlobalRuleChange.fromString(params.get("GlobalRule")));
}
if (params.containsKey("SetPower")) {

View File

@@ -22,13 +22,29 @@ package forge.game;
*/
public enum GlobalRuleChange {
alwaysWither,
manapoolsDontEmpty,
noCycling,
noCreatureETBTriggers,
noLegendRule,
noPrevention,
onlyOneAttackerATurn,
onlyOneAttackerACombat,
onlyOneBlocker
alwaysWither ("All damage is dealt as though it's source had wither."),
manapoolsDontEmpty ("Mana pools don't empty as steps and phases end."),
noCycling ("Players can't cycle cards."),
noCreatureETBTriggers ("Creatures entering the battlefield don't cause abilities to trigger."),
noLegendRule ("The legend rule doesn't apply."),
noPrevention ("Damage can't be prevented."),
onlyOneAttackerATurn ("No more than one creature can attack each turn."),
onlyOneAttackerACombat ("No more than one creature can attack each combat."),
onlyOneBlocker ("No more than one creature can block each combat.");
private final String ruleText;
private GlobalRuleChange(String text) {
ruleText = text;
}
public static GlobalRuleChange fromString(String text) {
for (final GlobalRuleChange v : GlobalRuleChange.values()) {
if (v.ruleText.compareToIgnoreCase(text) == 0) {
return v;
}
}
throw new RuntimeException("Element " + text + " not found in GlobalRuleChange enum");
}
}