diff --git a/Mage.Sets/src/mage/cards/c/CryptbornHorror.java b/Mage.Sets/src/mage/cards/c/CryptbornHorror.java index 9328ab0493..16d72c1098 100644 --- a/Mage.Sets/src/mage/cards/c/CryptbornHorror.java +++ b/Mage.Sets/src/mage/cards/c/CryptbornHorror.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; @@ -11,14 +9,15 @@ import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.counters.CounterType; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class CryptbornHorror extends CardImpl { @@ -26,7 +25,7 @@ public final class CryptbornHorror extends CardImpl { private static final String rule = "with X +1/+1 counters on it, where X is the total life lost by your opponents this turn"; public CryptbornHorror(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B/R}{B/R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B/R}{B/R}"); this.subtype.add(SubType.HORROR); this.color.setBlack(true); this.color.setRed(true); @@ -64,7 +63,7 @@ class CryptbornHorrorEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { - int oll = new OpponentsLostLifeCount().calculate(game, source, this); + int oll = OpponentsLostLifeCount.instance.calculate(game, source, this); if (oll > 0) { permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game); } diff --git a/Mage.Sets/src/mage/cards/n/NehebTheEternal.java b/Mage.Sets/src/mage/cards/n/NehebTheEternal.java index 58bd4f5e39..c56200a21f 100644 --- a/Mage.Sets/src/mage/cards/n/NehebTheEternal.java +++ b/Mage.Sets/src/mage/cards/n/NehebTheEternal.java @@ -1,7 +1,5 @@ - package mage.cards.n; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.Ability; @@ -18,8 +16,9 @@ import mage.constants.TargetController; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** - * * @author spjspj */ public final class NehebTheEternal extends CardImpl { @@ -74,7 +73,7 @@ class NehebTheEternalManaEffect extends ManaEffect { @Override public Mana produceMana(boolean netMana, Game game, Ability source) { - return Mana.RedMana(new OpponentsLostLifeCount().calculate(game, source, this)); + return Mana.RedMana(OpponentsLostLifeCount.instance.calculate(game, source, this)); } @Override diff --git a/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java b/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java index 7ada8448d2..37f5452921 100644 --- a/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java +++ b/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java @@ -1,7 +1,5 @@ - package mage.cards.r; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.SpellAbility; @@ -20,8 +18,9 @@ import mage.game.events.GameEvent.EventType; import mage.game.stack.Spell; import mage.util.CardUtil; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class RakdosLordOfRiots extends CardImpl { @@ -84,9 +83,7 @@ class RakdosLordOfRiotsCantCastEffect extends ContinuousRuleModifyingEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getSourceId().equals(source.getSourceId())) { - if (new OpponentsLostLifeCount().calculate(game, source, this) == 0) { - return true; - } + return OpponentsLostLifeCount.instance.calculate(game, source, this) == 0; } return false; } @@ -107,8 +104,7 @@ class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl { public boolean apply(Game game, Ability source, Ability abilityToModify) { Ability spellAbility = abilityToModify; if (spellAbility != null) { - OpponentsLostLifeCount dynamicValue = new OpponentsLostLifeCount(); - int amount = dynamicValue.calculate(game, source, this); + int amount = OpponentsLostLifeCount.instance.calculate(game, source, this); if (amount > 0) { CardUtil.reduceCost(spellAbility, amount); return true; diff --git a/Mage.Sets/src/mage/cards/s/SithLord.java b/Mage.Sets/src/mage/cards/s/SithLord.java index 0334ca86df..9b5b76c118 100644 --- a/Mage.Sets/src/mage/cards/s/SithLord.java +++ b/Mage.Sets/src/mage/cards/s/SithLord.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; @@ -11,14 +9,15 @@ import mage.abilities.keyword.MenaceAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.counters.CounterType; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author Styxo */ public final class SithLord extends CardImpl { @@ -26,7 +25,7 @@ public final class SithLord extends CardImpl { private static final String rule = "with X +1/+1 counters on it, where X is the total life lost by your opponents this turn"; public SithLord(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{B}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.SITH); this.power = new MageInt(2); @@ -62,7 +61,7 @@ public final class SithLord extends CardImpl { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { - int oll = new OpponentsLostLifeCount().calculate(game, source, this); + int oll = OpponentsLostLifeCount.instance.calculate(game, source, this); if (oll > 0) { permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game); } @@ -76,5 +75,5 @@ public final class SithLord extends CardImpl { return new SithLordEffect(this); } } - + } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java index 0be9fa437a..5a566ef04f 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java @@ -1,18 +1,19 @@ - package mage.abilities.dynamicvalue.common; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; import mage.game.Game; import mage.watchers.common.PlayerLostLifeWatcher; +import java.util.UUID; + /** - * * @author LevelX2 */ -public class OpponentsLostLifeCount implements DynamicValue { +public enum OpponentsLostLifeCount implements DynamicValue { + + instance; @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { @@ -29,7 +30,7 @@ public class OpponentsLostLifeCount implements DynamicValue { @Override public OpponentsLostLifeCount copy() { - return new OpponentsLostLifeCount(); + return instance; } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java b/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java index 8f3d172b23..d0254f70d6 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java @@ -1,13 +1,12 @@ - package mage.abilities.keyword; import mage.abilities.SpellAbility; import mage.abilities.costs.mana.ManaCost; +import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount; import mage.cards.Card; import mage.constants.SpellAbilityType; import mage.constants.Zone; import mage.game.Game; -import mage.watchers.common.PlayerLostLifeWatcher; import java.util.ArrayList; import java.util.UUID; @@ -40,8 +39,7 @@ public class SpectacleAbility extends SpellAbility { @Override public ActivationStatus canActivate(UUID playerId, Game game) { - PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); - if (watcher != null && watcher.getAllOppLifeLost(playerId, game) > 0) { + if (OpponentsLostLifeCount.instance.calculate(game, playerId) > 0) { return super.canActivate(playerId, game); } return ActivationStatus.getFalse();