V1.14.0: spell slots, rests, and a level-up checklist
- Spell slots. Every class that casts has a slot tracker, worked out from class and level: the full-caster table for bards, clerics, druids, sorcerers and wizards, the half-caster table for paladins and rangers (from level 2), and a warlock's few slots of one level. It is in the Spellcasting card on the sheet and in the character panel, and the party overview has a column for it. A player presses Use to spend a slot; only the DM gives one back. - Rests. The DM's "Rest…" button, beside the character list and on the party overview, rests any of the party at once. A short rest shows which Hit Dice each character can roll and heals from what they rolled (typed in, or rolled by the site), and gives a warlock their slots. A long rest puts back HP, every spell slot and half the level in Hit Dice, and clears temp HP. - Hit Dice are counted: one per level, shown on the sheet, the panel and the party overview. - Level Up. "Level Up…" on a sheet takes a character up one level with the whole checklist: the new max HP and a full heal, the class's new special abilities for levels 2 to 10, a Boon where the level grants one (Toughened raises Extra AC, Hardy gives temp HP now and after each long rest), fresh spell slots and new spells, and the free upgrade of one standard weapon. - A level typed into the Level field still writes down what the class gains on the way up, and leaves a line where a Boon is owed. - The docs cover all of it, with a generated list of what each class gains at each level. The Hollowcrown seed's note no longer says to track spell slots on paper. - New migration: spent spell slots and Hit Dice on a character. - All packages at version 1.14.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
const { hitDiceProblem, shortRest, longRest } = require('./rest');
|
||||
const { computeCharacterSheet } = require('../game/calculations');
|
||||
|
||||
const CLEAR = { deathSaveSuccesses: 0, deathSaveFailures: 0, stable: false };
|
||||
// A level 5 fighter (d10) with CON 14 (+2): 10 + 2 + 4 × (6 + 2) = 44 HP.
|
||||
const hero = (over = {}) => ({
|
||||
name: 'Aria',
|
||||
characterClass: 'FIGHTER',
|
||||
level: 5,
|
||||
conScore: 14,
|
||||
currentHp: 10,
|
||||
tempHp: 0,
|
||||
hitDiceUsed: 0,
|
||||
spellSlotsUsed: [],
|
||||
specialAbilities: null,
|
||||
...CLEAR,
|
||||
...over,
|
||||
});
|
||||
const sheet = (character) => computeCharacterSheet(character);
|
||||
|
||||
describe('shortRest', () => {
|
||||
test('spent Hit Dice heal what they rolled plus Constitution for each', () => {
|
||||
const c = hero();
|
||||
const { data, result } = shortRest(c, sheet(c), { dice: 2, rolls: [7, 4] });
|
||||
expect(data).toMatchObject({ currentHp: 25, hitDiceUsed: 2 });
|
||||
expect(result).toMatchObject({ hpBefore: 10, hpAfter: 25, maxHp: 44 });
|
||||
expect(result.hitDice).toMatchObject({ size: 10, spent: 2, total: 11, conBonus: 4, healed: 15, left: 3, of: 5 });
|
||||
});
|
||||
|
||||
test('takes a total rolled at the table, stops at max HP, and never takes HP away', () => {
|
||||
const c = hero({ currentHp: 40 });
|
||||
expect(shortRest(c, sheet(c), { dice: 1, rolled: 9 }).data.currentHp).toBe(44);
|
||||
const frail = hero({ conScore: 3, currentHp: 10 }); // CON -4
|
||||
const rest = shortRest(frail, sheet(frail), { dice: 1, rolled: 2 });
|
||||
expect(rest.data.currentHp).toBeUndefined();
|
||||
expect(rest.data.hitDiceUsed).toBe(1);
|
||||
expect(rest.result.hitDice.healed).toBe(0);
|
||||
});
|
||||
|
||||
test('with no dice spent nothing changes for a fighter', () => {
|
||||
const c = hero({ hitDiceUsed: 3 });
|
||||
expect(shortRest(c, sheet(c)).data).toEqual({ hitDiceUsed: 3 });
|
||||
});
|
||||
|
||||
test('gives a warlock their slots back, and nobody else', () => {
|
||||
const warlock = hero({ characterClass: 'WARLOCK', spellSlotsUsed: [0, 0, 2] });
|
||||
const rest = shortRest(warlock, sheet(warlock));
|
||||
expect(rest.data.spellSlotsUsed).toEqual([]);
|
||||
expect(rest.result.slotsRestored).toBe(true);
|
||||
|
||||
const wizard = hero({ characterClass: 'WIZARD', spellSlotsUsed: [2, 1] });
|
||||
const wizardRest = shortRest(wizard, sheet(wizard));
|
||||
expect(wizardRest.data.spellSlotsUsed).toBeUndefined();
|
||||
expect(wizardRest.result.slotsRestored).toBe(false);
|
||||
// ...but a wizard is reminded of Arcane Recovery: half their level, rounded up.
|
||||
expect(wizardRest.result.notes).toEqual([expect.stringContaining('Arcane Recovery')]);
|
||||
expect(wizardRest.result.notes[0]).toContain('3 slot levels');
|
||||
const fresh = hero({ characterClass: 'WIZARD' });
|
||||
expect(shortRest(fresh, sheet(fresh)).result.notes).toEqual([]);
|
||||
});
|
||||
|
||||
test('wakes a stable character who spends a Hit Die', () => {
|
||||
const c = hero({ currentHp: 0, stable: true });
|
||||
expect(shortRest(c, sheet(c), { dice: 1, rolled: 5 }).data).toMatchObject({ currentHp: 7, ...CLEAR });
|
||||
});
|
||||
});
|
||||
|
||||
describe('hitDiceProblem', () => {
|
||||
test('refuses more dice than are left, an impossible total, and the dying', () => {
|
||||
const c = hero({ hitDiceUsed: 4 });
|
||||
expect(hitDiceProblem(c, sheet(c), 0)).toBeNull();
|
||||
expect(hitDiceProblem(c, sheet(c), 1, 10)).toBeNull();
|
||||
expect(hitDiceProblem(c, sheet(c), 1)).toBeNull();
|
||||
expect(hitDiceProblem(c, sheet(c), 2)).toMatch(/1 Hit Die left/);
|
||||
expect(hitDiceProblem(c, sheet(c), 1, 11)).toMatch(/between 1 and 10/);
|
||||
expect(hitDiceProblem(c, sheet(c), 1, 0)).toMatch(/between 1 and 10/);
|
||||
const dying = hero({ currentHp: 0 });
|
||||
expect(hitDiceProblem(dying, sheet(dying), 1)).toMatch(/dying/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('longRest', () => {
|
||||
test('heals to full, gives back every slot and half the level in Hit Dice', () => {
|
||||
const c = hero({ characterClass: 'WIZARD', currentHp: 3, tempHp: 4, hitDiceUsed: 5, spellSlotsUsed: [4, 3, 2] });
|
||||
const { data, result } = longRest(c, sheet(c));
|
||||
expect(data).toEqual({ currentHp: sheet(c).hp.max, tempHp: 0, ...CLEAR, hitDiceUsed: 3, spellSlotsUsed: [] });
|
||||
expect(result.hitDice).toMatchObject({ regained: 2, left: 2, of: 5 });
|
||||
expect(result.slotsRestored).toBe(true);
|
||||
});
|
||||
|
||||
test('gives back at least one Hit Die, and no more than were spent', () => {
|
||||
const novice = hero({ level: 1, hitDiceUsed: 1 });
|
||||
expect(longRest(novice, sheet(novice)).data.hitDiceUsed).toBe(0);
|
||||
const rested = hero({ hitDiceUsed: 1 });
|
||||
expect(longRest(rested, sheet(rested)).result.hitDice).toMatchObject({ regained: 1, left: 5 });
|
||||
});
|
||||
|
||||
test('gets a dying character back on their feet', () => {
|
||||
const c = hero({ currentHp: 0, deathSaveFailures: 2, deathSaveSuccesses: 1 });
|
||||
expect(longRest(c, sheet(c)).data).toMatchObject({ currentHp: 44, ...CLEAR });
|
||||
});
|
||||
|
||||
test('leaves the Hardy Boon its Temp HP', () => {
|
||||
const c = hero({ tempHp: 2, specialAbilities: 'Hardy — +10 maximum HP: gain 10 Temp HP after each long rest.' });
|
||||
const { data, result } = longRest(c, sheet(c));
|
||||
expect(data.tempHp).toBe(10);
|
||||
expect(result.notes).toEqual(['Hardy: 10 Temp HP for the day.']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user