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