V1.22.0: campaign settings for dice, scores, multiclassing, auto-rolls, XP and crits

- Settings grouped into Characters, Dice & rolls, Combat and Progression
- Dice: digital, physical or both; a campaign's own choice applies to every character
- Ability scores by 4d6, the standard array or point buy (27 points, 8 to 15)
- Track XP can be turned off for milestone levelling: XP is hidden and not awarded
- New settings saved ahead of their features: multiclassing, auto-rolled monster
  and NPC attacks, roll visibility, hidden monster rolls, HP on level up, crit rule
- docs/CAMPAIGN_SETTINGS.md lists every setting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 15:12:05 +02:00
co-authored by Claude Opus 5.5
parent 57fba68a48
commit e7b6e0065a
24 changed files with 697 additions and 96 deletions
+8 -2
View File
@@ -17,8 +17,10 @@ router.use(requireAuth);
async function requireEncounterAccess(req, res, next) {
try {
const encounter = await prisma.encounter.findUnique({ where: { id: req.params.id } });
if (!encounter) return res.status(404).json({ error: 'Encounter not found' });
const found = await prisma.encounter.findUnique({ where: { id: req.params.id }, include: { campaign: true } });
if (!found) return res.status(404).json({ error: 'Encounter not found' });
// The campaign rides along for its settings (req.campaign), not on the encounter.
const { campaign, ...encounter } = found;
const membership = await loadCampaignMembership(req.user.id, encounter.campaignId);
if (!membership) return res.status(403).json({ error: 'Not a member of this campaign' });
@@ -35,6 +37,7 @@ async function requireEncounterAccess(req, res, next) {
}
req.encounter = encounter;
req.campaign = campaign;
req.membership = membership;
req.isDM = isDM;
return next();
@@ -793,6 +796,9 @@ router.post('/:id/award-xp', requireEncounterAccess, requireDM, async (req, res,
try {
const parsed = awardXpSchema.safeParse(req.body || {});
if (!parsed.success) return res.status(400).json({ error: parsed.error.flatten() });
if (!req.campaign.trackXp) {
return res.status(400).json({ error: 'This campaign does not keep experience points.' });
}
if (req.encounter.xpAwarded != null) {
return res.status(400).json({ error: `XP has already been awarded for this encounter (${req.encounter.xpAwarded}). Change a character's XP on their sheet.` });
}