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:
2026-10-10 10:47:56 +02:00
co-authored by Claude Opus 5.5
parent 3a867fd1a1
commit e9f8169286
34 changed files with 2855 additions and 61 deletions
+9
View File
@@ -31,6 +31,7 @@ import { Spinner, ErrorBanner } from '../components/Spinner';
import { NumberInput } from '../components/NumberInput';
import { SectionNav, type Section } from '../components/SectionNav';
import { LifeBadge } from '../components/DeathSaves';
import { RestModal } from '../components/RestModal';
import { Pagination } from '../components/Paginated';
import { usePagination } from '../hooks/usePagination';
import { CampaignSearch, type SearchGroup } from '../components/campaign/CampaignSearch';
@@ -168,6 +169,7 @@ export function CampaignHomePage() {
const [formError, setFormError] = useState<string | null>(null);
const [showSettings, setShowSettings] = useState(false);
const [showDelete, setShowDelete] = useState(false);
const [resting, setResting] = useState(false);
const [deleteConfirmName, setDeleteConfirmName] = useState('');
const liveEncounters = encounters?.filter((e) => !e.archivedAt) || [];
@@ -432,6 +434,11 @@ export function CampaignHomePage() {
<div className="section-block">
<div className="page-header" style={{ marginBottom: '0.75rem' }}>
<h2 style={{ fontSize: '1.1rem', margin: 0 }}>{isDM ? 'Characters' : 'Rest of the Party'}</h2>
{isDM && characters?.some((c) => c.buildStage === 'COMPLETE') && (
<button className="btn" onClick={() => setResting(true)} title="A short or long rest for any of the party: Hit Dice, HP and spell slots">
🛏 Rest…
</button>
)}
</div>
<form onSubmit={handleCreateCharacter} className="flex-row flex-wrap mt-sm" style={{ marginBottom: '0.75rem' }}>
<input
@@ -876,6 +883,8 @@ export function CampaignHomePage() {
</div>
)}
{isDM && resting && <RestModal campaignId={campaignId} characters={characters ?? []} onClose={() => setResting(false)} />}
{isDM && opened && (
<EntryDetail
campaignId={campaignId}
+48 -3
View File
@@ -36,6 +36,8 @@ import { JumpNav } from '../components/JumpNav';
import { useRememberCampaign } from '../lib/lastCampaign';
import { HpBar } from '../components/HpBar';
import { DeathSaves } from '../components/DeathSaves';
import { SpellSlotTracker } from '../components/SpellSlots';
import { LevelUpModal } from '../components/LevelUpModal';
import { GearInForce } from '../components/CharacterPanel';
import { effectsSummary } from '../lib/gear';
import { InfoTip } from '../components/InfoTip';
@@ -280,6 +282,7 @@ export function CharacterSheetPage() {
const [pickedSpellId, setPickedSpellId] = useState('');
const [copyTargetId, setCopyTargetId] = useState('');
const [formError, setFormError] = useState<string | null>(null);
const [levellingUp, setLevellingUp] = useState(false);
const weaponsPage = usePagination(character?.weapons, 8);
const spellsPage = usePagination(character?.spells, 8);
@@ -485,6 +488,10 @@ export function CharacterSheetPage() {
isDM={isDM}
onError={(err) => setFormError(extractErrorMessage(err))}
/>
<p className="subtitle mt-sm" style={{ marginBottom: 0 }}>
Hit Dice: <strong>{sheet.hitDice.remaining}</strong> of {sheet.hitDice.count} left (d{sheet.hitDice.size}{' '}
{fmtMod(sheet.abilities.CON.modifier)} each) <InfoTip term="HIT_DICE_LEFT" />
</p>
{/* HP is the DM's to change; a player reads it. */}
{isDM && (
@@ -534,7 +541,8 @@ export function CharacterSheetPage() {
{isDM && (
<div className="flex-row mt-sm flex-wrap">
<label className="flex-row gap-sm">
{/* Typing a level sets it outright; the button walks the checklist, one level at a time. */}
<label className="flex-row gap-sm" title="Set the level by hand. A higher level still adds the class's new special abilities; use Level Up for the full checklist.">
Level
<NumberInput
key={`level:${character.level}`}
@@ -543,7 +551,30 @@ export function CharacterSheetPage() {
keepValue
defaultValue={character.level}
style={{ width: 60 }}
onBlur={(e) => patchCharacter.mutate({ level: Number(e.target.value) })}
onBlur={(e) => Number(e.target.value) !== character.level && patchCharacter.mutate({ level: Number(e.target.value) })}
/>
</label>
<button
className="btn btn-primary"
onClick={() => setLevellingUp(true)}
disabled={character.level >= 20}
title="Go up one level with the levelling-up checklist: HP, new special abilities, spells and the free weapon upgrade"
>
⬆ Level Up…
</button>
<label className="flex-row gap-sm" title="Hit Dice this character still has to spend on a short rest. The Rest button on the campaign page keeps count for you.">
Hit Dice left
<NumberInput
key={`hitdice:${sheet.hitDice.remaining}:${sheet.hitDice.count}`}
min={0}
max={sheet.hitDice.count}
keepValue
defaultValue={sheet.hitDice.remaining}
style={{ width: 60 }}
onBlur={(e) => {
const left = Number(e.target.value);
if (left !== sheet.hitDice.remaining) patchCharacter.mutate({ hitDiceUsed: sheet.hitDice.count - left });
}}
/>
</label>
<button className="btn btn-ghost" onClick={recomputeMaxHp} title="Recompute max HP from the current level and Constitution">
@@ -633,7 +664,7 @@ export function CharacterSheetPage() {
</div>
{sheet.spellcasting && (
<div className="card mt-md">
<div data-jump="Spellcasting" className="card mt-md">
<div className="card-title">
Spellcasting ({ABILITY_LABELS[sheet.spellcasting.ability]}) <InfoTip term="SPELL_SAVE_DC" />
</div>
@@ -641,6 +672,18 @@ export function CharacterSheetPage() {
Save DC <strong>{sheet.spellcasting.saveDC}</strong> · Attack Bonus{' '}
<strong>{fmtMod(sheet.spellcasting.attackBonus)}</strong> <InfoTip term="SPELL_ATTACK_BONUS" />
</p>
{sheet.spellSlots ? (
<SpellSlotTracker
characterId={characterId}
name={character.name}
slots={sheet.spellSlots}
canUse={canEdit}
isDM={isDM}
onError={(err) => setFormError(extractErrorMessage(err))}
/>
) : (
<p className="subtitle" style={{ margin: '0.4rem 0 0' }}>No spell slots yet: they come at level 2.</p>
)}
</div>
)}
@@ -1062,6 +1105,8 @@ export function CharacterSheetPage() {
<Pagination page={notesPage.page} pageCount={notesPage.pageCount} onPrev={notesPage.prevPage} onNext={notesPage.nextPage} onJump={notesPage.setPage} />
</div>
{isDM && levellingUp && <LevelUpModal character={character} campaignSpells={campaignSpells ?? []} onClose={() => setLevellingUp(false)} />}
</div>
);
}
+23 -4
View File
@@ -1,3 +1,4 @@
import { useState } from 'react';
import { Link, useParams } from 'react-router-dom';
import { useAuth } from '../auth/useAuth';
import { useCampaign, useCampaignCharacters } from '../api/queries';
@@ -6,7 +7,8 @@ import { Spinner, ErrorBanner } from '../components/Spinner';
import { Pagination } from '../components/Paginated';
import { usePagination } from '../hooks/usePagination';
import { InfoTip } from '../components/InfoTip';
import { CLASS_LABELS, SPECIES_LABELS, formatPurse } from '../lib/format';
import { CLASS_LABELS, SPECIES_LABELS, formatPurse, slotsSummary } from '../lib/format';
import { RestModal } from '../components/RestModal';
import { HpBar } from '../components/HpBar';
import { LifeBadge } from '../components/DeathSaves';
import { speciesIcon } from '../lib/speciesIcons';
@@ -23,6 +25,7 @@ export function PartyOverviewPage() {
const { data, isLoading: campaignLoading, error: campaignError } = useCampaign(campaignId);
const { data: characters, isLoading: charsLoading, error: charsError } = useCampaignCharacters(campaignId);
const { pageItems, page, pageCount, prevPage, nextPage, setPage } = usePagination(characters, 12);
const [resting, setResting] = useState(false);
if (campaignLoading || charsLoading) return <Spinner label="Gathering the party…" />;
if (campaignError || charsError || !data) return <ErrorBanner message="Could not load the party overview." />;
@@ -36,9 +39,16 @@ export function PartyOverviewPage() {
<h1>Party Overview</h1>
<p className="subtitle">{isDM ? 'Every character in this campaign, at a glance.' : 'Your party.'}</p>
</div>
<Link to={`/campaigns/${campaignId}`} className="btn btn-ghost">
← Back to Campaign
</Link>
<div className="flex-row">
{isDM && characters?.some((c) => c.buildStage === 'COMPLETE') && (
<button className="btn" onClick={() => setResting(true)} title="A short or long rest for any of the party: Hit Dice, HP and spell slots">
🛏 Rest…
</button>
)}
<Link to={`/campaigns/${campaignId}`} className="btn btn-ghost">
← Back to Campaign
</Link>
</div>
</div>
{characters?.length === 0 && <div className="empty-state">No characters yet.</div>}
@@ -58,6 +68,12 @@ export function PartyOverviewPage() {
<th>
AC <InfoTip term="AC" />
</th>
<th>
Hit Dice <InfoTip term="HIT_DICE_LEFT" />
</th>
<th>
Spell slots <InfoTip term="SPELL_SLOTS" />
</th>
<th>Coins</th>
<th>Location</th>
</tr>
@@ -92,6 +108,8 @@ export function PartyOverviewPage() {
)}
</td>
<td data-label="AC">{c.armorClass ?? '—'}</td>
<td data-label="Hit Dice" className="mono">{c.hitDice ? `${c.hitDice.remaining}/${c.hitDice.count} d${c.hitDice.size}` : '—'}</td>
<td data-label="Spell slots" className="mono">{slotsSummary(c.spellSlots) || '—'}</td>
<td data-label="Coins" className="mono">{c.gold == null ? '—' : formatPurse(c)}</td>
<td data-label="Location">{c.currentLocationName ? `📍 ${c.currentLocationName}` : '—'}</td>
</tr>
@@ -102,6 +120,7 @@ export function PartyOverviewPage() {
</div>
)}
<Pagination page={page} pageCount={pageCount} onPrev={prevPage} onNext={nextPage} onJump={setPage} />
{isDM && resting && <RestModal campaignId={campaignId} characters={characters ?? []} onClose={() => setResting(false)} />}
</div>
);
}