fix: use correct power stone self damage calculation to not kill the character
This commit is contained in:
parent
57d384e98c
commit
315c7d2891
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user