feat: add audio library and visual verification

This commit is contained in:
goose
2026-10-01 08:48:38 -04:00
parent ea4bbf15fa
commit 0615f5b89d
15 changed files with 363 additions and 26 deletions
+54 -22
View File
@@ -1,42 +1,74 @@
# Dungeon Crawler World — S3 Combat HUD
# Dungeon Crawler World — S4 Audio and visual verification
## Prerequisites
Godot 4.2+ (verified with Godot 4.5) is required. GUT **9.5.0** is vendored and pinned at `addons/gut`.
## Run
Godot 4.2+ is required (verified with Godot 4.5). GUT **9.5.0** is vendored and pinned at `addons/gut`. Linux visual verification needs either an active display or `xvfb-run`; the verification script uses Xvfb automatically when `DISPLAY` is unset.
## Run on Linux
```bash
"${GODOT_BIN:-$(command -v godot4 || command -v godot)}" --path .
```
Use WASD / arrow keys (and QEZC diagonals). The deterministic public E2E seam is `Game.submit_test_action(Vector2i)`; it calls the same action processor as keyboard input.
## Tests
Use WASD / arrow keys (and QEZC diagonals). `Game.submit_test_action(Vector2i)` is the deterministic public E2E seam and follows the same action processor as keyboard input.
## Optional ASCII audio layout
Audio is optional presentation. Its absence, unknown requests, missing folders, bad files, and unsupported codecs never affect a turn or game startup. No audio files ship with this repository.
`AudioLibrary` first searches the directory named by `DCW_AUDIO_HOME`; when it is unset, it searches `~/.local/share/dcwascii`. Place tracks in this exact layout:
```text
<root>/
├── audio/
│ ├── exploration/
│ ├── combat/
│ └── danger/
└── sfx/
├── attack_given/
├── attack_received/
├── menu_select/
├── menu_cancel/
├── item_use/
└── death/
```
Admitted file extensions are `.mp3`, `.ogg`, `.oga`, `.wav`, `.flac`, `.m4a`, and `.opus`. Godot-native playback is attempted for compatible `.wav`, `.ogg`/`.oga`/`.opus`, and `.mp3` files; other admitted extensions are discovered but silently skipped if no native loader is available. The game selects `exploration` at startup, changes to `combat` for a combat result, and dispatches SFX for player attacks, enemy attacks, and death.
Example:
```bash
DCW_AUDIO_HOME="$HOME/.local/share/dcwascii" "${GODOT_BIN:-godot4}" --path .
```
## Tests and visual check
```bash
GODOT_BIN=/snap/bin/godot4 ./scripts/test-unit.sh
GODOT_BIN=/snap/bin/godot4 ./scripts/test-e2e.sh
GODOT_BIN=/snap/bin/godot4 ./scripts/run-visual-check.sh
GODOT_BIN=/snap/bin/godot4 ./scripts/verify.sh
```
Scripts use `GODOT_BIN`, otherwise discover `godot4`, then `godot`, and run headlessly.
## Exploration et FOV
- Les cellules actuellement dans `GameState.visible_cells` sont affichées à pleine luminosité.
- Les cellules présentes seulement dans `GameState.explored_cells` restent visibles, mais sont assombries ; les cellules inconnues sont noires.
- La FOV est calculée contre la carte : les murs et portes fermées restent visibles mais masquent les cases situées derrière eux.
- Le rendu est synchronisé après chaque action via le même chemin que les entrées clavier et `Game.submit_test_action(Vector2i)`.
`run-visual-check.sh` runs the actual project with `--capture`, waits for it to render, logs output to `artifacts/visual-check.log`, and requires the project-owned capture at `artifacts/visual-check.png` to be a nonempty valid PNG. It chooses `xvfb-run` when no display is available, enforces a timeout, and reports **unavailable** (rather than a false pass) when neither a display nor Xvfb exists. `verify.sh` runs unit tests and headless E2E before visual verification; unavailable visual verification is reported distinctly from a failed test or failed visual capture.
## Combat HUD
- `HUD/PlayerHealthLabel` and `HUD/EnemyHealthLabel` show current hit points; the latter reports `No active target` after the goblin is defeated.
- `HUD/CombatSummaryLabel` is the separate public combat state: it identifies the current target and its hit points, then explicitly reports no active target after removal.
- Every `melee` and `enemy_melee` `TurnResult` is routed to its actor view. `ActorView.last_damage` records the received amount and the sprite is tinted red to make the hit visible.
- `HUD/EventLog` keeps appending all combat messages. The public E2E seam remains `Game.submit_test_action(Vector2i)` and uses the same action processor as keyboard input.
For a direct headless startup check:
## Verification
```bash
GODOT_BIN=/snap/bin/godot4 ./scripts/test-unit.sh
GODOT_BIN=/snap/bin/godot4 ./scripts/test-e2e.sh
GODOT_BIN=/snap/bin/godot4 ./scripts/verify.sh
GODOT_BIN=/snap/bin/godot4 timeout 3s /snap/bin/godot4 --headless --path .
```
The focused presentation unit test plus resolver tests and the real-scene E2E cover hit feedback, counterattack feedback, HUD values/summary/log, and enemy removal.
## Exploration, combat, and HUD
- `GameState.visible_cells` render at full brightness; cells retained in `explored_cells` render dimly; unknown cells are black.
- FOV is map-aware: walls and closed doors are visible but block cells behind them.
- `HUD/PlayerHealthLabel`, `HUD/EnemyHealthLabel`, `HUD/CombatSummaryLabel`, and `HUD/EventLog` expose the current combat state.
- Every `melee` and `enemy_melee` result is routed to its actor view; the sprite's persistent red tint makes received damage visible.
## Exports
Install the matching Godot export templates, then configure/export the project in the Godot editor for **Linux/X11** or **Windows Desktop**. Linux builds may be tested on a Linux host with the resulting executable. Windows exports can be produced from Linux when the export templates are installed, but this project does **not** claim that a Windows export has been tested on Windows.
## Limits
This slice deliberately provides one compact map, one deterministic goblin, direct pursuit, no persistence, inventory, audio, or animations/tweens. Damage feedback remains a persistent tint/state rather than a timed animation.
This compact prototype has one deterministic goblin, direct pursuit, no persistence or inventory UI, and persistent rather than animated damage tint. Audio remains intentionally nonblocking and uses no bundled assets.