From 4e005a7348328e8b071db098a8b31dae370be446 Mon Sep 17 00:00:00 2001 From: LlemonDuck Date: Mon, 29 Jan 2024 10:02:20 -0500 Subject: [PATCH] reset monster hp when switching monsters There is still a related but smaller bug with scaled monsters not setting to the correct value, but it's not new and I'm not sure how much extra work it would require (there's possible recursive concerns with watching monster.inputs). closes #198 --- src/state.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/state.tsx b/src/state.tsx index 752a8893..e22e67c9 100644 --- a/src/state.tsx +++ b/src/state.tsx @@ -239,6 +239,14 @@ class GlobalState implements State { this.recalculateEquipmentBonusesFromGearAll(); } })); + + // reset monster current hp when selecting a new monster + const monsterHpTriggers: ((r: IReactionPublic) => unknown)[] = [ + () => toJS(this.monster.id), + ]; + monsterHpTriggers.map((t) => reaction(t, () => { + this.monster.inputs.monsterCurrentHp = this.monster.skills.hp; + })); } set debug(debug: boolean) {