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:
@@ -14,6 +14,10 @@ const {
|
||||
weaponDamageBonus,
|
||||
computeCharacterSheet,
|
||||
computeWeaponStats,
|
||||
DAMAGE_LADDER,
|
||||
diceAverage,
|
||||
scaledDamageDice,
|
||||
canUseGear,
|
||||
} = require('./calculations');
|
||||
|
||||
describe('abilityModifier', () => {
|
||||
@@ -211,4 +215,110 @@ describe('computeWeaponStats', () => {
|
||||
expect(stats.damageBonus).toBe(sheet.abilities.STR.modifier);
|
||||
expect(stats.damageDice).toBe('1d8');
|
||||
});
|
||||
|
||||
test('uses the dice for the level of the copy the character holds', () => {
|
||||
const sheet = computeCharacterSheet({ level: 5, strScore: 16 });
|
||||
const spear = { attackAbility: 'STR', damageDice: '1d6', damageType: 'piercing', damageScaling: 1 };
|
||||
expect(computeWeaponStats(spear, sheet.abilities, sheet.proficiencyBonus, true, 3).damageDice).toBe('1d10');
|
||||
// The level changes the dice only, never the bonuses.
|
||||
expect(computeWeaponStats(spear, sheet.abilities, sheet.proficiencyBonus, true, 3).damageBonus).toBe(sheet.abilities.STR.modifier);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gear levels — the damage ladder', () => {
|
||||
test('starts with single dice, then pairs, in the smallest possible steps', () => {
|
||||
expect(DAMAGE_LADDER.slice(0, 13).map((r) => r.dice)).toEqual([
|
||||
'1d4', '1d6', '1d8', '1d10', '1d12',
|
||||
'2d6', '1d6+1d8', '2d8', '1d8+1d10', '2d10', '1d10+1d12', '2d12',
|
||||
'3d8',
|
||||
]);
|
||||
});
|
||||
|
||||
test('every rung is stronger than the last by 1 average damage, or 0.5 where a die is added', () => {
|
||||
for (let i = 1; i < DAMAGE_LADDER.length; i++) {
|
||||
const step = DAMAGE_LADDER[i].average - DAMAGE_LADDER[i - 1].average;
|
||||
expect([0.5, 1]).toContain(step);
|
||||
// The stated average really is the average of the dice shown.
|
||||
expect(diceAverage(DAMAGE_LADDER[i].dice)).toBe(DAMAGE_LADDER[i].average);
|
||||
}
|
||||
});
|
||||
|
||||
test('diceAverage reads the expressions DMs type, and rejects free text', () => {
|
||||
expect(diceAverage('1d8')).toBe(4.5);
|
||||
expect(diceAverage('d8')).toBe(4.5);
|
||||
expect(diceAverage('2d6')).toBe(7);
|
||||
expect(diceAverage('1d6 + 1d8')).toBe(8);
|
||||
expect(diceAverage('2d4+2')).toBe(7);
|
||||
expect(diceAverage('1d6-1')).toBe(2.5);
|
||||
expect(diceAverage('3')).toBe(3);
|
||||
expect(diceAverage('special')).toBeNull();
|
||||
expect(diceAverage('')).toBeNull();
|
||||
expect(diceAverage(null)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('scaledDamageDice', () => {
|
||||
const byLevel = (base, scaling, levels) => levels.map((level) => scaledDamageDice(base, level, scaling));
|
||||
|
||||
test('standard gear climbs one rung per level', () => {
|
||||
expect(byLevel('1d4', 1, [1, 2, 3, 4, 5, 6])).toEqual(['1d4', '1d6', '1d8', '1d10', '1d12', '2d6']);
|
||||
expect(byLevel('1d8', 1, [1, 2, 3])).toEqual(['1d8', '1d10', '1d12']);
|
||||
});
|
||||
|
||||
test('powerful and legendary gear climb two and three rungs per level', () => {
|
||||
expect(byLevel('1d6', 2, [1, 2, 3, 4])).toEqual(['1d6', '1d10', '2d6', '2d8']);
|
||||
expect(byLevel('1d8', 3, [1, 2, 3])).toEqual(['1d8', '2d6', '1d8+1d10']);
|
||||
});
|
||||
|
||||
test('level 1 is always the base dice exactly as written', () => {
|
||||
expect(scaledDamageDice('2d4+2', 1, 1)).toBe('2d4+2');
|
||||
expect(scaledDamageDice('special', 1, 3)).toBe('special');
|
||||
});
|
||||
|
||||
test('dice that are not on the ladder start from the highest rung that does not beat them', () => {
|
||||
expect(scaledDamageDice('2d4+2', 2, 1)).toBe('1d6+1d8'); // avg 7 sits on 2d6
|
||||
expect(scaledDamageDice('1d4+1', 2, 1)).toBe('1d8'); // avg 3.5 sits on 1d6
|
||||
expect(scaledDamageDice('1', 2, 1)).toBe('1d4'); // below the ladder
|
||||
});
|
||||
|
||||
test('free text never scales, and levels and scaling are clamped to their ranges', () => {
|
||||
expect(scaledDamageDice('special', 9, 3)).toBe('special');
|
||||
expect(scaledDamageDice('1d4', 99, 1)).toBe(scaledDamageDice('1d4', 9, 1));
|
||||
expect(scaledDamageDice('1d4', 9, 1)).toBe('1d8+1d10');
|
||||
expect(scaledDamageDice('1d4', 0, 1)).toBe('1d4');
|
||||
expect(scaledDamageDice('1d4', 2, 99)).toBe(scaledDamageDice('1d4', 2, 3));
|
||||
expect(scaledDamageDice('1d4', 2, undefined)).toBe('1d6');
|
||||
});
|
||||
|
||||
test('gear with a starting level shows its base dice there and climbs from it', () => {
|
||||
// A greatsword that only exists from level 3: 2d6 at 3, then one rung per level.
|
||||
expect([3, 4, 5].map((level) => scaledDamageDice('2d6', level, 1, 3))).toEqual(['2d6', '1d6+1d8', '2d8']);
|
||||
expect(scaledDamageDice('2d6', 1, 1, 3)).toBe('2d6'); // never below its base
|
||||
expect(scaledDamageDice('2d4+2', 3, 2, 3)).toBe('2d4+2'); // as written at its starting level
|
||||
const sheet = computeCharacterSheet({ level: 5, strScore: 16 });
|
||||
const greatsword = { attackAbility: 'STR', damageDice: '2d6', damageType: 'slashing', damageScaling: 1, minLevel: 3 };
|
||||
expect(computeWeaponStats(greatsword, sheet.abilities, sheet.proficiencyBonus, true, 4).damageDice).toBe('1d6+1d8');
|
||||
});
|
||||
|
||||
test('a higher level is never weaker', () => {
|
||||
for (const base of ['1d4', '1d12', '2d6', '2d4+2']) {
|
||||
for (const scaling of [1, 2, 3]) {
|
||||
for (let level = 2; level <= 9; level++) {
|
||||
expect(diceAverage(scaledDamageDice(base, level, scaling))).toBeGreaterThan(
|
||||
diceAverage(scaledDamageDice(base, level - 1, scaling))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUseGear', () => {
|
||||
test('a character can use gear of their own level or lower', () => {
|
||||
expect(canUseGear(1, 1)).toBe(true);
|
||||
expect(canUseGear(3, 1)).toBe(true);
|
||||
expect(canUseGear(3, 3)).toBe(true);
|
||||
expect(canUseGear(2, 3)).toBe(false);
|
||||
expect(canUseGear(1, 0)).toBe(true); // cantrips
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user