fix(combat): clear the monster's pending action once it is defeated
This commit is contained in:
@@ -252,6 +252,7 @@ describe('CombatEngineService', () => {
|
||||
|
||||
expect(result.state.status).toBe(CombatStatus.WON);
|
||||
expect(result.state.player.currentHp).toBe(100);
|
||||
expect(result.state.monster.stats.pendingAction).toBeUndefined();
|
||||
expect(result.events).toEqual([
|
||||
{ source: Combatant.PLAYER, target: Combatant.MONSTER, type: CombatEventType.DAMAGE, amount: 14 },
|
||||
{ source: Combatant.PLAYER, target: Combatant.MONSTER, type: CombatEventType.COMBAT_WON },
|
||||
|
||||
@@ -124,7 +124,8 @@ export class CombatEngineService {
|
||||
): CombatEngineResult {
|
||||
if (monster.currentHp <= 0) {
|
||||
events.push({ source: Combatant.PLAYER, target: Combatant.MONSTER, type: CombatEventType.COMBAT_WON });
|
||||
return { state: { ...state, player, monster, status: CombatStatus.WON }, events };
|
||||
const defeatedMonster = { ...monster, stats: { ...monster.stats, pendingAction: undefined } };
|
||||
return { state: { ...state, player, monster: defeatedMonster, status: CombatStatus.WON }, events };
|
||||
}
|
||||
|
||||
if (!interrupted) {
|
||||
|
||||
Reference in New Issue
Block a user