step 7.3: done

This commit is contained in:
bepis
2026-10-21 07:16:18 +11:00
parent 3991295395
commit 944a2e69d4
7 changed files with 201 additions and 28 deletions
+29 -1
View File
@@ -77,6 +77,11 @@ function getStmts(db) {
updateCharacterXp: db.prepare(
'UPDATE characters SET xp = ?, level = ?, unspent_points = ? WHERE id = ?'
),
// List all expedition definitions.
listDefs: db.prepare(
'SELECT * FROM expedition_defs ORDER BY min_level, id'
),
};
stmtCache.set(db, s);
}
@@ -255,4 +260,27 @@ function claimExpedition(characterId, expeditionId) {
};
}
module.exports = { startExpedition, getActive, claimExpedition };
/**
* List all expedition definitions (public, no auth needed but called behind requireAuth).
* @returns {Array<object>} expedition definitions ordered by min_level, id.
*/
function listDefinitions() {
const db = getDb();
const s = getStmts(db);
const rows = s.listDefs.all();
return rows.map((row) => ({
id: row.id,
slug: row.slug,
name: row.name,
description: row.description,
minLevel: row.min_level,
durationSec: row.duration_sec,
energyCost: row.energy_cost,
xpReward: row.xp_reward,
goldMin: row.gold_min,
goldMax: row.gold_max,
}));
}
module.exports = { startExpedition, getActive, claimExpedition, listDefinitions };