From 255f839397494ab1475e5f7b412dae4c97af32c6 Mon Sep 17 00:00:00 2001 From: North Date: Sun, 25 Nov 2012 14:02:44 +0200 Subject: [PATCH] Improved text generation for CreateTokenEffect --- .../sets/innistrad/EndlessRanksOfTheDead.java | 18 ++++++------------ .../src/mage/sets/newphyrexia/FreshMeat.java | 5 +++-- .../sets/newphyrexia/PhyrexianSwarmlord.java | 15 +++------------ .../common/ControllerLifeCount.java | 2 +- .../effects/common/CreateTokenEffect.java | 2 +- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Mage.Sets/src/mage/sets/innistrad/EndlessRanksOfTheDead.java b/Mage.Sets/src/mage/sets/innistrad/EndlessRanksOfTheDead.java index 24392f4afd..3ec00ab02d 100644 --- a/Mage.Sets/src/mage/sets/innistrad/EndlessRanksOfTheDead.java +++ b/Mage.Sets/src/mage/sets/innistrad/EndlessRanksOfTheDead.java @@ -53,8 +53,10 @@ public class EndlessRanksOfTheDead extends CardImpl { this.color.setBlack(true); - // At the beginning of your upkeep, put X 2/2 black Zombie creature tokens onto the battlefield, where X is half the number of Zombies you control, rounded down. - this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new CreateTokenEffect(new ZombieToken(), HalfZombiesCount.getInstance()))); + // At the beginning of your upkeep, put X 2/2 black Zombie creature tokens onto the battlefield, + // where X is half the number of Zombies you control, rounded down. + this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", + new CreateTokenEffect(new ZombieToken(), new HalfZombiesCount()))); } @@ -70,20 +72,12 @@ public class EndlessRanksOfTheDead extends CardImpl { class HalfZombiesCount implements DynamicValue { - private static HalfZombiesCount instance; private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); static { filter.add(new SubtypePredicate("Zombie")); } - public static HalfZombiesCount getInstance() { - if (instance == null) { - instance = new HalfZombiesCount(); - } - return instance; - } - @Override public int calculate(Game game, Ability sourceAbility) { int amount = game.getBattlefield().countAll(filter, sourceAbility.getControllerId(), game) / 2; @@ -92,12 +86,12 @@ class HalfZombiesCount implements DynamicValue { @Override public DynamicValue clone() { - return getInstance(); + return new HalfZombiesCount(); } @Override public String toString() { - return "1"; + return "X"; } @Override diff --git a/Mage.Sets/src/mage/sets/newphyrexia/FreshMeat.java b/Mage.Sets/src/mage/sets/newphyrexia/FreshMeat.java index 5f934b29f0..e3e0e2ea99 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/FreshMeat.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/FreshMeat.java @@ -116,8 +116,9 @@ class FreshMeatDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility) { FreshMeatWatcher watcher = (FreshMeatWatcher) game.getState().getWatchers().get("YourCreaturesDied", sourceAbility.getControllerId()); - if (watcher != null) + if (watcher != null) { return watcher.getCreaturesCount(); + } return 0; } @@ -133,6 +134,6 @@ class FreshMeatDynamicValue implements DynamicValue { @Override public String getMessage() { - return "for each creature put into your graveyard from the battlefield this turn"; + return "creature put into your graveyard from the battlefield this turn"; } } diff --git a/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianSwarmlord.java b/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianSwarmlord.java index d75239c3a6..4d2b314eaf 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianSwarmlord.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianSwarmlord.java @@ -62,7 +62,7 @@ public class PhyrexianSwarmlord extends CardImpl { this.addAbility(InfectAbility.getInstance()); this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", - new CreateTokenEffect(new InsectInfectToken(), OpponentsPoisonCountersCount.getInstance()))); + new CreateTokenEffect(new InsectInfectToken(), new OpponentsPoisonCountersCount()))); } public PhyrexianSwarmlord(final PhyrexianSwarmlord card) { @@ -77,15 +77,6 @@ public class PhyrexianSwarmlord extends CardImpl { class OpponentsPoisonCountersCount implements DynamicValue { - private static OpponentsPoisonCountersCount instance; - - public static OpponentsPoisonCountersCount getInstance() { - if (instance == null) { - instance = new OpponentsPoisonCountersCount(); - } - return instance; - } - @Override public int calculate(Game game, Ability sourceAbility) { int amount = 0; @@ -101,7 +92,7 @@ class OpponentsPoisonCountersCount implements DynamicValue { @Override public DynamicValue clone() { - return getInstance(); + return new OpponentsPoisonCountersCount(); } @Override @@ -113,4 +104,4 @@ class OpponentsPoisonCountersCount implements DynamicValue { public String getMessage() { return "poison counter your opponents have"; } -} \ No newline at end of file +} diff --git a/Mage/src/mage/abilities/dynamicvalue/common/ControllerLifeCount.java b/Mage/src/mage/abilities/dynamicvalue/common/ControllerLifeCount.java index 0f0e92f093..791a4d4458 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/ControllerLifeCount.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/ControllerLifeCount.java @@ -27,6 +27,6 @@ public class ControllerLifeCount implements DynamicValue { @Override public String toString() { - return "1"; + return "X"; } } diff --git a/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java b/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java index ee79ef82a7..3eb96bba27 100644 --- a/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java +++ b/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java @@ -91,7 +91,7 @@ public class CreateTokenEffect extends OneShotEffect { sb.append(" onto the battlefield"); String message = amount.getMessage(); if (message.length() > 0) { - if (message.startsWith("the ") || message.contains("number ")) { + if (amount.toString().equals("X")) { sb.append(", where X is "); } else { sb.append(" for each ");