From c27b6c5026e84c56a8fe9a0a8d2cc77f302412f9 Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Fri, 21 Aug 2026 15:59:32 +0200 Subject: [PATCH] feat(web): model HP regen fields and map CHARACTER_TOO_WOUNDED - Add hpRegenPerSecond and hpRegenSince fields to CharacterResponse - Update inventory-page.component.spec.ts fixture with new fields - Add CHARACTER_TOO_WOUNDED error mapping to combat.store - Add test for CHARACTER_TOO_WOUNDED error mapping - Update app.spec.ts and world.store.spec.ts fixtures for compilation Co-Authored-By: Claude Sonnet 5 --- apps/web/src/app/app.spec.ts | 2 ++ apps/web/src/app/core/api/game-api.models.ts | 2 ++ .../src/app/features/combat/combat.store.spec.ts | 16 ++++++++++++++++ apps/web/src/app/features/combat/combat.store.ts | 1 + .../inventory/inventory-page.component.spec.ts | 2 ++ .../src/app/features/world/world.store.spec.ts | 2 ++ 6 files changed, 25 insertions(+) diff --git a/apps/web/src/app/app.spec.ts b/apps/web/src/app/app.spec.ts index dbc6be7..0ca6613 100644 --- a/apps/web/src/app/app.spec.ts +++ b/apps/web/src/app/app.spec.ts @@ -158,6 +158,8 @@ describe('App', () => { currentHp: 52, maxHp: 80, attack: 12, + hpRegenPerSecond: 1, + hpRegenSince: null, currentLocation: { id: 'location-id', key: 'south-gate', name: 'Südtor von Graufurt' }, }); const fixture = TestBed.createComponent(AppShellComponent); diff --git a/apps/web/src/app/core/api/game-api.models.ts b/apps/web/src/app/core/api/game-api.models.ts index 367dc30..a888dbd 100644 --- a/apps/web/src/app/core/api/game-api.models.ts +++ b/apps/web/src/app/core/api/game-api.models.ts @@ -13,6 +13,8 @@ export interface CharacterResponse { currentHp: number; maxHp: number; attack: number; + hpRegenPerSecond: number; + hpRegenSince: string | null; currentLocation: LocationSummary; } diff --git a/apps/web/src/app/features/combat/combat.store.spec.ts b/apps/web/src/app/features/combat/combat.store.spec.ts index 5c0acda..69a2336 100644 --- a/apps/web/src/app/features/combat/combat.store.spec.ts +++ b/apps/web/src/app/features/combat/combat.store.spec.ts @@ -84,6 +84,22 @@ describe('CombatStore', () => { expect(store.errorCode()).toBe('COMBAT_ALREADY_ACTIVE'); }); + it('maps CHARACTER_TOO_WOUNDED to its German message', async () => { + api.startCombat.mockReturnValue( + throwError( + () => + new HttpErrorResponse({ + status: 409, + error: { statusCode: 409, code: 'CHARACTER_TOO_WOUNDED', message: 'Too wounded.' }, + }), + ), + ); + + await store.startCombat('encounter-1'); + + expect(store.error()).toBe('Du bist zu schwer verwundet, um zu kämpfen. Warte, bis du dich erholt hast.'); + }); + it('loads the running combat and clears the error that sent us looking for it', async () => { api.startCombat.mockReturnValue( throwError( diff --git a/apps/web/src/app/features/combat/combat.store.ts b/apps/web/src/app/features/combat/combat.store.ts index db18682..a9e45b5 100644 --- a/apps/web/src/app/features/combat/combat.store.ts +++ b/apps/web/src/app/features/combat/combat.store.ts @@ -13,6 +13,7 @@ const COMBAT_ERROR_MESSAGES: Readonly> = { HUNT_ENCOUNTER_ALREADY_CONSUMED: 'Diese Begegnung wurde bereits genutzt.', INVALID_HUNT_ENCOUNTER: 'Diese Begegnung ist nicht mehr gültig.', CHARACTER_TRAVELLING: 'Du kannst nicht kämpfen, während du unterwegs bist.', + CHARACTER_TOO_WOUNDED: 'Du bist zu schwer verwundet, um zu kämpfen. Warte, bis du dich erholt hast.', COMBAT_ALREADY_ACTIVE: 'Du befindest dich bereits in einem Kampf.', COMBAT_NOT_FOUND: 'Dieser Kampf wurde nicht gefunden.', COMBAT_ALREADY_FINISHED: 'Dieser Kampf ist bereits beendet.', diff --git a/apps/web/src/app/features/inventory/inventory-page.component.spec.ts b/apps/web/src/app/features/inventory/inventory-page.component.spec.ts index 063fad5..f95e4ab 100644 --- a/apps/web/src/app/features/inventory/inventory-page.component.spec.ts +++ b/apps/web/src/app/features/inventory/inventory-page.component.spec.ts @@ -71,6 +71,8 @@ const character: CharacterResponse = { currentHp: 100, maxHp: 100, attack: 6, + hpRegenPerSecond: 1, + hpRegenSince: null, currentLocation: { id: 'loc-1', key: 'south-gate', name: 'Südtor' }, }; diff --git a/apps/web/src/app/features/world/world.store.spec.ts b/apps/web/src/app/features/world/world.store.spec.ts index 589c26c..6700f6d 100644 --- a/apps/web/src/app/features/world/world.store.spec.ts +++ b/apps/web/src/app/features/world/world.store.spec.ts @@ -20,6 +20,8 @@ const character: CharacterResponse = { currentHp: 100, maxHp: 100, attack: 6, + hpRegenPerSecond: 1, + hpRegenSince: null, currentLocation: { id: 'origin-id', key: 'south-gate', name: 'Südtor' }, };