refactor: use isAlive instead of hp.getValue

This commit is contained in:
punchready 2021-06-03 03:15:05 +02:00
parent 00eb5e21f3
commit 614b33adff

View File

@ -498,7 +498,7 @@ public class GameLogic {
EntityType opposing = target.id.type == EntityType.P1 ? EntityType.P2 : EntityType.P1; EntityType opposing = target.id.type == EntityType.P1 ? EntityType.P2 : EntityType.P1;
state.winConditions.increaseValue(opposing, WinCondition.TotalDamage, ((CharacterEvent)event).amount); state.winConditions.increaseValue(opposing, WinCondition.TotalDamage, ((CharacterEvent)event).amount);
if(target.hp.getValue() == 0) { if(!target.isAlive()) {
state.winConditions.increaseValue(opposing, WinCondition.TotalKnockouts, 1); state.winConditions.increaseValue(opposing, WinCondition.TotalKnockouts, 1);
} }
} }
@ -815,7 +815,7 @@ public class GameLogic {
Collections.shuffle(state.turnOrder); Collections.shuffle(state.turnOrder);
for (EntityID id: state.turnOrder) { for (EntityID id: state.turnOrder) {
if(id.type == EntityType.NPC || revived.contains(id) || ((Character)state.entities.findEntity(id)).hp.getValue() > 0){ if(id.type == EntityType.NPC || revived.contains(id) || ((Character)state.entities.findEntity(id)).isAlive()){
state.activeCharacter = id; state.activeCharacter = id;
break; break;
}else { // again send empty turns for knocked out characters }else { // again send empty turns for knocked out characters
@ -927,7 +927,7 @@ public class GameLogic {
for(Character character: characters) { for(Character character: characters) {
if(checkLineOfSight(state, spawnPosition, character.getPosition())) { if(checkLineOfSight(state, spawnPosition, character.getPosition())) {
if(character.hp.getValue() == 0) { if(!character.isAlive()) {
revived.add(character.id); revived.add(character.id);
} }
if(character.hp.getValue() != character.hp.getMax()) { if(character.hp.getValue() != character.hp.getMax()) {