step 7.3: done
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user