Refactor OpponentsLostLifeCount to enum

This commit is contained in:
Oleg Agafonov 2019-02-06 17:31:34 +04:00
parent ccba9b2e5a
commit 283b101a08
6 changed files with 26 additions and 34 deletions

View file

@ -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

View file

@ -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();