V1.24.0: multiclassing, by each class's own level

- With the campaign setting on, the level-up checklist asks which class gains
  the level; a new class needs both classes' ability requirements (2014 rules)
- HP, Hit Dice, features, Boons, subclasses and counters go by each class's
  own level; spell slots add up to a caster level, pact slots apart
- A first level in a new class writes its level-1 gifts and what it teaches
- Eldritch Knight and Arcane Trickster cast from level 3 with real slots
- The sheet shows each class's road to 20 and suggested multiclass routes
  (Hexadin, Sorlock, fighter dip...) with the character's progress and scores

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 16:14:57 +02:00
co-authored by Claude Opus 5.5
parent 18d9e7301c
commit 86ef106969
27 changed files with 1098 additions and 78 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "frontend",
"private": true,
"version": "1.23.0",
"version": "1.24.0",
"type": "module",
"scripts": {
"dev": "vite",
+17 -4
View File
@@ -18,6 +18,7 @@ import type {
Item,
LevelUpPlan,
Location,
MulticlassReference,
Monster,
Note,
Npc,
@@ -252,12 +253,14 @@ export function useCharacterState(characterId: string) {
}
// What a character's next level brings. DM only.
export function useLevelUpPlan(characterId: string, enabled: boolean) {
// `toClass`: the plan for a level in that class (multiclassing); the first class when null.
export function useLevelUpPlan(characterId: string, enabled: boolean, toClass: CharacterClass | null = null) {
return useQuery({
queryKey: ['character', characterId, 'level-up'],
queryKey: ['character', characterId, 'level-up', toClass],
enabled,
gcTime: 0, // never open on the plan for a level the character has already reached
queryFn: async () => (await apiClient.get<{ plan: LevelUpPlan }>(`/characters/${characterId}/level-up`)).data.plan,
queryFn: async () =>
(await apiClient.get<{ plan: LevelUpPlan }>(`/characters/${characterId}/level-up`, { params: toClass ? { class: toClass } : {} })).data.plan,
});
}
@@ -265,7 +268,7 @@ export function useLevelUpPlan(characterId: string, enabled: boolean) {
export function useLevelUp(characterId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (data: { subclass?: string; boon?: string; weaponId?: string | null; spellIds?: string[] }) =>
mutationFn: async (data: { characterClass?: CharacterClass; subclass?: string; boon?: string; weaponId?: string | null; spellIds?: string[] }) =>
(await apiClient.post<{ character: CharacterDetail }>(`/characters/${characterId}/level-up`, data)).data.character,
onSuccess: (character) => {
invalidateCharacter(qc, characterId);
@@ -362,6 +365,16 @@ export function useBuildOptions() {
});
}
// Multiclassing requirements and the suggested routes.
export function useMulticlassReference(enabled: boolean) {
return useQuery({
queryKey: ['multiclass-reference'],
enabled,
staleTime: Infinity,
queryFn: async () => (await apiClient.get<MulticlassReference>('/reference/multiclass')).data,
});
}
// What each level from 1 to 20 gives a class, with a subclass's lines when one is given.
export function useProgression(characterClass: CharacterClass | null | undefined, subclass?: string | null) {
return useQuery({
+40 -2
View File
@@ -132,6 +132,21 @@ export interface SubclassSummary {
replaces: string | null;
}
// What each class asks of the scores to multiclass, and the suggested routes
// (GET /reference/multiclass). An alternative is a list of abilities that must
// all be at least prereqScore.
export interface MulticlassReference {
prereqScore: number;
prereqs: Record<CharacterClass, { alternatives: Ability[][]; text: string }>;
paths: {
key: string;
name: string;
from: CharacterClass | null;
steps: { class: CharacterClass; toLevel: number; subclass?: string }[];
why: string;
}[];
}
// One level of a class's road from 1 to 20 (GET /reference/progression).
export interface ProgressionLevel {
level: number;
@@ -216,7 +231,7 @@ export interface SpellSlotLevel {
// A character's spell slots, from class and level. A warlock's (PACT) are all
// of one slot level and come back on a short rest; everyone else's on a long one.
export interface SpellSlots {
kind: 'FULL' | 'HALF' | 'PACT';
kind: 'FULL' | 'HALF' | 'THIRD' | 'PACT';
restoresOn: 'SHORT' | 'LONG';
levels: SpellSlotLevel[];
}
@@ -227,6 +242,16 @@ export interface HitDice {
count: number;
used: number;
remaining: number;
// A multiclassed character's dice by class (each class's own size).
pools?: { characterClass: CharacterClass; size: number; count: number }[];
}
// A class a character has levels in. One entry unless they have multiclassed.
export interface ClassLevel {
characterClass: CharacterClass;
level: number;
subclass?: string | null;
subclassName: string | null;
}
// A class counter (Rage, Ki, Channel Divinity...): how many uses there are,
@@ -278,6 +303,7 @@ export interface CharacterSummary extends CharacterCondition {
characterClass: CharacterClass | null;
subclassName: string | null;
level: number;
classes: ClassLevel[];
xp: number;
xpProgress: XpProgress;
buildStage: BuildStage;
@@ -350,6 +376,10 @@ export interface CharacterSheet {
passiveInvestigation: number;
passiveInsight: number;
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
// A multiclassed caster's DC and attack for each class that casts.
spellcastingByClass: { characterClass: CharacterClass; ability: Ability; saveDC: number; attackBonus: number }[];
// A multiclassed warlock's pact slots, apart from the other slots; null otherwise.
pactSlots: { count: number; slotLevel: number } | null;
spellSlots: SpellSlots | null; // null for a character with no spell slots
resources: ClassResource[]; // the class counters, with how many of each are left
gear: ActiveGear;
@@ -478,6 +508,7 @@ export interface CharacterDetail extends CharacterCondition {
// The 2024 subclass that updates the one followed, if there is one.
subclassUpgrade: SubclassSummary | null;
level: number;
classes: ClassLevel[];
xp: number;
xpProgress: XpProgress;
motivation: string | null;
@@ -883,6 +914,13 @@ export interface BoonOption {
export interface LevelUpPlan {
fromLevel: number;
toLevel: number;
// The class taking the level, its own level after it, and whether it is the
// character's first level in that class (multiclassing).
characterClass: CharacterClass;
classLevel: number;
joining: boolean;
// With multiclassing on: every class the level could go to, and why not.
classChoice: { options: { characterClass: CharacterClass; level: number; eligible: boolean; problems: string[] }[] } | null;
maxHp: { from: number; to: number };
// Set when a subclass has to be picked on the way to this level: the level
// the class chooses at, and each option with everything it would write.
@@ -898,7 +936,7 @@ export interface LevelUpPlan {
spellSlots: SpellSlots | null; // the slots at the new level
// Held weapons that can take the free upgrade of one level.
weapons: { weaponId: string; name: string; equipped: boolean; level: number; damageDice: string; nextDamageDice: string }[];
beyondTables: boolean; // past level 10, where the class tables stop
beyondTables: boolean; // past level 20, where the class tables stop
}
export type RestType = 'SHORT' | 'LONG';
+46 -6
View File
@@ -1,9 +1,9 @@
import { useState, type ReactNode } from 'react';
import { useLevelUp, useLevelUpPlan } from '../api/queries';
import { extractErrorMessage, slotLevelLabel, slotsSummary, spellLevelLabel } from '../lib/format';
import { CLASS_LABELS, classLabel, extractErrorMessage, slotLevelLabel, slotsSummary, spellLevelLabel } from '../lib/format';
import { Modal } from './Modal';
import { Spinner, ErrorBanner } from './Spinner';
import type { CharacterDetail, LevelUpPlan, Spell } from '../api/types';
import type { CharacterClass, CharacterDetail, LevelUpPlan, Spell } from '../api/types';
// One numbered step of the checklist.
function Step({ n, title, children }: { n: number; title: string; children: ReactNode }) {
@@ -29,7 +29,9 @@ function allowance(spells: NonNullable<LevelUpPlan['spells']>): string {
// where the level calls for one), new spells and fresh slots, and the free weapon upgrade. The
// site does every step; the DM makes the choices and says yes.
export function LevelUpModal({ character, campaignSpells, onClose }: { character: CharacterDetail; campaignSpells: Spell[]; onClose: () => void }) {
const { data: plan, isLoading, error: planError } = useLevelUpPlan(character.id, true);
// The class taking the level: the first one, unless another is picked (multiclassing).
const [toClass, setToClass] = useState<CharacterClass | null>(null);
const { data: plan, isLoading, error: planError } = useLevelUpPlan(character.id, true, toClass);
const levelUp = useLevelUp(character.id);
const [subclass, setSubclass] = useState('');
const [boon, setBoon] = useState('');
@@ -66,7 +68,9 @@ export function LevelUpModal({ character, campaignSpells, onClose }: { character
async function handleLevelUp() {
setError(null);
try {
await levelUp.mutateAsync({ subclass: plan!.subclass ? subclass : undefined, boon: plan!.boon ? boon : undefined, weaponId: weaponId || null, spellIds: [...spellIds] });
await levelUp.mutateAsync({
characterClass: plan!.characterClass,
subclass: plan!.subclass ? subclass : undefined, boon: plan!.boon ? boon : undefined, weaponId: weaponId || null, spellIds: [...spellIds] });
onClose();
} catch (err) {
setError(extractErrorMessage(err));
@@ -78,8 +82,44 @@ export function LevelUpModal({ character, campaignSpells, onClose }: { character
{error && <ErrorBanner message={error} />}
<Step n={1} title="Level">
{plan.classChoice && (
<div className="mb-2">
<label className="flex-row flex-wrap gap-sm">
Which class gains this level?
<select
value={plan.characterClass}
onChange={(e) => {
setToClass(e.target.value as CharacterClass);
setSubclass('');
setBoon('');
setSpellIds(new Set());
}}
>
{plan.classChoice.options.map((o) => (
<option key={o.characterClass} value={o.characterClass} disabled={!o.eligible} title={o.problems.join(' ')}>
{CLASS_LABELS[o.characterClass]}
{o.level > 0 ? ` (level ${o.level} → ${o.level + 1})` : o.eligible ? ' (new class)' : ' (requirements not met)'}
</option>
))}
</select>
</label>
{plan.joining && (
<p className="combatant-sub">
Multiclassing into {CLASS_LABELS[plan.characterClass]}: it starts at its own level 1, with what that class grants at level 1 (not its saves or
skills) and what it teaches a newcomer.
</p>
)}
</div>
)}
<p>
Level <strong>{plan.fromLevel}</strong> → <strong>{plan.toLevel}</strong>. Proficiency bonus, saves, skills and spell DC follow by themselves.
Level <strong>{plan.fromLevel}</strong> → <strong>{plan.toLevel}</strong>
{(character.classes.length > 1 || plan.characterClass !== character.characterClass) && (
<span className="combatant-sub">
{' '}
· {CLASS_LABELS[plan.characterClass]} {plan.classLevel - 1} → {plan.classLevel} (now {classLabel(character.characterClass, character.subclassName, character.classes)})
</span>
)}
. Proficiency bonus, saves, skills and spell DC follow by themselves.
</p>
</Step>
@@ -120,7 +160,7 @@ export function LevelUpModal({ character, campaignSpells, onClose }: { character
)}
{plan.features.length === 0 && !plan.boon && !plan.subclass && (
<p className="combatant-sub">
{plan.beyondTables ? 'The class tables stop at level 10. Add anything new to the special abilities by hand.' : 'No new feature at this level.'}
{plan.beyondTables ? 'The class tables stop at level 20. Add anything new to the special abilities by hand.' : 'No new feature at this level.'}
</p>
)}
{plan.features.map((feature) => (
@@ -0,0 +1,62 @@
import { useMulticlassReference } from '../api/queries';
import { CLASS_LABELS } from '../lib/format';
import { Spinner } from './Spinner';
import type { Ability, CharacterClass, ClassLevel, MulticlassReference } from '../api/types';
// Whether final scores meet a class's multiclassing requirement.
function meets(reference: MulticlassReference, characterClass: CharacterClass, scores: Record<Ability, number>): boolean {
return reference.prereqs[characterClass].alternatives.some((all) => all.every((a) => scores[a] >= reference.prereqScore));
}
// Suggested multiclass routes from where a character stands: each route's
// steps, how far along the character is, and whether their scores meet every
// class the route takes them through (multiclassing needs the requirement of
// the class joined and of each class left).
export function MulticlassRoutes({ classes, scores }: { classes: ClassLevel[]; scores: Record<Ability, number> }) {
const { data: reference, isLoading } = useMulticlassReference(true);
if (isLoading || !reference) return <Spinner label="Reading the routes…" />;
const levelIn = (cls: CharacterClass) => classes.find((c) => c.characterClass === cls)?.level ?? 0;
const have = new Set(classes.map((c) => c.characterClass));
const paths = reference.paths.filter((p) => !p.from || have.has(p.from));
const yours = classes.map((c) => c.characterClass);
return (
<div>
<p className="combatant-sub" style={{ marginTop: 0 }}>
Multiclassing is on. A level can go to another class when {classes.length > 1 ? 'every class you have' : `your ${CLASS_LABELS[yours[0]]}`} and the new class’s
requirements are met: {yours.map((c) => `${CLASS_LABELS[c]} needs ${reference.prereqs[c].text}`).join('; ')}.
</p>
<div className="choice-grid">
{paths.map((path) => {
const classesOnRoute = [...new Set(path.steps.map((s) => s.class))];
const blocked = classesOnRoute.filter((cls) => !meets(reference, cls, scores));
return (
<div key={path.key} className="choice-card" style={{ cursor: 'default' }}>
<span className="choice-card-title">
{path.name}
{blocked.length === 0 ? <span className="badge badge-friendly">Open to you</span> : <span className="badge badge-hostile">Needs scores</span>}
</span>
<span className="choice-card-blurb">{path.why}</span>
<ol style={{ margin: 0, paddingLeft: '1.2rem' }}>
{path.steps.map((step, i) => {
const done = levelIn(step.class) >= step.toLevel;
return (
<li key={i} style={done ? { opacity: 0.6 } : undefined}>
{done ? '✓ ' : ''}
{CLASS_LABELS[step.class]} to level {step.toLevel}
{step.subclass ? ` (${step.subclass.toLowerCase().replace(/_/g, ' ')})` : ''}
</li>
);
})}
</ol>
{blocked.length > 0 && (
<span className="choice-card-facts">{blocked.map((cls) => `${CLASS_LABELS[cls]}: ${reference.prereqs[cls].text}`).join(' · ')}</span>
)}
</div>
);
})}
</div>
</div>
);
}
+6 -2
View File
@@ -97,9 +97,13 @@ export function xpLabel(xp: number, progress: { nextLevelAt: number | null }): s
return progress.nextLevelAt == null ? `${xp.toLocaleString()} XP` : `${xp.toLocaleString()} / ${progress.nextLevelAt.toLocaleString()} XP`;
}
// "Fighter" or, with a subclass chosen, "Fighter (Champion)".
export function classLabel(characterClass: string | null, subclassName?: string | null): string {
// "Fighter" or, with a subclass chosen, "Fighter (Champion)". A multiclassed
// character (`classes` with more than one) reads "Fighter 3 (Champion) / Rogue 2".
export function classLabel(characterClass: string | null, subclassName?: string | null, classes?: { characterClass: string; level: number; subclassName: string | null }[]): string {
if (!characterClass) return '';
if (classes && classes.length > 1) {
return classes.map((c) => `${CLASS_LABELS[c.characterClass] ?? c.characterClass} ${c.level}${c.subclassName ? ` (${c.subclassName})` : ''}`).join(' / ');
}
const label = CLASS_LABELS[characterClass] ?? characterClass;
return subclassName ? `${label} (${subclassName})` : label;
}
+44 -2
View File
@@ -42,6 +42,7 @@ import { Rollable } from '../components/Rollable';
import { withBonus } from '../lib/diceRoller';
import { LevelUpModal } from '../components/LevelUpModal';
import { ProgressionTimeline } from '../components/ProgressionTimeline';
import { MulticlassRoutes } from '../components/MulticlassRoutes';
import { GearInForce } from '../components/CharacterPanel';
import { effectsSummary } from '../lib/gear';
import { InfoTip } from '../components/InfoTip';
@@ -65,6 +66,7 @@ import {
formatPurse,
purseWorthInGold,
spellLevelLabel,
slotLevelLabel,
} from '../lib/format';
import { speciesIcon } from '../lib/speciesIcons';
import { hpMax as previewHpMax, scaledDamageDice, MAX_GEAR_LEVEL } from '../lib/previewCalc';
@@ -432,7 +434,7 @@ export function CharacterSheetPage() {
<span aria-hidden="true">{speciesIcon(character.species)}</span> {character.name}
</h1>
<p className="subtitle">
{character.species && SPECIES_LABELS[character.species]} {classLabel(character.characterClass, character.subclassName)} · Level{' '}
{character.species && SPECIES_LABELS[character.species]} {classLabel(character.characterClass, character.subclassName, character.classes)} · Level{' '}
{character.level}
{trackXp && ` · ${xpLabel(character.xp, character.xpProgress)}`}
{trackXp && character.xpProgress.levelUpDue && (
@@ -746,6 +748,20 @@ export function CharacterSheetPage() {
</Rollable>{' '}
<InfoTip term="SPELL_ATTACK_BONUS" />
</p>
{sheet.spellcastingByClass.length > 1 && (
<p className="combatant-sub" style={{ margin: '0.2rem 0 0' }}>
By class:{' '}
{sheet.spellcastingByClass
.map((c) => `${CLASS_LABELS[c.characterClass]} (${ABILITY_LABELS[c.ability]}) DC ${c.saveDC}, ${fmtMod(c.attackBonus)}`)
.join(' · ')}
</p>
)}
{sheet.pactSlots && (
<p className="combatant-sub" style={{ margin: '0.2rem 0 0' }}>
Pact Magic: {sheet.pactSlots.count} slot{sheet.pactSlots.count === 1 ? '' : 's'} of {slotLevelLabel(sheet.pactSlots.slotLevel)} level, back on a short rest.
Keep count of these at the table; the tracker below is the other classes’ slots.
</p>
)}
{sheet.spellSlots ? (
<SpellSlotTracker
characterId={characterId}
@@ -1138,12 +1154,38 @@ export function CharacterSheetPage() {
)}
</div>
)}
{character.classes.length > 1 && (
<p className="section-label" style={{ margin: '0.5rem 0 0.3rem' }}>
{CLASS_LABELS[character.characterClass]} {character.classes[0].level}
{character.subclassName ? ` (${character.subclassName})` : ''}
</p>
)}
<ProgressionTimeline
characterClass={character.characterClass}
subclass={character.subclass}
subclassName={character.subclassName}
currentLevel={character.level}
currentLevel={character.classes[0]?.level ?? character.level}
/>
{character.classes.slice(1).map((c) => (
<div key={c.characterClass} className="mt-md">
<p className="section-label" style={{ margin: '0 0 0.3rem' }}>
{CLASS_LABELS[c.characterClass]} {c.level}
{c.subclassName ? ` (${c.subclassName})` : ''}
</p>
<ProgressionTimeline characterClass={c.characterClass} subclass={c.subclass} subclassName={c.subclassName} currentLevel={c.level} />
</div>
))}
{campaignData?.campaign.multiclassEnabled && (
<details className="mt-md">
<summary className="section-label" style={{ cursor: 'pointer' }}>
Multiclass routes from here
</summary>
<MulticlassRoutes
classes={character.classes}
scores={Object.fromEntries(Object.entries(sheet.abilities).map(([a, d]) => [a, d.final])) as Record<Ability, number>}
/>
</details>
)}
</div>
)}
+1 -1
View File
@@ -122,7 +122,7 @@ export function PartyOverviewPage() {
)}
</td>
<td data-label="Species">{c.species ? SPECIES_LABELS[c.species] : '—'}</td>
<td data-label="Class">{c.characterClass ? classLabel(c.characterClass, c.subclassName) : inProgress ? 'Building…' : '—'}</td>
<td data-label="Class">{c.characterClass ? classLabel(c.characterClass, c.subclassName, c.classes) : inProgress ? 'Building…' : '—'}</td>
<td data-label="Level">
{c.level}
{!inProgress && data?.campaign.trackXp && (