- 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>
39 lines
1.8 KiB
JavaScript
39 lines
1.8 KiB
JavaScript
// Rules the app knows, for any signed-in user: nothing here belongs to a
|
|
// campaign or a character.
|
|
const express = require('express');
|
|
const { z } = require('zod');
|
|
const { requireAuth } = require('../middleware/auth');
|
|
const { CLASSES } = require('../game/data/classes');
|
|
const { findSubclass } = require('../game/data/subclasses');
|
|
const { progression } = require('../game/levelUp');
|
|
const { MULTICLASS_PREREQS, PREREQ_SCORE, prereqText } = require('../game/multiclass');
|
|
const { MULTICLASS_PATHS } = require('../game/data/multiclassPaths');
|
|
|
|
const router = express.Router();
|
|
|
|
router.use(requireAuth);
|
|
|
|
// GET /reference/progression?class=FIGHTER&subclass=CHAMPION — what each
|
|
// level from 1 to 20 gives a class, with the subclass's lines when one is
|
|
// named. Shown as the progression timeline in the builder, on the sheet and
|
|
// when levelling up.
|
|
router.get('/progression', (req, res) => {
|
|
const parsed = z.object({ class: z.enum(Object.keys(CLASSES)), subclass: z.string().optional() }).safeParse(req.query);
|
|
if (!parsed.success) return res.status(400).json({ error: parsed.error.flatten() });
|
|
const { class: characterClass, subclass } = parsed.data;
|
|
if (subclass && !findSubclass(characterClass, subclass)) return res.status(400).json({ error: 'That is not a subclass of this class.' });
|
|
res.json({ characterClass, subclass: subclass || null, levels: progression(characterClass, subclass) });
|
|
});
|
|
|
|
// GET /reference/multiclass — what each class asks of the ability scores to
|
|
// multiclass into or out of it, and the suggested routes (data/multiclassPaths.js).
|
|
router.get('/multiclass', (req, res) => {
|
|
res.json({
|
|
prereqScore: PREREQ_SCORE,
|
|
prereqs: Object.fromEntries(Object.keys(CLASSES).map((cls) => [cls, { alternatives: MULTICLASS_PREREQS[cls], text: prereqText(cls) }])),
|
|
paths: MULTICLASS_PATHS,
|
|
});
|
|
});
|
|
|
|
module.exports = router;
|