step 10.13: done

This commit is contained in:
bepis
2026-10-23 05:16:35 +11:00
parent 4277b9c273
commit 32fb0eee9a
8 changed files with 290 additions and 78 deletions
+22 -1
View File
@@ -9,6 +9,13 @@ const { computeHp } = require('../game/hp');
const { getEquipmentBonuses } = require('../game/equipment');
// Class → starter weapon item_id mapping.
const STARTER_WEAPONS = {
warrior: 1, // Rusty Sword
mage: 2, // Apprentice Staff
ranger: 3, // Hunters Shortbow
};
function wrapStmts(db) {
return {
findByUserId: db.prepare(
@@ -65,7 +72,21 @@ function createCharacter(userId, name, classKey) {
hpCurrent, ENERGY_MAX, now, now, now
);
return { id: result.lastInsertRowid };
const characterId = result.lastInsertRowid;
// Grant starter kit: class weapon (equipped) + 2 Minor Healing Potions.
const grantKit = db.transaction((cid, weaponId, potionId, qty, acquired) => {
db.prepare(
'INSERT INTO inventory (character_id, item_id, quantity, equipped_slot, acquired_at) VALUES (?, ?, ?, ?, ?)'
).run(cid, weaponId, 1, 'weapon', acquired);
db.prepare(
'INSERT INTO inventory (character_id, item_id, quantity, equipped_slot, acquired_at) VALUES (?, ?, ?, ?, ?)'
).run(cid, potionId, qty, null, acquired);
});
grantKit(characterId, STARTER_WEAPONS[classKey], 14, 2, now);
return { id: characterId };
}
/**