V1.0.1: Aldenfell campaign seed, content library, party overview

- Seed now resets the database and seeds the Aldenfell campaign from the
  campaign book: admin DM user, default weapons, locations, bestiary,
  pre-built encounters, and DM/shared notes
- Default weapon/spell/monster library, character profile fields,
  locations and dice mode (new migration)
- Party overview page, pagination, info tips, build preview calc
- Remove stale demo-login hint; notes preserve line breaks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 10:24:48 +02:00
co-authored by Claude Opus 5.5
parent 9b29dc8253
commit 94067f1268
34 changed files with 3158 additions and 391 deletions
+33 -2
View File
@@ -1,7 +1,8 @@
import type { Ability, CharacterClass } from '../api/types';
// Mirrors backend/src/game/data/classes.js spellcastingAbility column — used
// only to decide whether the builder's equipment step offers spell picks.
// Mirrors backend/src/game/data/classes.js — used only to preview the
// running math live during the builder. The server recomputes authoritatively
// at finalize, so this duplication is display-only and never gameplay-deciding.
export const CLASS_SPELLCASTING_ABILITY: Record<CharacterClass, Ability | null> = {
FIGHTER: null,
BARBARIAN: null,
@@ -16,3 +17,33 @@ export const CLASS_SPELLCASTING_ABILITY: Record<CharacterClass, Ability | null>
DRUID: 'WIS',
MONK: null,
};
export const CLASS_HIT_DIE: Record<CharacterClass, number> = {
FIGHTER: 10,
BARBARIAN: 12,
ROGUE: 8,
RANGER: 10,
WIZARD: 6,
SORCERER: 6,
CLERIC: 8,
PALADIN: 10,
BARD: 8,
WARLOCK: 8,
DRUID: 8,
MONK: 8,
};
export const CLASS_SAVE_PROFICIENCIES: Record<CharacterClass, Ability[]> = {
FIGHTER: ['STR', 'CON'],
BARBARIAN: ['STR', 'CON'],
ROGUE: ['DEX', 'INT'],
RANGER: ['STR', 'DEX'],
WIZARD: ['INT', 'WIS'],
SORCERER: ['CON', 'CHA'],
CLERIC: ['WIS', 'CHA'],
PALADIN: ['WIS', 'CHA'],
BARD: ['DEX', 'CHA'],
WARLOCK: ['WIS', 'CHA'],
DRUID: ['INT', 'WIS'],
MONK: ['STR', 'DEX'],
};
+10
View File
@@ -60,6 +60,16 @@ export function fmtMod(mod: number): string {
return mod >= 0 ? `+${mod}` : `${mod}`;
}
// Healthy / bloodied (<=50%) / critical (<=25%) — matches .hp-bar-fill's
// modifier classes in index.css.
export function hpBarClass(current: number, max: number): string {
if (max <= 0) return 'hp-bar-fill';
const pct = current / max;
if (pct <= 0.25) return 'hp-bar-fill hp-critical';
if (pct <= 0.5) return 'hp-bar-fill hp-bloodied';
return 'hp-bar-fill';
}
export function extractErrorMessage(err: unknown): string {
const anyErr = err as { response?: { data?: { error?: unknown } } };
const apiError = anyErr?.response?.data?.error;
+64
View File
@@ -0,0 +1,64 @@
import type { Ability } from '../api/types';
// Mirrors the pure formulas in backend/src/game/calculations.js — used only
// to render a live "what does this change" preview while building a
// character. Display-only: the server recomputes authoritatively at
// finalize, so this duplication is never gameplay-deciding. Keep in sync by
// hand if the backend formulas change.
export function abilityModifier(score: number): number {
return Math.floor((score - 10) / 2);
}
export function proficiencyBonus(level: number): number {
return 2 + Math.floor((level - 1) / 4);
}
export function armorClass(dexMod: number, armorBonus = 0): number {
return 10 + dexMod + armorBonus;
}
// Level 1 always uses the maximum possible Hit Die roll; every level after
// uses the fixed "average" value (floor(hitDieSize / 2) + 1).
export function hpMax(level: number, hitDieSize: number, conMod: number): number {
const base = hitDieSize + conMod;
if (level <= 1) return base;
const perLevelAverage = Math.floor(hitDieSize / 2) + 1;
return base + (level - 1) * (perLevelAverage + conMod);
}
export function saveBonus(abilityMod: number, proficient: boolean, profBonus: number): number {
return abilityMod + (proficient ? profBonus : 0);
}
export function skillBonus(abilityMod: number, proficient: boolean, profBonus: number, expertise = false): number {
if (!proficient) return abilityMod;
return abilityMod + profBonus * (expertise ? 2 : 1);
}
export function passivePerception(perceptionSkillBonus: number): number {
return 10 + perceptionSkillBonus;
}
export function spellSaveDC(profBonus: number, spellAbilityMod: number): number {
return 8 + profBonus + spellAbilityMod;
}
export function spellAttackBonus(profBonus: number, spellAbilityMod: number): number {
return profBonus + spellAbilityMod;
}
export function fmtMod(n: number): string {
return n >= 0 ? `+${n}` : `${n}`;
}
export interface PreviewAbilities {
STR: number;
DEX: number;
CON: number;
INT: number;
WIS: number;
CHA: number;
}
export const ABILITY_ORDER: Ability[] = ['STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA'];
+19
View File
@@ -0,0 +1,19 @@
import type { Species } from '../api/types';
// Quick visual identification in lists/tables — purely decorative.
export const SPECIES_ICONS: Record<Species, string> = {
HUMAN: '🙂',
HALF_ELF: '🧝',
ELF: '🧝‍♀️',
GNOME: '🍄',
DWARF: '⛏️',
HALFLING: '🌾',
DRAGONBORN: '🐉',
TIEFLING: '😈',
HALF_ORC: '🪓',
ORC: '👹',
};
export function speciesIcon(species: Species | null): string {
return species ? SPECIES_ICONS[species] || '❓' : '❓';
}