feat: add safe rooms and repeatable Bobka rations

This commit is contained in:
goose
2026-10-04 11:08:19 -04:00
parent 34eb08f02a
commit 9bd003102c
16 changed files with 297 additions and 2 deletions
+37
View File
@@ -0,0 +1,37 @@
# PR-2 — Safe Rooms and Bobka
## Scope
PR-2 adds procedural safe-room support and the Bobka ration interaction without changing unrelated product areas.
- Generated floors reserve at least one non-entrance `refuge` or `sanctuary` when weighted unique-room selection would otherwise produce none.
- Safe rooms materialize exactly one reserved bed, are populated with Bobka, and expose floor/service helpers for validation and rest eligibility.
- Bobka's imported `give_item` dialogue effect is accepted only for Bobka and the ration item. It grants one ration per selection, appends explicit item/journal events, and does not read or mutate gold.
- The active run receives the authoritative content catalog for dialogue-time item construction; inventory gains a definition-ID count helper.
- Added unit, integration, and real Game E2E coverage for the safe-room contract.
## Verification finding and root-cause fix
The initial full verification found one genuine PR-2 E2E failure. The test refreshed `GameHud` with an untyped literal `[]`, while `GameHud.refresh` requires a typed `Array[GameEvent]`; Godot rejected the call before the Bobka scenario executed. The production path was not at fault. The test now consistently passes its declared `Array[GameEvent]`, preserving the intended E2E coverage. No workaround or production behavior change was added.
## Required confirmations
- **Bobka repeat ration / no gold:** the unit test invokes `give_bobka_ration` twice with a run starting at 47 gold and verifies two rations, the same gold total, and the expected grant/journal events. The real Game E2E selects Bobka's ration dialogue three times, verifies ration counts 1/2/3, asserts gold remains unchanged after every selection, and confirms the Bobka journal event.
- **Generator 20-seed invariants:** the integration suite generates 20 deterministic floor-four seeds. For every seed it verifies that the entrance is neither safe nor bed/NPC occupied, that at least one non-entrance safe room exists, and that every safe room has exactly one bed and a Bobka. `SafeRoomService.validate_floor` is empty for all 20 seeds.
## Final verification
`./scripts/verify.sh` completed successfully with Godot 4.5.0:
- Unit: **195 / 195** tests passed, **2,437** assertions.
- Integration: **14 / 14** tests passed, **235,636** assertions.
- E2E: **60 / 60** tests passed, **600** assertions.
- Visual capture: passed.
- `artifacts/visual-check.png`: `dungeon_non_black_pixels=489308`, `visible_pixels=17524`, `explored_pixels=10438`, `explored_luminance=0.012`, `unknown_pixels=365325`, `unknown_luminance=0.001`.
- `artifacts/visual-check-exit.png`: `dungeon_non_black_pixels=488708`, `visible_pixels=29407`, `explored_pixels=17146`, `explored_luminance=0.012`, `unknown_pixels=277574`, `unknown_luminance=0.001`.
The standard GUT invalid-UID and Godot cleanup/resource warnings occurred; there were no parse errors, script errors, test failures, or visual verification failures. Capture artifacts are intentionally ignored by `.gitignore`.
## Git
All intended PR-2 sources, generated UIDs, tests, and this report are committed locally in one commit. No push and no pull request were created.