mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Refactor OpponentsLostLifeCount to enum
This commit is contained in:
parent
ccba9b2e5a
commit
283b101a08
6 changed files with 26 additions and 34 deletions
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldAbility;
|
import mage.abilities.common.EntersBattlefieldAbility;
|
||||||
|
@ -11,14 +9,15 @@ import mage.abilities.keyword.TrampleAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class CryptbornHorror extends CardImpl {
|
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";
|
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) {
|
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.subtype.add(SubType.HORROR);
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
this.color.setRed(true);
|
this.color.setRed(true);
|
||||||
|
@ -64,7 +63,7 @@ class CryptbornHorrorEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
int oll = new OpponentsLostLifeCount().calculate(game, source, this);
|
int oll = OpponentsLostLifeCount.instance.calculate(game, source, this);
|
||||||
if (oll > 0) {
|
if (oll > 0) {
|
||||||
permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game);
|
permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.n;
|
package mage.cards.n;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -18,8 +16,9 @@ import mage.constants.TargetController;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author spjspj
|
* @author spjspj
|
||||||
*/
|
*/
|
||||||
public final class NehebTheEternal extends CardImpl {
|
public final class NehebTheEternal extends CardImpl {
|
||||||
|
@ -74,7 +73,7 @@ class NehebTheEternalManaEffect extends ManaEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mana produceMana(boolean netMana, Game game, Ability source) {
|
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
|
@Override
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.r;
|
package mage.cards.r;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
|
@ -20,8 +18,9 @@ import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class RakdosLordOfRiots extends CardImpl {
|
public final class RakdosLordOfRiots extends CardImpl {
|
||||||
|
@ -84,9 +83,7 @@ class RakdosLordOfRiotsCantCastEffect extends ContinuousRuleModifyingEffectImpl
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getSourceId().equals(source.getSourceId())) {
|
if (event.getSourceId().equals(source.getSourceId())) {
|
||||||
if (new OpponentsLostLifeCount().calculate(game, source, this) == 0) {
|
return OpponentsLostLifeCount.instance.calculate(game, source, this) == 0;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -107,8 +104,7 @@ class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl {
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
Ability spellAbility = abilityToModify;
|
Ability spellAbility = abilityToModify;
|
||||||
if (spellAbility != null) {
|
if (spellAbility != null) {
|
||||||
OpponentsLostLifeCount dynamicValue = new OpponentsLostLifeCount();
|
int amount = OpponentsLostLifeCount.instance.calculate(game, source, this);
|
||||||
int amount = dynamicValue.calculate(game, source, this);
|
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
CardUtil.reduceCost(spellAbility, amount);
|
CardUtil.reduceCost(spellAbility, amount);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldAbility;
|
import mage.abilities.common.EntersBattlefieldAbility;
|
||||||
|
@ -11,14 +9,15 @@ import mage.abilities.keyword.MenaceAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Styxo
|
* @author Styxo
|
||||||
*/
|
*/
|
||||||
public final class SithLord extends CardImpl {
|
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";
|
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) {
|
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.HUMAN);
|
||||||
this.subtype.add(SubType.SITH);
|
this.subtype.add(SubType.SITH);
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
|
@ -62,7 +61,7 @@ public final class SithLord extends CardImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
int oll = new OpponentsLostLifeCount().calculate(game, source, this);
|
int oll = OpponentsLostLifeCount.instance.calculate(game, source, this);
|
||||||
if (oll > 0) {
|
if (oll > 0) {
|
||||||
permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game);
|
permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
|
|
||||||
package mage.abilities.dynamicvalue.common;
|
package mage.abilities.dynamicvalue.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.watchers.common.PlayerLostLifeWatcher;
|
import mage.watchers.common.PlayerLostLifeWatcher;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class OpponentsLostLifeCount implements DynamicValue {
|
public enum OpponentsLostLifeCount implements DynamicValue {
|
||||||
|
|
||||||
|
instance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||||
|
@ -29,7 +30,7 @@ public class OpponentsLostLifeCount implements DynamicValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OpponentsLostLifeCount copy() {
|
public OpponentsLostLifeCount copy() {
|
||||||
return new OpponentsLostLifeCount();
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
|
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
|
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.SpellAbilityType;
|
import mage.constants.SpellAbilityType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.watchers.common.PlayerLostLifeWatcher;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -40,8 +39,7 @@ public class SpectacleAbility extends SpellAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||||
PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
|
if (OpponentsLostLifeCount.instance.calculate(game, playerId) > 0) {
|
||||||
if (watcher != null && watcher.getAllOppLifeLost(playerId, game) > 0) {
|
|
||||||
return super.canActivate(playerId, game);
|
return super.canActivate(playerId, game);
|
||||||
}
|
}
|
||||||
return ActivationStatus.getFalse();
|
return ActivationStatus.getFalse();
|
||||||
|
|
Loading…
Reference in a new issue