fix: use correct power stone self damage calculation to not kill the character

This commit is contained in:
punchready 2021-08-06 12:45:06 +02:00
parent 57d384e98c
commit 315c7d2891

View File

@ -490,11 +490,15 @@ public class GameLogic {
case PowerStone -> { case PowerStone -> {
Character origin = (Character)state.entities.findEntity(data.originEntity); Character origin = (Character)state.entities.findEntity(data.originEntity);
int dmg = (int)Math.round(origin.hp.getMax() * 0.1); int dmg = (int)Math.round(origin.hp.getMax() * 0.1);
if(origin.hp.getValue() != 1 && dmg > 0) { //this is ugly ... but also easy to understand
int hp1 = origin.hp.getValue();
int hp2 = Math.max(1, origin.hp.getValue() - dmg);
int actualDmg = hp1 - hp2;
if(actualDmg > 0) {
result.add(new EventBuilder(EventType.TakenDamageEvent) result.add(new EventBuilder(EventType.TakenDamageEvent)
.withTargetEntity(data.originEntity) .withTargetEntity(data.originEntity)
.withTargetField(data.originField) .withTargetField(data.originField)
.withAmount(dmg) .withAmount(actualDmg)
.buildEntityEvent()); .buildEntityEvent());
} }
result.add(new EventBuilder(EventType.TakenDamageEvent) result.add(new EventBuilder(EventType.TakenDamageEvent)