(Underdepths) Pass 2
This commit is contained in:
1 parent
4a5a92cb74
commit
b49c285c89
37 files changed
+5590
No files matched your search
@@ -0,0 +1,21 @@
|
||||
Phase 4 is complete and nothing regressed. Here's a summary of what was built:
|
||||
|
||||
## Phase 4 — Polish, Audio, Persist: Complete
|
||||
|
||||
**New files:**
|
||||
|
||||
- **`engine/serializers.py`** — Thin JSON converters for `Rect`, `Item`, `Enemy`, `Player`, `GameMap`. Tuples→lists, sets→lists; `visible` grids excluded (recomputed on load); effects timers persisted.
|
||||
|
||||
- **`engine/game_state.py`** — `GameSession` (`@dataclass(slots=True)`) as the single source of truth: `player`, `dungeon` (all 10 floors), `current_floor`, `log` (capped at 50), `turn`, `state`, `rng_seed`. Implements `new_game`, `apply_action` (move/pickup/descend/save/quaff/read/equip/wait), `to_dict`/`from_dict`, `save`/`load`. Each turn: runs all live enemies with per-enemy FOV (player tile hidden when invisible), recomputes player FOV into `visible`+`explored`, then resolves death/victory. Fixed a stale-floor bug so post-descent processing targets the new floor.
|
||||
|
||||
- **`engine/audio.py`** — `AudioEngine` synthesizes 8 tones (hit/miss/damage/pickup/stairs/levelup/death/victory) with stdlib `array` written straight into `pygame.mixer.Sound(buffer=...)` (no numpy, no asset files). Mixer init is fully guarded; never raises; plays are no-ops when disabled/muted.
|
||||
|
||||
- **`render/camera.py`** — Player-centered, map-clamped viewport (50×30 tiles).
|
||||
|
||||
- **`render/renderer.py`** — Colored 16×16 tiles (visible/explored/unexplored), type-coded entities, stairs glyph, top bar (floor/HP/level/XP), color-coded log panel, equipment + sound bottom bar, context prompts (`Press G to pick up <name>` / `Press > (Shift+.) to descend`), plus main-menu and end-screen drawing.
|
||||
|
||||
- **`main.py`** (rewritten) — Full state machine: menu (New Game/Continue[only if save]/How to Play/Quit) with keyboard+mouse; How-to-Play before each New Game and via `?`; `g`/`>`/`i`/`e`/`q`/`r`/`S`/`m`/Esc all wired to `apply_action` tuples; death screen deletes save → menu on keypress; victory screen likewise. Headless-safe: under dummy drivers it runs a scripted playthrough (menu→play→save→continue→help→mute) and exits 0, cleaning up its own test save.
|
||||
|
||||
**Verification:**
|
||||
- Phase 4: 7/7 ✅ · Phase all: 27/27 ✅ · Smoke play: 6/6 ✅ · Phases 1–3 re-verified ✅
|
||||
- `python main.py` headless exits 0; audio survives forced mixer failure; 8-run randomized stress + forced full-descent-to-victory integration tests had **0 crashes**; save/load mid-descent and effects-timer persistence confirmed.
|
||||
Reference in new issue
Block a user