Add new PlayerStates "HasLostLife" and "HasGainedLife"
parent
c3f86b5176
commit
8a215eb68c
|
@ -6,6 +6,8 @@ public enum MagicPlayerState {
|
||||||
WasDealtDamage(""),
|
WasDealtDamage(""),
|
||||||
CantCastSpells("can't cast spells this turn"),
|
CantCastSpells("can't cast spells this turn"),
|
||||||
CantActivateAbilities("can't activate abilities this turn"),
|
CantActivateAbilities("can't activate abilities this turn"),
|
||||||
|
HasLostLife(""),
|
||||||
|
HasGainedLife(""),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package magic.model.action;
|
||||||
import magic.ai.ArtificialScoringSystem;
|
import magic.ai.ArtificialScoringSystem;
|
||||||
import magic.model.MagicGame;
|
import magic.model.MagicGame;
|
||||||
import magic.model.MagicPlayer;
|
import magic.model.MagicPlayer;
|
||||||
|
import magic.model.MagicPlayerState;
|
||||||
import magic.model.trigger.MagicLifeChangeTriggerData;
|
import magic.model.trigger.MagicLifeChangeTriggerData;
|
||||||
import magic.model.trigger.MagicTriggerType;
|
import magic.model.trigger.MagicTriggerType;
|
||||||
|
|
||||||
|
@ -41,8 +42,10 @@ public class MagicChangeLifeAction extends MagicAction {
|
||||||
setScore(player,ArtificialScoringSystem.getLifeScore(newLife)-ArtificialScoringSystem.getLifeScore(oldLife));
|
setScore(player,ArtificialScoringSystem.getLifeScore(newLife)-ArtificialScoringSystem.getLifeScore(oldLife));
|
||||||
if (newLife > oldLife) {
|
if (newLife > oldLife) {
|
||||||
game.executeTrigger(MagicTriggerType.WhenLifeIsGained,new MagicLifeChangeTriggerData(player,newLife-oldLife));
|
game.executeTrigger(MagicTriggerType.WhenLifeIsGained,new MagicLifeChangeTriggerData(player,newLife-oldLife));
|
||||||
|
game.doAction(new MagicChangePlayerStateAction(player,MagicPlayerState.HasGainedLife));
|
||||||
} else if (newLife < oldLife) {
|
} else if (newLife < oldLife) {
|
||||||
game.executeTrigger(MagicTriggerType.WhenLifeIsLost,new MagicLifeChangeTriggerData(player,oldLife-newLife));
|
game.executeTrigger(MagicTriggerType.WhenLifeIsLost,new MagicLifeChangeTriggerData(player,oldLife-newLife));
|
||||||
|
game.doAction(new MagicChangePlayerStateAction(player,MagicPlayerState.HasLostLife));
|
||||||
}
|
}
|
||||||
game.setStateCheckRequired();
|
game.setStateCheckRequired();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue