Fix issue #83: Add more things to the character sheet
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-15 20:40:05 +00:00
parent 2c1cc970e6
commit f0ffa2f72b
12 changed files with 1047 additions and 34 deletions

View File

@@ -34,7 +34,12 @@ function fromSource(source, pattern, locals = {}) {
}
const abilityStats = fromSource(script, /const abilityStats = \[[\s\S]*?\];/);
const normalizeActor = fromSource(script, /function normalizeActor\(actor\) \{[\s\S]*?\n\}/, { abilityStats });
// #83 put the skills, the saving throws, the tools, the languages and the coins into the
// sheet form, so reading that form out of the source reads their names along with it.
const skillList = fromSource(script, /const skillList = \[[\s\S]*?\];/);
const currencyUnits = fromSource(script, /const currencyUnits = \[[\s\S]*?\];/);
const proficiencyText = fromSource(script, /function proficiencyText\(value\) \{[\s\S]*?\n\}/);
const normalizeActor = fromSource(script, /function normalizeActor\(actor\) \{[\s\S]*?\n\}/, { abilityStats, skillList, currencyUnits, proficiencyText });
const barPercent = fromSource(script, /function barPercent\(current, max\) \{[\s\S]*?\n\}/);
const barPool = fromSource(actorRouteSource, /function barPool\(existing, value\) \{[\s\S]*?\n\}/);
@@ -117,10 +122,14 @@ test("the initiative bonus is the modifier of dexterity", () => {
/const initiativeBonus = computed\(\(\) => abilityModifier\(form\.value\.abilityScores\.dex\)\)/,
"D&D counts initiative as the dexterity modifier while the character carries no extra bonus"
);
const abilityModifier = fromSource(script, /function abilityModifier\(score\) \{[\s\S]*?\n\}/);
// #83 gave the helper an optional proficiency bonus, for the skills and the saving
// throws the character is proficient with; the bare modifier is unchanged.
const abilityModifier = fromSource(script, /function abilityModifier\(score[^{]*\) \{[\s\S]*?\n\}/);
assert.equal(abilityModifier(16), "+3");
assert.equal(abilityModifier(10), "+0", "the sheet writes a flat modifier with its sign, as the ability cards do");
assert.equal(abilityModifier(9), "-1");
assert.equal(abilityModifier(16, 3), "+6", "a proficient skill adds the proficiency bonus to its modifier");
assert.equal(abilityModifier(8, 2), "+1", "and one below 10 counts its own negative modifier first");
});
test("an actor carries its pools, and one without them starts on its level", () => {