Skip to content

Commit

Permalink
reset monster hp when switching monsters
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LlemonDuck authored and jayktaylor committed Jan 29, 2024
1 parent 605bf2d commit 4e005a7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4e005a7

Please sign in to comment.