feat: complete Phase 4 combat/hunting system

- Add content migration (003_content.sql): zones, monsters, items, loot tables
- Add inventory migration (004_inventory.sql) and logs migration (006_logs.sql)
- Add Mulberry32 PRNG (src/utils/rng.js) for deterministic combat
- Add combat system (src/game/combat.js) with turn order, crit, mage bonus, 20-round cap
- Add rewards/loot system (src/game/rewards.js) and leveling (src/game/leveling.js)
- Add hunt endpoint (POST /api/hunt) with full combat flow in DB transaction
- Add hunt integration tests and unit tests for rewards/leveling/combat
- Fix session middleware to use memory store in tests (avoids cleanup hang)
- Fix huntService transaction (db.transaction() returns wrapper, must call separately)
- Add huntService to helpers.js cache invalidation for test isolation
This commit is contained in:
bepis
2026-10-20 17:46:18 +11:00
parent 7a3e408ffc
commit f1ae7b3119
16 changed files with 1239 additions and 21 deletions
+12 -9
View File
@@ -5,17 +5,20 @@ const { getDb } = require('../db');
const { AppError } = require('../utils/errors');
function createSessionMiddleware() {
const db = getDb();
// Use memory store in tests to avoid session store cleanup interval hanging tests
const useMemoryStore = config.nodeEnv === 'test';
return session({
store: new SessionStore({
client: db,
table: 'sessions',
expired: {
clear: true,
intervalMs: 900000, // 15 min cleanup
},
}),
store: useMemoryStore
? undefined // express-session built-in memory store
: new SessionStore({
client: getDb(),
table: 'sessions',
expired: {
clear: true,
intervalMs: 900000, // 15 min cleanup
},
}),
secret: config.sessionSecret,
resave: false,
saveUninitialized: false,