fix: move away from targetEntity in use stone requests in request executing too

This commit is contained in:
punchready 2021-08-10 19:21:44 +02:00
parent a9acbda343
commit 673ba9f89d
1 changed files with 10 additions and 4 deletions

View File

@ -511,7 +511,8 @@ public class GameLogic {
.buildCharacterEvent()); .buildCharacterEvent());
} }
case MindStone -> { case MindStone -> {
Entity targetEntity = state.entities.findEntity(data.targetEntity); ArrayList<Entity> found = state.entities.findByPosition(data.targetField);
Entity targetEntity = found.get(0);
result.add(new EventBuilder(EventType.TakenDamageEvent) result.add(new EventBuilder(EventType.TakenDamageEvent)
.withTargetEntity(targetEntity.id) .withTargetEntity(targetEntity.id)
@ -571,6 +572,9 @@ public class GameLogic {
} }
} }
case PowerStone -> { case PowerStone -> {
ArrayList<Entity> found = state.entities.findByPosition(data.targetField);
Entity targetEntity = found.get(0);
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);
//this is ugly ... but also easy to understand //this is ugly ... but also easy to understand
@ -585,7 +589,7 @@ public class GameLogic {
.buildEntityEvent()); .buildEntityEvent());
} }
result.add(new EventBuilder(EventType.TakenDamageEvent) result.add(new EventBuilder(EventType.TakenDamageEvent)
.withTargetEntity(data.targetEntity) .withTargetEntity(targetEntity.id)
.withTargetField(data.targetField) .withTargetField(data.targetField)
.withAmount(origin.meleeDamage * 2) .withAmount(origin.meleeDamage * 2)
.buildEntityEvent()); .buildEntityEvent());
@ -610,9 +614,11 @@ public class GameLogic {
} }
} }
case SoulStone -> { case SoulStone -> {
Character target = (Character)state.entities.findEntity(data.targetEntity); ArrayList<Entity> found = state.entities.findByPosition(data.targetField);
Character target = (Character)found.get(0);
result.add(new EventBuilder(EventType.HealedEvent) result.add(new EventBuilder(EventType.HealedEvent)
.withTargetEntity(data.targetEntity) .withTargetEntity(target.id)
.withTargetField(data.targetField) .withTargetField(data.targetField)
.withAmount(target.hp.getMax()) .withAmount(target.hp.getMax())
.buildEntityEvent()); .buildEntityEvent());