52 lines
3.8 KiB
Markdown
52 lines
3.8 KiB
Markdown
# Task F6 — Death, Permadeath, and Narrative Resurrection
|
||
|
||
## Scope
|
||
|
||
Implemented F6 exclusively in the Godot port worktree:
|
||
|
||
- Added a run-domain `DeathEngine` that resolves a dead player into one of three explicit outcomes:
|
||
- **classic death**: ends the run while preserving its slot policy;
|
||
- **permadeath**: ends the run and marks the slot policy for retirement;
|
||
- **qualified narrative resurrection**: consumes the existing quest-only `misc_phylactere_narratif`, restores 25% of combat HP (minimum 1), applies permanent `-1 Endurance`, and records `marked_by_death`.
|
||
- Added persistent run lifecycle fields (`is_game_over`, `death_outcome`, `slot_policy`) so the later G1 save repository has an authoritative policy rather than inferring it from UI state.
|
||
- Wired the death resolver directly after every resolved player action. Final death journals either `run_ended` or `permadeath_run_retired`, displays the new `DeathPanel`, and blocks all subsequent routed or raw input. Resurrection journals `narrative_resurrection` and resumes the run without opening the panel.
|
||
- Added `scenes/ui/DeathPanel.tscn` and its focused presenter script, with player, floor, level, and death-mode/slot-policy messaging.
|
||
- Added strict TDD coverage:
|
||
- unit tests for the phylactery’s consumption, 25% recovery, permanent cost/flag, and classic/permadeath policies;
|
||
- real Game-scene E2E tests which kill the player through an actual adjacent enemy turn and verify classic panel/action lock, permadeath retirement, and narrative continuation.
|
||
|
||
No DCWASCII source was changed. No unrelated port behavior was changed.
|
||
|
||
## TDD and Root Cause
|
||
|
||
The red tests first failed as intended because `death_engine.gd`, `RunState` death lifecycle fields, and `HUD/DeathPanel` did not exist. Before F6, combat and collapse could reduce the player to zero HP and emit a normal `actor_died` descriptor, but the Game action pipeline had no authoritative player-death transition. Consequently it neither terminated/locked a run nor had a place to apply the data-backed narrative exception.
|
||
|
||
The root fix is a single post-resolution lifecycle boundary in `Game._resolve_player_death_if_needed()`, backed by the isolated `DeathEngine`. This keeps combat responsible for damage only, keeps the rare exception tied to the existing narrative quest item instead of a generic service, and makes final slot policy explicit for the future save layer.
|
||
|
||
## Verification
|
||
|
||
### Red → green
|
||
|
||
- Initial unit red run failed with the expected missing `res://scripts/domain/run/death_engine.gd`, unknown `DeathEngine`, and resulting absent death contract.
|
||
- Initial E2E red run failed with the expected missing `HUD/DeathPanel` and absent `RunState.is_game_over` lifecycle state.
|
||
- Green targeted runs passed:
|
||
- Unit: **178 / 178** tests, **1,331** assertions.
|
||
- E2E: **54 / 54** tests, **531** assertions.
|
||
|
||
### Full verification
|
||
|
||
`./scripts/verify.sh` completed successfully with Godot 4.5.0:
|
||
|
||
- Unit: **178 / 178** tests passed, **1,331** assertions
|
||
- Integration: **10 / 10** tests passed, **59,462** assertions
|
||
- E2E: **54 / 54** tests passed, **531** assertions
|
||
- Visual capture verification 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=489252`, `visible_pixels=17404`, `explored_pixels=17146`, `explored_luminance=0.012`, `unknown_pixels=439497`, `unknown_luminance=0.001`
|
||
|
||
The runner reported only known third-party GUT invalid-UID/resource-cleanup warnings; there were no application parse errors, script errors, test failures, or visual failures.
|
||
|
||
## Git
|
||
|
||
All intended F6 source, scene, test, UID, and report files are included in one local commit. No push and no pull request were created.
|