BlueGit

timfa questward

Lower default player Health from level 10 to level 5.

New and legacy characters floor Health at 5 max HP; update tests that
assumed the old starting cap.

timfa Tim Falken · pushed by timfa

Authored 2026-09-01 · 2 months ago

Hash
e88eb7fcccc730c1cdaec6fe267fd10b399a7980
Parent
b67ec1da
11 files changed +33 −30
server/src/persistence/stateDb.js +1 −1
@@ -1250,7 +1250,7 @@ export class StateDatabase
1250 1250 {
1251 1251 const parsed = JSON.parse(row.skills_blob || "{}");
1252 1252 const skills = normalizePlayerSkills(parsed);
1253 // Persist floors (Health ≥ 10, others ≥ 1) for legacy under-leveled rows.
1253 // Persist floors (Health ≥ 5, others ≥ 1) for legacy under-leveled rows.
1254 1254 if (this.#skillsBlobNeedsRewrite(parsed, skills))
1255 1255 { this.saveSkills(characterId, skills); }
1256 1256 return skills;
@@ -1250,7 +1250,7 @@ export class StateDatabase
1250 {
1250 {
1251 const parsed = JSON.parse(row.skills_blob || "{}");
1251 const parsed = JSON.parse(row.skills_blob || "{}");
1252 const skills = normalizePlayerSkills(parsed);
1252 const skills = normalizePlayerSkills(parsed);
1253 // Persist floors (Health ≥ 10, others ≥ 1) for legacy under-leveled rows.
1253 // Persist floors (Health ≥ 5, others ≥ 1) for legacy under-leveled rows.
1254 if (this.#skillsBlobNeedsRewrite(parsed, skills))
1254 if (this.#skillsBlobNeedsRewrite(parsed, skills))
1255 { this.saveSkills(characterId, skills); }
1255 { this.saveSkills(characterId, skills); }
1256 return skills;
1256 return skills;
server/src/simulation/simulation.js +1 −1
@@ -429,7 +429,7 @@ export class Simulation
429 429 };
430 430 const skills = this.stateDb.getSkills(character.character_id) ?? defaultPlayerSkills();
431 431 const spells = this.stateDb.getSpells(character.character_id) ?? defaultPlayerSpells();
432 // Login floor: Health ≥ 10, every other skill ≥ 1 (persist if raised).
432 // Login floor: Health ≥ 5, every other skill ≥ 1 (persist if raised).
433 433 if (enforceMinimumSkillLevels(skills))
434 434 { this.stateDb.saveSkills(character.character_id, skills); }
435 435 const maxHealth = playerMaxHealth(skills);
@@ -429,7 +429,7 @@ export class Simulation
429 };
429 };
430 const skills = this.stateDb.getSkills(character.character_id) ?? defaultPlayerSkills();
430 const skills = this.stateDb.getSkills(character.character_id) ?? defaultPlayerSkills();
431 const spells = this.stateDb.getSpells(character.character_id) ?? defaultPlayerSpells();
431 const spells = this.stateDb.getSpells(character.character_id) ?? defaultPlayerSpells();
432 // Login floor: Health ≥ 10, every other skill ≥ 1 (persist if raised).
432 // Login floor: Health ≥ 5, every other skill ≥ 1 (persist if raised).
433 if (enforceMinimumSkillLevels(skills))
433 if (enforceMinimumSkillLevels(skills))
434 { this.stateDb.saveSkills(character.character_id, skills); }
434 { this.stateDb.saveSkills(character.character_id, skills); }
435 const maxHealth = playerMaxHealth(skills);
435 const maxHealth = playerMaxHealth(skills);
server/tests/alchemy.test.js +2 −2
@@ -304,7 +304,7 @@ test("drinking a lesser health tonic applies health regen", () =>
304 304 const worker = harness.simulation.workers[record.workerId];
305 305 const handle = worker.world.ecs.handleOf(entityId);
306 306 const health = worker.world.ecs.get(handle, Component.health);
307 health.current = 5;
307 health.current = 4;
308 308
309 309 const slotIndex = inserted.slots.findIndex((slot) => slot?.itemId === ItemId.potion);
310 310 harness.simulation.enqueue(1, { type: "drink-item", characterId: character.character_id, slotIndex });
@@ -315,7 +315,7 @@ test("drinking a lesser health tonic applies health regen", () =>
315 315 assert.ok(status?.effects?.some((entry) => entry.type === "health-regen"));
316 316
317 317 stepTimes(harness.simulation, 25);
318 assert.ok(Number(worker.world.ecs.get(handle, Component.health)?.current) > 5);
318 assert.ok(Number(worker.world.ecs.get(handle, Component.health)?.current) > 4);
319 319 }
320 320 finally
321 321 { harness.close(); }
@@ -304,7 +304,7 @@ test("drinking a lesser health tonic applies health regen", () =>
304 const worker = harness.simulation.workers[record.workerId];
304 const worker = harness.simulation.workers[record.workerId];
305 const handle = worker.world.ecs.handleOf(entityId);
305 const handle = worker.world.ecs.handleOf(entityId);
306 const health = worker.world.ecs.get(handle, Component.health);
306 const health = worker.world.ecs.get(handle, Component.health);
307 health.current = 5;
307 health.current = 4;
308
308
309 const slotIndex = inserted.slots.findIndex((slot) => slot?.itemId === ItemId.potion);
309 const slotIndex = inserted.slots.findIndex((slot) => slot?.itemId === ItemId.potion);
310 harness.simulation.enqueue(1, { type: "drink-item", characterId: character.character_id, slotIndex });
310 harness.simulation.enqueue(1, { type: "drink-item", characterId: character.character_id, slotIndex });
@@ -315,7 +315,7 @@ test("drinking a lesser health tonic applies health regen", () =>
315 assert.ok(status?.effects?.some((entry) => entry.type === "health-regen"));
315 assert.ok(status?.effects?.some((entry) => entry.type === "health-regen"));
316
316
317 stepTimes(harness.simulation, 25);
317 stepTimes(harness.simulation, 25);
318 assert.ok(Number(worker.world.ecs.get(handle, Component.health)?.current) > 5);
318 assert.ok(Number(worker.world.ecs.get(handle, Component.health)?.current) > 4);
319 }
319 }
320 finally
320 finally
321 { harness.close(); }
321 { harness.close(); }
server/tests/character-resume.test.js +1 −1
@@ -69,7 +69,7 @@ test("logout saves current health and login restores it", () =>
69 69 const again = harness.simulation.spawnCharacter(2, saved);
70 70 const resumed = harness.simulation.entityRecord(again);
71 71 assert.equal(resumed.health, 4);
72 assert.equal(resumed.maxHealth, 10);
72 assert.equal(resumed.maxHealth, 5);
73 73 }
74 74 finally
75 75 { harness.close(); }
@@ -69,7 +69,7 @@ test("logout saves current health and login restores it", () =>
69 const again = harness.simulation.spawnCharacter(2, saved);
69 const again = harness.simulation.spawnCharacter(2, saved);
70 const resumed = harness.simulation.entityRecord(again);
70 const resumed = harness.simulation.entityRecord(again);
71 assert.equal(resumed.health, 4);
71 assert.equal(resumed.health, 4);
72 assert.equal(resumed.maxHealth, 10);
72 assert.equal(resumed.maxHealth, 5);
73 }
73 }
74 finally
74 finally
75 { harness.close(); }
75 { harness.close(); }
server/tests/combat.test.js +4 −0
@@ -1140,6 +1140,10 @@ test("stacked combatants against the same target spread to different tiles", ()
1140 1140 spawnerId: null
1141 1141 }));
1142 1142 const worker = workerOf(harness.simulation, playerId);
1143 const handle = worker.world.ecs.handleOf(playerId);
1144 const playerHealth = worker.world.ecs.get(handle, Component.health);
1145 playerHealth.max = 500;
1146 playerHealth.current = 500;
1143 1147 teleportEntity(worker, rat2, 9, 8);
1144 1148
1145 1149 for (let i = 0; i < 200; i++)
@@ -1140,6 +1140,10 @@ test("stacked combatants against the same target spread to different tiles", ()
1140 spawnerId: null
1140 spawnerId: null
1141 }));
1141 }));
1142 const worker = workerOf(harness.simulation, playerId);
1142 const worker = workerOf(harness.simulation, playerId);
1143 const handle = worker.world.ecs.handleOf(playerId);
1144 const playerHealth = worker.world.ecs.get(handle, Component.health);
1145 playerHealth.max = 500;
1146 playerHealth.current = 500;
1143 teleportEntity(worker, rat2, 9, 8);
1147 teleportEntity(worker, rat2, 9, 8);
1144
1148
1145 for (let i = 0; i < 200; i++)
1149 for (let i = 0; i < 200; i++)
server/tests/combatLevel.test.js +2 −2
@@ -56,7 +56,7 @@ function skillsAtLevel (level)
56 56 test("combatLevelFromSkills applies D + max(M, R, S)", () =>
57 57 {
58 58 const starter = defaultPlayerSkills();
59 assert.equal(combatLevelFromSkills(starter), 3);
59 assert.equal(combatLevelFromSkills(starter), 2);
60 60
61 61 const focused = skillsAtLevel(30);
62 62 assert.equal(combatLevelFromSkills(focused), 40);
@@ -142,7 +142,7 @@ test("chunk peace prevents aggressive rats from auto-aggroing", () =>
142 142 function defaultPlayerSkills ()
143 143 {
144 144 return normalizePlayerSkills({
145 [SkillId.health]: totalXpForLevel(10),
145 [SkillId.health]: totalXpForLevel(5),
146 146 [SkillId.stamina]: totalXpForLevel(5)
147 147 });
148 148 }
@@ -56,7 +56,7 @@ function skillsAtLevel (level)
56test("combatLevelFromSkills applies D + max(M, R, S)", () =>
56test("combatLevelFromSkills applies D + max(M, R, S)", () =>
57{
57{
58 const starter = defaultPlayerSkills();
58 const starter = defaultPlayerSkills();
59 assert.equal(combatLevelFromSkills(starter), 3);
59 assert.equal(combatLevelFromSkills(starter), 2);
60
60
61 const focused = skillsAtLevel(30);
61 const focused = skillsAtLevel(30);
62 assert.equal(combatLevelFromSkills(focused), 40);
62 assert.equal(combatLevelFromSkills(focused), 40);
@@ -142,7 +142,7 @@ test("chunk peace prevents aggressive rats from auto-aggroing", () =>
142function defaultPlayerSkills ()
142function defaultPlayerSkills ()
143{
143{
144 return normalizePlayerSkills({
144 return normalizePlayerSkills({
145 [SkillId.health]: totalXpForLevel(10),
145 [SkillId.health]: totalXpForLevel(5),
146 [SkillId.stamina]: totalXpForLevel(5)
146 [SkillId.stamina]: totalXpForLevel(5)
147 });
147 });
148}
148}
server/tests/firestarting-cooking.test.js +2 −3
@@ -316,8 +316,7 @@ test("eating cooked venison heals and applies health regen", () =>
316 316 const worker = workerOf(harness.simulation, playerId);
317 317 const handle = worker.world.ecs.handleOf(playerId);
318 318 const health = worker.world.ecs.get(handle, Component.health);
319 health.current = 5;
320 health.max = 20;
319 health.current = 2;
321 320 giveInventory(harness, playerId, [
322 321 { itemId: CraftingItemId.cookedMeat, quantity: 1 }
323 322 ]);
@@ -329,7 +328,7 @@ test("eating cooked venison heals and applies health regen", () =>
329 328 });
330 329 harness.simulation.step();
331 330
332 assert.equal(health.current, 10);
331 assert.equal(health.current, 5);
333 332 const status = worker.world.ecs.get(handle, Component.statusEffects);
334 333 const regen = status?.effects?.find((e) => e.type === StatusEffectType.healthRegen);
335 334 assert.ok(regen);
@@ -316,8 +316,7 @@ test("eating cooked venison heals and applies health regen", () =>
316 const worker = workerOf(harness.simulation, playerId);
316 const worker = workerOf(harness.simulation, playerId);
317 const handle = worker.world.ecs.handleOf(playerId);
317 const handle = worker.world.ecs.handleOf(playerId);
318 const health = worker.world.ecs.get(handle, Component.health);
318 const health = worker.world.ecs.get(handle, Component.health);
319 health.current = 5;
319 health.current = 2;
320 health.max = 20;
321 giveInventory(harness, playerId, [
320 giveInventory(harness, playerId, [
322 { itemId: CraftingItemId.cookedMeat, quantity: 1 }
321 { itemId: CraftingItemId.cookedMeat, quantity: 1 }
323 ]);
322 ]);
@@ -329,7 +328,7 @@ test("eating cooked venison heals and applies health regen", () =>
329 });
328 });
330 harness.simulation.step();
329 harness.simulation.step();
331
330
332 assert.equal(health.current, 10);
331 assert.equal(health.current, 5);
333 const status = worker.world.ecs.get(handle, Component.statusEffects);
332 const status = worker.world.ecs.get(handle, Component.statusEffects);
334 const regen = status?.effects?.find((e) => e.type === StatusEffectType.healthRegen);
333 const regen = status?.effects?.find((e) => e.type === StatusEffectType.healthRegen);
335 assert.ok(regen);
334 assert.ok(regen);
server/tests/inventory.test.js +3 −3
@@ -329,7 +329,7 @@ test("eating food restores player health", () =>
329 329 const worker = workerOf(harness.simulation, playerId);
330 330 const handle = worker.world.ecs.handleOf(playerId);
331 331 const health = worker.world.ecs.get(handle, Component.health);
332 health.current = 6;
332 health.current = 4;
333 333 const bag = harness.simulation.bagOf(playerId);
334 334 const appleSlot = bag.inventory.findIndex((slot) => slot?.itemId === ItemId.apple);
335 335 assert.ok(appleSlot >= 0);
@@ -340,8 +340,8 @@ test("eating food restores player health", () =>
340 340 });
341 341 harness.simulation.step();
342 342 const after = worker.world.ecs.get(handle, Component.health);
343 assert.equal(after.current, 10);
344 assert.equal(after.max, 10);
343 assert.equal(after.current, 5);
344 assert.equal(after.max, 5);
345 345 const afterBag = harness.simulation.bagOf(playerId);
346 346 assert.equal(afterBag.inventory[appleSlot].quantity, 2);
347 347 }
@@ -329,7 +329,7 @@ test("eating food restores player health", () =>
329 const worker = workerOf(harness.simulation, playerId);
329 const worker = workerOf(harness.simulation, playerId);
330 const handle = worker.world.ecs.handleOf(playerId);
330 const handle = worker.world.ecs.handleOf(playerId);
331 const health = worker.world.ecs.get(handle, Component.health);
331 const health = worker.world.ecs.get(handle, Component.health);
332 health.current = 6;
332 health.current = 4;
333 const bag = harness.simulation.bagOf(playerId);
333 const bag = harness.simulation.bagOf(playerId);
334 const appleSlot = bag.inventory.findIndex((slot) => slot?.itemId === ItemId.apple);
334 const appleSlot = bag.inventory.findIndex((slot) => slot?.itemId === ItemId.apple);
335 assert.ok(appleSlot >= 0);
335 assert.ok(appleSlot >= 0);
@@ -340,8 +340,8 @@ test("eating food restores player health", () =>
340 });
340 });
341 harness.simulation.step();
341 harness.simulation.step();
342 const after = worker.world.ecs.get(handle, Component.health);
342 const after = worker.world.ecs.get(handle, Component.health);
343 assert.equal(after.current, 10);
343 assert.equal(after.current, 5);
344 assert.equal(after.max, 10);
344 assert.equal(after.max, 5);
345 const afterBag = harness.simulation.bagOf(playerId);
345 const afterBag = harness.simulation.bagOf(playerId);
346 assert.equal(afterBag.inventory[appleSlot].quantity, 2);
346 assert.equal(afterBag.inventory[appleSlot].quantity, 2);
347 }
347 }
server/tests/skills.test.js +13 −13
@@ -26,11 +26,11 @@ import { MobId } from "../../shared/definitions/mobs.js";
26 26 import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
27 27 import { installDamagingCombatRng } from "./helpers/combatRng.js";
28 28
29 test("enforceMinimumSkillLevels raises Health to 10 and leaves higher XP alone", () =>
29 test("enforceMinimumSkillLevels raises Health to 5 and leaves higher XP alone", () =>
30 30 {
31 31 const low = { xp: { health: 0, strength: 0 } };
32 32 assert.equal(enforceMinimumSkillLevels(low), true);
33 assert.equal(skillLevel(low, SkillId.health), 10);
33 assert.equal(skillLevel(low, SkillId.health), 5);
34 34 assert.equal(skillLevel(low, SkillId.strength), 1);
35 35 assert.equal(skillLevel(low, SkillId.stamina), 5);
36 36
@@ -51,7 +51,7 @@ test("login floors under-minimum skills and persists them", () =>
51 51
52 52 harness.simulation.spawnCharacter(1, character);
53 53 const stored = harness.stateDb.getSkills(character.character_id);
54 assert.equal(skillLevel(stored, SkillId.health), 10);
54 assert.equal(skillLevel(stored, SkillId.health), 5);
55 55 assert.equal(skillLevel(stored, SkillId.strength), 1);
56 56 assert.equal(skillLevel(stored, SkillId.defence), 1);
57 57 assert.equal(skillLevel(stored, SkillId.stamina), 5);
@@ -60,14 +60,14 @@ test("login floors under-minimum skills and persists them", () =>
60 60 { harness.close(); }
61 61 });
62 62
63 test("normalizeSkillXp floors Health to the level-10 starting XP", () =>
63 test("normalizeSkillXp floors Health to the level-5 starting XP", () =>
64 64 {
65 assert.equal(normalizeSkillXp({}).health, totalXpForLevel(10));
66 assert.equal(normalizeSkillXp({ health: 14 }).health, totalXpForLevel(10));
65 assert.equal(normalizeSkillXp({}).health, totalXpForLevel(5));
66 assert.equal(normalizeSkillXp({ health: 14 }).health, totalXpForLevel(5));
67 67 assert.equal(normalizeSkillXp({ health: totalXpForLevel(11) }).health, totalXpForLevel(11));
68 68 });
69 69
70 test("legacy empty skills_blob loads as Health level 10 max HP", () =>
70 test("legacy empty skills_blob loads as Health level 5 max HP", () =>
71 71 {
72 72 const harness = makeSimulation({ workerCount: 1 });
73 73 try
@@ -76,13 +76,13 @@ test("legacy empty skills_blob loads as Health level 10 max HP", () =>
76 76 harness.stateDb.db.prepare("UPDATE character_bags SET skills_blob = ? WHERE character_id = ?")
77 77 .run("{}", character.character_id);
78 78 const skills = harness.stateDb.getSkills(character.character_id);
79 assert.equal(skillLevel(skills, SkillId.health), 10);
80 assert.equal(playerMaxHealth(skills), 10);
79 assert.equal(skillLevel(skills, SkillId.health), 5);
80 assert.equal(playerMaxHealth(skills), 5);
81 81 const stored = JSON.parse(
82 82 harness.stateDb.db.prepare("SELECT skills_blob FROM character_bags WHERE character_id = ?")
83 83 .get(character.character_id).skills_blob
84 84 );
85 assert.ok((stored.xp?.health ?? stored.health) >= totalXpForLevel(10));
85 assert.ok((stored.xp?.health ?? stored.health) >= totalXpForLevel(5));
86 86 }
87 87 finally
88 88 { harness.close(); }
@@ -136,12 +136,12 @@ test("skillLevel reads player xp and mob levels", () =>
136 136 assert.equal(skillLevel({ levels: { [SkillId.unarmed]: 5 } }, SkillId.unarmed), 5);
137 137 });
138 138
139 test("new characters start with Health level 10", () =>
139 test("new characters start with Health level 5", () =>
140 140 {
141 141 const skills = defaultPlayerSkills();
142 assert.equal(skillLevel(skills, SkillId.health), 10);
142 assert.equal(skillLevel(skills, SkillId.health), 5);
143 143 assert.equal(skillLevel(skills, SkillId.strength), 1);
144 assert.equal(playerMaxHealth(skills), 10);
144 assert.equal(playerMaxHealth(skills), 5);
145 145 });
146 146
147 147 test("publicSkillsView exposes progress fields for the client", () =>
@@ -26,11 +26,11 @@ import { MobId } from "../../shared/definitions/mobs.js";
26import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
26import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
27import { installDamagingCombatRng } from "./helpers/combatRng.js";
27import { installDamagingCombatRng } from "./helpers/combatRng.js";
28
28
29test("enforceMinimumSkillLevels raises Health to 10 and leaves higher XP alone", () =>
29test("enforceMinimumSkillLevels raises Health to 5 and leaves higher XP alone", () =>
30{
30{
31 const low = { xp: { health: 0, strength: 0 } };
31 const low = { xp: { health: 0, strength: 0 } };
32 assert.equal(enforceMinimumSkillLevels(low), true);
32 assert.equal(enforceMinimumSkillLevels(low), true);
33 assert.equal(skillLevel(low, SkillId.health), 10);
33 assert.equal(skillLevel(low, SkillId.health), 5);
34 assert.equal(skillLevel(low, SkillId.strength), 1);
34 assert.equal(skillLevel(low, SkillId.strength), 1);
35 assert.equal(skillLevel(low, SkillId.stamina), 5);
35 assert.equal(skillLevel(low, SkillId.stamina), 5);
36
36
@@ -51,7 +51,7 @@ test("login floors under-minimum skills and persists them", () =>
51
51
52 harness.simulation.spawnCharacter(1, character);
52 harness.simulation.spawnCharacter(1, character);
53 const stored = harness.stateDb.getSkills(character.character_id);
53 const stored = harness.stateDb.getSkills(character.character_id);
54 assert.equal(skillLevel(stored, SkillId.health), 10);
54 assert.equal(skillLevel(stored, SkillId.health), 5);
55 assert.equal(skillLevel(stored, SkillId.strength), 1);
55 assert.equal(skillLevel(stored, SkillId.strength), 1);
56 assert.equal(skillLevel(stored, SkillId.defence), 1);
56 assert.equal(skillLevel(stored, SkillId.defence), 1);
57 assert.equal(skillLevel(stored, SkillId.stamina), 5);
57 assert.equal(skillLevel(stored, SkillId.stamina), 5);
@@ -60,14 +60,14 @@ test("login floors under-minimum skills and persists them", () =>
60 { harness.close(); }
60 { harness.close(); }
61});
61});
62
62
63test("normalizeSkillXp floors Health to the level-10 starting XP", () =>
63test("normalizeSkillXp floors Health to the level-5 starting XP", () =>
64{
64{
65 assert.equal(normalizeSkillXp({}).health, totalXpForLevel(10));
65 assert.equal(normalizeSkillXp({}).health, totalXpForLevel(5));
66 assert.equal(normalizeSkillXp({ health: 14 }).health, totalXpForLevel(10));
66 assert.equal(normalizeSkillXp({ health: 14 }).health, totalXpForLevel(5));
67 assert.equal(normalizeSkillXp({ health: totalXpForLevel(11) }).health, totalXpForLevel(11));
67 assert.equal(normalizeSkillXp({ health: totalXpForLevel(11) }).health, totalXpForLevel(11));
68});
68});
69
69
70test("legacy empty skills_blob loads as Health level 10 max HP", () =>
70test("legacy empty skills_blob loads as Health level 5 max HP", () =>
71{
71{
72 const harness = makeSimulation({ workerCount: 1 });
72 const harness = makeSimulation({ workerCount: 1 });
73 try
73 try
@@ -76,13 +76,13 @@ test("legacy empty skills_blob loads as Health level 10 max HP", () =>
76 harness.stateDb.db.prepare("UPDATE character_bags SET skills_blob = ? WHERE character_id = ?")
76 harness.stateDb.db.prepare("UPDATE character_bags SET skills_blob = ? WHERE character_id = ?")
77 .run("{}", character.character_id);
77 .run("{}", character.character_id);
78 const skills = harness.stateDb.getSkills(character.character_id);
78 const skills = harness.stateDb.getSkills(character.character_id);
79 assert.equal(skillLevel(skills, SkillId.health), 10);
79 assert.equal(skillLevel(skills, SkillId.health), 5);
80 assert.equal(playerMaxHealth(skills), 10);
80 assert.equal(playerMaxHealth(skills), 5);
81 const stored = JSON.parse(
81 const stored = JSON.parse(
82 harness.stateDb.db.prepare("SELECT skills_blob FROM character_bags WHERE character_id = ?")
82 harness.stateDb.db.prepare("SELECT skills_blob FROM character_bags WHERE character_id = ?")
83 .get(character.character_id).skills_blob
83 .get(character.character_id).skills_blob
84 );
84 );
85 assert.ok((stored.xp?.health ?? stored.health) >= totalXpForLevel(10));
85 assert.ok((stored.xp?.health ?? stored.health) >= totalXpForLevel(5));
86 }
86 }
87 finally
87 finally
88 { harness.close(); }
88 { harness.close(); }
@@ -136,12 +136,12 @@ test("skillLevel reads player xp and mob levels", () =>
136 assert.equal(skillLevel({ levels: { [SkillId.unarmed]: 5 } }, SkillId.unarmed), 5);
136 assert.equal(skillLevel({ levels: { [SkillId.unarmed]: 5 } }, SkillId.unarmed), 5);
137});
137});
138
138
139test("new characters start with Health level 10", () =>
139test("new characters start with Health level 5", () =>
140{
140{
141 const skills = defaultPlayerSkills();
141 const skills = defaultPlayerSkills();
142 assert.equal(skillLevel(skills, SkillId.health), 10);
142 assert.equal(skillLevel(skills, SkillId.health), 5);
143 assert.equal(skillLevel(skills, SkillId.strength), 1);
143 assert.equal(skillLevel(skills, SkillId.strength), 1);
144 assert.equal(playerMaxHealth(skills), 10);
144 assert.equal(playerMaxHealth(skills), 5);
145});
145});
146
146
147test("publicSkillsView exposes progress fields for the client", () =>
147test("publicSkillsView exposes progress fields for the client", () =>
shared/definitions/skills.js +1 −1
@@ -87,7 +87,7 @@ export const DEFAULT_PLAYER_SKILL_LEVELS = Object.freeze(Object.fromEntries(
87 87 ALL_SKILL_IDS.map((skillId) =>
88 88 {
89 89 if (skillId === SkillId.health)
90 { return [skillId, 10]; }
90 { return [skillId, 5]; }
91 91 if (skillId === SkillId.stamina)
92 92 { return [skillId, 5]; }
93 93 return [skillId, 1];
@@ -87,7 +87,7 @@ export const DEFAULT_PLAYER_SKILL_LEVELS = Object.freeze(Object.fromEntries(
87 ALL_SKILL_IDS.map((skillId) =>
87 ALL_SKILL_IDS.map((skillId) =>
88 {
88 {
89 if (skillId === SkillId.health)
89 if (skillId === SkillId.health)
90 { return [skillId, 10]; }
90 { return [skillId, 5]; }
91 if (skillId === SkillId.stamina)
91 if (skillId === SkillId.stamina)
92 { return [skillId, 5]; }
92 { return [skillId, 5]; }
93 return [skillId, 1];
93 return [skillId, 1];
shared/skills/state.js +3 −3
@@ -2,8 +2,8 @@ import { SkillId, SKILL_DEFINITIONS, ALL_SKILL_IDS, DEFAULT_PLAYER_SKILL_LEVELS
2 2 import { combatLevelFromSkills } from "../combat/combatLevel.js";
3 3 import { maxTotalSkillXp, totalXpForLevel, xpProgress, MAX_SKILL_LEVEL } from "./progression.js";
4 4
5 /** Health starts at level 10; Stamina at 5; other skills at level 1. */
6 export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 10);
5 /** Health starts at level 5; Stamina at 5; other skills at level 1. */
6 export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 5);
7 7
8 8 export function emptySkillXp ()
9 9 {
@@ -53,7 +53,7 @@ export function normalizePlayerSkills (stored)
53 53 return { xp: normalizeSkillXp(stored?.xp ?? stored) };
54 54 }
55 55
56 /** Starting skills for a new character (Health 10, Stamina 5, others 1). */
56 /** Starting skills for a new character (Health 5, Stamina 5, others 1). */
57 57 export function defaultPlayerSkills ()
58 58 {
59 59 return normalizePlayerSkills({
@@ -2,8 +2,8 @@ import { SkillId, SKILL_DEFINITIONS, ALL_SKILL_IDS, DEFAULT_PLAYER_SKILL_LEVELS
2import { combatLevelFromSkills } from "../combat/combatLevel.js";
2import { combatLevelFromSkills } from "../combat/combatLevel.js";
3import { maxTotalSkillXp, totalXpForLevel, xpProgress, MAX_SKILL_LEVEL } from "./progression.js";
3import { maxTotalSkillXp, totalXpForLevel, xpProgress, MAX_SKILL_LEVEL } from "./progression.js";
4
4
5/** Health starts at level 10; Stamina at 5; other skills at level 1. */
5/** Health starts at level 5; Stamina at 5; other skills at level 1. */
6export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 10);
6export const STARTING_HEALTH_XP = totalXpForLevel(DEFAULT_PLAYER_SKILL_LEVELS[SkillId.health] ?? 5);
7
7
8export function emptySkillXp ()
8export function emptySkillXp ()
9{
9{
@@ -53,7 +53,7 @@ export function normalizePlayerSkills (stored)
53 return { xp: normalizeSkillXp(stored?.xp ?? stored) };
53 return { xp: normalizeSkillXp(stored?.xp ?? stored) };
54}
54}
55
55
56/** Starting skills for a new character (Health 10, Stamina 5, others 1). */
56/** Starting skills for a new character (Health 5, Stamina 5, others 1). */
57export function defaultPlayerSkills ()
57export function defaultPlayerSkills ()
58{
58{
59 return normalizePlayerSkills({
59 return normalizePlayerSkills({