V1.1.0: gear levels, encounter overhaul, guided builder, trading, docs
Characters - Builder: pick-then-Next on every step with live preview, Back button, plain-language help throughout, and "Suggest for me" for ability scores - Motivation is picked from a list; new steps for special abilities, background and appearance, all composed from fixed lists and DM-only to edit afterwards - Copy a character to another campaign - Characters can give gold, weapons, items and spells to each other - Money tracker: gold only changes through a logged ledger - Fixes: level/XP/location are DM-only, HP stays within 0..max, physical dice ability rolls, every die is rolled once Gear - DM-managed item pool; weapons, items and spells are handed out by the DM - Starting-option flag per pool entry - Gear levels 1-9 per held copy with a damage ladder, growth rate and starting level; spells gated by spell level with a fixed damage value - Spell library carries default damage; damage is picked from a list Encounters - Battle and NPC quest modes, turn tracking, scene description, DM notes - NPCs, richer combatant cards, conditions from a list - Rewards (gold, weapons, items) lined up and awarded, with gold splitting - Character HP is shared between the sheet and the encounter - Monster stat blocks and NPC secrets are never sent to players Other - Dice roller on every page - Docs for characters, weapons, spells, items, encounters, monsters and NPCs, with full lists generated from the data (npm run docs:lists) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
const crypto = require('crypto');
|
||||
const { SPECIES } = require('./data/species');
|
||||
const { CLASSES } = require('./data/classes');
|
||||
const { SPECIES_TRAITS, CLASS_FEATURES, TALENTS, TALENT_PICKS } = require('./data/characterOptions');
|
||||
|
||||
const ALL_SPECIES = Object.keys(SPECIES);
|
||||
const ALL_CLASSES = Object.keys(CLASSES);
|
||||
@@ -28,15 +29,6 @@ const CLASS_ROLL_TABLE = {
|
||||
8: 'WILDCARD',
|
||||
};
|
||||
|
||||
const MOTIVATION_TABLE = {
|
||||
1: 'Revenge for a past wrong',
|
||||
2: 'Seeking fortune or wealth',
|
||||
3: 'Protecting someone they love',
|
||||
4: 'Redemption for a past mistake',
|
||||
5: 'Driven by curiosity or knowledge',
|
||||
6: 'Duty or oath to a cause or order',
|
||||
};
|
||||
|
||||
function rollDie(sides) {
|
||||
return crypto.randomInt(1, sides + 1);
|
||||
}
|
||||
@@ -87,6 +79,60 @@ function validateManualRoll(sides, value) {
|
||||
return Number.isInteger(value) && value >= 1 && value <= sides;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Story steps: background, appearance and special abilities are composed from
|
||||
// picks out of fixed lists, never typed in.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// `picks` maps each group's key to the option keys chosen in it. Returns a
|
||||
// message describing the first problem, or null if the picks are valid.
|
||||
function validatePicks(groups, picks) {
|
||||
for (const group of groups) {
|
||||
const chosen = picks[group.key] || [];
|
||||
if (!Array.isArray(chosen) || new Set(chosen).size !== chosen.length) return `${group.label}: pick each option once.`;
|
||||
if (chosen.some((key) => !group.options.some((o) => o.key === key))) return `${group.label}: that is not one of the options.`;
|
||||
if (chosen.length < group.min || chosen.length > group.max) {
|
||||
const range = group.min === group.max ? `${group.min}` : `${group.min} to ${group.max}`;
|
||||
return `${group.label}: pick ${range}.`;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// One line per group, in the groups' order: "Upbringing: Soldier — Served in
|
||||
// an army…" or, for several picks, "Personality: Brave, Curious".
|
||||
function composeFromPicks(groups, picks) {
|
||||
const lines = [];
|
||||
for (const group of groups) {
|
||||
const chosen = group.options.filter((o) => (picks[group.key] || []).includes(o.key));
|
||||
if (chosen.length === 0) continue;
|
||||
const detail = chosen.length === 1 && chosen[0].text ? ` — ${chosen[0].text}` : '';
|
||||
lines.push(`${group.label}: ${chosen.map((o) => o.label).join(', ')}${detail}`);
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function validateTalents(talentKeys) {
|
||||
const valid = new Set(talentKeys).size === talentKeys.length && talentKeys.every((key) => TALENTS.some((t) => t.key === key));
|
||||
return valid && talentKeys.length === TALENT_PICKS ? null : `Pick ${TALENT_PICKS} different talents from the list.`;
|
||||
}
|
||||
|
||||
// Everything a new character can do beyond the numbers: what its species and
|
||||
// class grant automatically, then the talents the player picked.
|
||||
function composeSpecialAbilities(species, characterClass, talentKeys = []) {
|
||||
const abilities = [
|
||||
...(SPECIES_TRAITS[species] || []),
|
||||
...(CLASS_FEATURES[characterClass] || []),
|
||||
...TALENTS.filter((t) => talentKeys.includes(t.key)),
|
||||
];
|
||||
// A trait granted twice over (two sources of Darkvision, say) is listed once.
|
||||
const seen = new Set();
|
||||
return abilities
|
||||
.filter((a) => !seen.has(a.name) && seen.add(a.name))
|
||||
.map((a) => `${a.name} — ${a.text}`)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
function speciesChoicesForRoll(roll) {
|
||||
const entry = SPECIES_ROLL_TABLE[roll];
|
||||
if (entry === 'WILDCARD') return { type: 'wildcard', options: ALL_SPECIES };
|
||||
@@ -103,7 +149,6 @@ function classChoicesForRoll(roll) {
|
||||
module.exports = {
|
||||
SPECIES_ROLL_TABLE,
|
||||
CLASS_ROLL_TABLE,
|
||||
MOTIVATION_TABLE,
|
||||
ALL_SPECIES,
|
||||
ALL_CLASSES,
|
||||
rollDie,
|
||||
@@ -114,4 +159,8 @@ module.exports = {
|
||||
randomSample,
|
||||
autoSelectSkills,
|
||||
validateManualRoll,
|
||||
validatePicks,
|
||||
composeFromPicks,
|
||||
validateTalents,
|
||||
composeSpecialAbilities,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user