mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Adv 2.0 D&D Phase 11 D1b: DungeonRun state machine + dnd_zone_run schema
dnd_zone_run table (run_id, zone_id, room_seq_json, rooms_cleared, boss_defeated, abandoned, loot_collected, gm_mood, started_at, last_action_at, completed_at) added to db.go schema with active-run index. dnd_zone_run.go ships RoomType (entry|exploration|trap|elite|boss), DungeonRun struct, generateRoomSequence (Entry → ExplorationxN1 → Trap → ExplorationxN2 → Elite → Boss within zone's [MinRooms, MaxRooms]), and persistence helpers: startZoneRun (gates on level tier + active-run exclusivity), getActiveZoneRun, getZoneRun, markRoomCleared (advances and auto-completes on boss kill), abandonZoneRun, adjustGMMood (clamped to [0,100]), addLoot. 8 new tests covering room-sequence shape (entry first, boss last, exactly one trap/elite, ≥2 explorations), happy-path start, concurrent-run rejection, unknown-zone rejection, full advance-to-boss flow with completion, abandon idempotency, GM mood clamping at both bounds, and loot accumulation order. Full repo test suite green. Boss-room behavior, !zone command surface, and TwinBee narration arrive in D1c/D1d. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1604,6 +1604,32 @@ CREATE TABLE IF NOT EXISTS adventure_characters_pre_dnd (
|
||||
snapshot_json TEXT NOT NULL,
|
||||
snapshotted_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- ── D&D Layer (Phase 11 D1b — zone runs) ───────────────────────────────────
|
||||
-- A single in-progress or completed dungeon run. One row per run; players
|
||||
-- may have at most one row with completed_at IS NULL AND abandoned = 0
|
||||
-- (enforced in code, not via constraint, to keep migrations simple).
|
||||
-- room_seq_json is a JSON array of RoomType strings generated at run start;
|
||||
-- current_room indexes into that array. rooms_cleared is a JSON array of
|
||||
-- room indices the player has resolved (combat won / trap survived / etc.).
|
||||
CREATE TABLE IF NOT EXISTS dnd_zone_run (
|
||||
run_id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL,
|
||||
zone_id TEXT NOT NULL,
|
||||
current_room INTEGER NOT NULL DEFAULT 0,
|
||||
total_rooms INTEGER NOT NULL,
|
||||
room_seq_json TEXT NOT NULL DEFAULT '[]',
|
||||
rooms_cleared TEXT NOT NULL DEFAULT '[]',
|
||||
boss_defeated INTEGER NOT NULL DEFAULT 0,
|
||||
abandoned INTEGER NOT NULL DEFAULT 0,
|
||||
loot_collected TEXT NOT NULL DEFAULT '[]',
|
||||
gm_mood INTEGER NOT NULL DEFAULT 50,
|
||||
started_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_action_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
completed_at DATETIME
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_zone_run_active
|
||||
ON dnd_zone_run(user_id, completed_at, abandoned);
|
||||
`
|
||||
|
||||
// SeedSchedulerDefaults inserts default scheduler jobs if they don't exist.
|
||||
|
||||
Reference in New Issue
Block a user