Files
the-sunken-reach/frontend/src/components/MulticlassRoutes.tsx
T
joshuaandClaude Opus 5.5 86ef106969 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>
2026-10-11 16:14:57 +02:00

63 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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>
);
}