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
+141 -21
View File
@@ -15,12 +15,18 @@ import {
useCharacterNotes,
useCreateNote,
useCampaign,
useCampaignLocations,
} from '../api/queries';
import { useAuth } from '../auth/AuthContext';
import { useCampaignSocket } from '../hooks/useCampaignSocket';
import { Spinner, ErrorBanner } from '../components/Spinner';
import { QuickStatsFab } from '../components/QuickStatsDrawer';
import { ABILITY_LABELS, CLASS_LABELS, SKILL_LABELS, SPECIES_LABELS, fmtMod, extractErrorMessage } from '../lib/format';
import { InfoTip } from '../components/InfoTip';
import { usePagination, Pagination } from '../components/Paginated';
import { ABILITY_LABELS, CLASS_LABELS, SKILL_LABELS, SPECIES_LABELS, fmtMod, hpBarClass, extractErrorMessage } from '../lib/format';
import { speciesIcon } from '../lib/speciesIcons';
import { hpMax as previewHpMax } from '../lib/previewCalc';
import { CLASS_HIT_DIE } from '../lib/classData';
import type { Ability } from '../api/types';
export function CharacterSheetPage() {
@@ -33,6 +39,7 @@ export function CharacterSheetPage() {
const { data: campaignData } = useCampaign(character?.campaignId);
const { data: campaignWeapons } = useCampaignWeapons(character?.campaignId);
const { data: campaignSpells } = useCampaignSpells(character?.campaignId);
const { data: locations } = useCampaignLocations(character?.campaignId);
const { data: notes } = useCharacterNotes(characterId);
const assignWeapon = useAssignWeapon(characterId);
@@ -51,6 +58,11 @@ export function CharacterSheetPage() {
const [pickedSpellId, setPickedSpellId] = useState('');
const [formError, setFormError] = useState<string | null>(null);
const weaponsPage = usePagination(character?.weapons, 8);
const spellsPage = usePagination(character?.spells, 8);
const itemsPage = usePagination(character?.inventoryItems, 8);
const notesPage = usePagination(notes, 6);
if (isLoading) return <Spinner label="Unfurling the character sheet…" />;
if (error || !character) return <ErrorBanner message="Could not load this character." />;
@@ -79,6 +91,14 @@ export function CharacterSheetPage() {
setHpDelta('');
}
function recomputeMaxHp() {
if (!character || !character.characterClass) return;
const hitDie = CLASS_HIT_DIE[character.characterClass];
const conMod = sheet.abilities.CON.modifier;
const newMax = previewHpMax(character.level, hitDie, conMod);
patchCharacter.mutate({ currentHp: newMax });
}
async function handleAddItem(e: FormEvent) {
e.preventDefault();
if (!newItemName.trim()) return;
@@ -120,11 +140,14 @@ export function CharacterSheetPage() {
<div>
<div className="page-header">
<div>
<h1>{character.name}</h1>
<h1>
<span aria-hidden="true">{speciesIcon(character.species)}</span> {character.name}
</h1>
<p className="subtitle">
{character.species && SPECIES_LABELS[character.species]} {character.characterClass && CLASS_LABELS[character.characterClass]} · Level{' '}
{character.level}
{character.motivation && ` · "${character.motivation}"`}
{character.currentLocation && ` · 📍 ${character.currentLocation.name}`}
</p>
</div>
<Link to={`/campaigns/${character.campaignId}`} className="btn btn-ghost">
@@ -136,36 +159,48 @@ export function CharacterSheetPage() {
<div className="grid grid-cols-3">
<div className="stat-block">
<span className="stat-label">HP</span>
<span className="stat-label">
HP <InfoTip term="HP" />
</span>
<span className="stat-value">
{character.currentHp}/{sheet.hp.max}
</span>
{character.tempHp > 0 && <span className="stat-sub">+{character.tempHp} temp</span>}
</div>
<div className="stat-block">
<span className="stat-label">AC</span>
<span className="stat-label">
AC <InfoTip term="AC" />
</span>
<span className="stat-value">{sheet.armorClass}</span>
</div>
<div className="stat-block">
<span className="stat-label">Initiative</span>
<span className="stat-label">
Initiative <InfoTip term="INITIATIVE" />
</span>
<span className="stat-value">{fmtMod(sheet.initiative)}</span>
</div>
<div className="stat-block">
<span className="stat-label">Speed</span>
<span className="stat-label">
Speed <InfoTip term="SPEED" />
</span>
<span className="stat-value">{sheet.speed}</span>
</div>
<div className="stat-block">
<span className="stat-label">Prof. Bonus</span>
<span className="stat-label">
Prof. Bonus <InfoTip term="PROFICIENCY_BONUS" />
</span>
<span className="stat-value">{fmtMod(sheet.proficiencyBonus)}</span>
</div>
<div className="stat-block">
<span className="stat-label">Passive Perception</span>
<span className="stat-label">
Passive Perception <InfoTip term="PASSIVE_PERCEPTION" />
</span>
<span className="stat-value">{sheet.passivePerception}</span>
</div>
</div>
<div className="hp-bar-track mt-sm">
<div className="hp-bar-fill" style={{ width: `${Math.max(0, Math.min(100, (character.currentHp / sheet.hp.max) * 100))}%` }} />
<div className={hpBarClass(character.currentHp, sheet.hp.max)} style={{ width: `${Math.max(0, Math.min(100, (character.currentHp / sheet.hp.max) * 100))}%` }} />
</div>
{canEdit && (
@@ -184,7 +219,7 @@ export function CharacterSheetPage() {
+ Heal
</button>
<label className="flex-row gap-sm" style={{ marginLeft: '1rem' }}>
Temp HP
Temp HP <InfoTip term="TEMP_HP" />
<input
type="number"
min={0}
@@ -194,7 +229,7 @@ export function CharacterSheetPage() {
/>
</label>
<label className="flex-row gap-sm">
Armor Bonus
Armor Bonus <InfoTip term="ARMOR_BONUS" />
<input
type="number"
min={0}
@@ -206,12 +241,50 @@ export function CharacterSheetPage() {
</div>
)}
{isDM && (
<div className="flex-row mt-sm flex-wrap">
<label className="flex-row gap-sm">
Level
<input
type="number"
min={1}
max={20}
defaultValue={character.level}
style={{ width: 60 }}
onBlur={(e) => patchCharacter.mutate({ level: Number(e.target.value) })}
/>
</label>
<button className="btn btn-ghost" onClick={recomputeMaxHp} title="Recompute max HP from the current level and Constitution">
Recompute Max HP <InfoTip term="HIT_DICE" />
</button>
<label className="flex-row gap-sm" style={{ marginLeft: '1rem' }}>
Location
<select
value={character.currentLocationId || ''}
onChange={(e) => patchCharacter.mutate({ currentLocationId: e.target.value || null })}
>
<option value="">— none —</option>
{locations?.map((loc) => (
<option key={loc.id} value={loc.id}>
{loc.name}
</option>
))}
</select>
</label>
</div>
)}
{!isDM && character.currentLocation && (
<p className="subtitle mt-sm">📍 Currently at: <strong>{character.currentLocation.name}</strong></p>
)}
<div className="card mt-md">
<div className="card-title">Ability Scores</div>
<div className="grid grid-cols-3">
{(Object.keys(sheet.abilities) as Ability[]).map((ability) => (
<div className="stat-block" key={ability}>
<span className="stat-label">{ABILITY_LABELS[ability]}</span>
<span className="stat-label">
{ABILITY_LABELS[ability]} <InfoTip term="ABILITY_MODIFIER" />
</span>
<span className="stat-value">{sheet.abilities[ability].final}</span>
<span className="stat-sub">{fmtMod(sheet.abilities[ability].modifier)}</span>
</div>
@@ -221,7 +294,9 @@ export function CharacterSheetPage() {
<div className="grid grid-cols-2 mt-md">
<div className="card">
<div className="card-title">Saving Throws</div>
<div className="card-title">
Saving Throws <InfoTip term="SAVING_THROW" />
</div>
{(Object.keys(sheet.saves) as Ability[]).map((ability) => (
<div key={ability} className="flex-between" style={{ padding: '0.3rem 0' }}>
<span>
@@ -232,7 +307,9 @@ export function CharacterSheetPage() {
))}
</div>
<div className="card">
<div className="card-title">Skills</div>
<div className="card-title">
Skills <InfoTip term="SKILL_BONUS" />
</div>
<div style={{ maxHeight: 320, overflowY: 'auto' }}>
{Object.entries(sheet.skills).map(([skill, detail]) => (
<div key={skill} className="flex-between" style={{ padding: '0.25rem 0' }}>
@@ -253,17 +330,21 @@ export function CharacterSheetPage() {
{sheet.spellcasting && (
<div className="card mt-md">
<div className="card-title">Spellcasting ({ABILITY_LABELS[sheet.spellcasting.ability]})</div>
<div className="card-title">
Spellcasting ({ABILITY_LABELS[sheet.spellcasting.ability]}) <InfoTip term="SPELL_SAVE_DC" />
</div>
<p style={{ margin: 0 }}>
Save DC <strong>{sheet.spellcasting.saveDC}</strong> · Attack Bonus{' '}
<strong>{fmtMod(sheet.spellcasting.attackBonus)}</strong>
<strong>{fmtMod(sheet.spellcasting.attackBonus)}</strong> <InfoTip term="SPELL_ATTACK_BONUS" />
</p>
</div>
)}
<div className="card mt-md">
<div className="card-title">Weapons</div>
{character.weapons.map((cw) => (
<div className="card-title">
Weapons <InfoTip term="ATTACK_BONUS" />
</div>
{weaponsPage.pageItems.map((cw) => (
<div key={cw.id} className="flex-between" style={{ padding: '0.4rem 0', borderBottom: '1px solid var(--border-soft)' }}>
<div>
<strong>{cw.weapon.name}</strong>
@@ -283,6 +364,7 @@ export function CharacterSheetPage() {
)}
</div>
))}
<Pagination page={weaponsPage.page} pageCount={weaponsPage.pageCount} onPrev={weaponsPage.prevPage} onNext={weaponsPage.nextPage} />
{canEdit && (
<div className="flex-row mt-sm flex-wrap">
<select value={pickedWeaponId} onChange={(e) => setPickedWeaponId(e.target.value)} style={{ flex: 1, minWidth: 160 }}>
@@ -305,7 +387,7 @@ export function CharacterSheetPage() {
{campaignSpells && campaignSpells.length > 0 && (
<div className="card mt-md">
<div className="card-title">Spells Known</div>
{character.spells.map((cs) => (
{spellsPage.pageItems.map((cs) => (
<div key={cs.id} className="flex-between" style={{ padding: '0.4rem 0', borderBottom: '1px solid var(--border-soft)' }}>
<div>
<strong>{cs.spell.name}</strong>
@@ -323,6 +405,7 @@ export function CharacterSheetPage() {
)}
</div>
))}
<Pagination page={spellsPage.page} pageCount={spellsPage.pageCount} onPrev={spellsPage.prevPage} onNext={spellsPage.nextPage} />
{canEdit && (
<div className="flex-row mt-sm flex-wrap">
<select value={pickedSpellId} onChange={(e) => setPickedSpellId(e.target.value)} style={{ flex: 1, minWidth: 160 }}>
@@ -345,7 +428,7 @@ export function CharacterSheetPage() {
<div className="card mt-md">
<div className="card-title">Inventory</div>
{character.inventoryItems.map((item) => (
{itemsPage.pageItems.map((item) => (
<div key={item.id} className="flex-between" style={{ padding: '0.4rem 0', borderBottom: '1px solid var(--border-soft)' }}>
<div>
<strong>{item.name}</strong>
@@ -368,6 +451,7 @@ export function CharacterSheetPage() {
)}
</div>
))}
<Pagination page={itemsPage.page} pageCount={itemsPage.pageCount} onPrev={itemsPage.prevPage} onNext={itemsPage.nextPage} />
{canEdit && (
<form onSubmit={handleAddItem} className="flex-row mt-sm flex-wrap">
<input
@@ -395,6 +479,41 @@ export function CharacterSheetPage() {
</div>
)}
<div className="card mt-md">
<div className="card-title">Background</div>
<textarea
rows={4}
defaultValue={character.background || ''}
placeholder={canEdit ? "Where this character came from, what drives them…" : 'No background written yet.'}
readOnly={!canEdit}
onBlur={(e) => canEdit && patchCharacter.mutate({ background: e.target.value })}
/>
</div>
<div className="card mt-md">
<div className="card-title">Appearance</div>
<textarea
rows={3}
defaultValue={character.appearance || ''}
placeholder={canEdit ? 'Height, build, notable features, typical outfit…' : 'No appearance written yet.'}
readOnly={!canEdit}
onBlur={(e) => canEdit && patchCharacter.mutate({ appearance: e.target.value })}
/>
</div>
{isOwner && (
<div className="card mt-md">
<div className="card-title">Private Notes</div>
<p className="subtitle" style={{ marginTop: 0 }}>Only you can see this — not even the DM.</p>
<textarea
rows={4}
defaultValue={character.privateNotes || ''}
placeholder="Secrets, plans, things your character wouldn't say out loud…"
onBlur={(e) => patchCharacter.mutate({ privateNotes: e.target.value })}
/>
</div>
)}
<div className="card mt-md">
<div className="card-title">Notes</div>
<form onSubmit={handleAddNote} className="flex-row flex-wrap">
@@ -410,7 +529,7 @@ export function CharacterSheetPage() {
</button>
</form>
<div className="mt-sm">
{notes?.map((n) => (
{notesPage.pageItems.map((n) => (
<div key={n.id} style={{ padding: '0.4rem 0', borderBottom: '1px solid var(--border-soft)' }}>
<p style={{ margin: 0 }}>{n.body}</p>
<span style={{ fontSize: '0.75rem', color: 'var(--text-dim)' }}>
@@ -419,6 +538,7 @@ export function CharacterSheetPage() {
</div>
))}
</div>
<Pagination page={notesPage.page} pageCount={notesPage.pageCount} onPrev={notesPage.prevPage} onNext={notesPage.nextPage} />
</div>
<QuickStatsFab characterId={characterId} />