V1.25.0: the DM approves a level, each player takes their own
- "Level up..." beside Rest approves a level for any of the party at once; with XP tracked, those who have the XP start ticked - Each player is told with a notice and picks for themselves in the checklist: class (multiclass), subclass, Boon, spells within the level's allowance, the weapon upgrade; a waiting level shows on the sheet and campaign page - The DM sees who still has picks to make, and can finish or take back any - Hit points on a level up can be rolled (campaign setting): by the site, or at the table and typed in with physical dice - Toasts: notices that slide in over any page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,13 +32,14 @@ import { NumberInput } from '../components/NumberInput';
|
||||
import { SectionNav, type Section } from '../components/SectionNav';
|
||||
import { LifeBadge } from '../components/DeathSaves';
|
||||
import { RestModal } from '../components/RestModal';
|
||||
import { LevelUpBulkModal } from '../components/LevelUpBulkModal';
|
||||
import { Pagination } from '../components/Paginated';
|
||||
import { usePagination } from '../hooks/usePagination';
|
||||
import { CampaignSearch, type SearchGroup } from '../components/campaign/CampaignSearch';
|
||||
import { EntryDetail } from '../components/campaign/EntryDetail';
|
||||
import { ItemsSection, MonstersSection, NpcsSection, SpellsSection, WeaponsSection } from '../components/campaign/PoolSections';
|
||||
import { effectsSummary } from '../lib/gear';
|
||||
import { extractErrorMessage, spellLevelLabel } from '../lib/format';
|
||||
import { SPECIES_LABELS, classLabel, extractErrorMessage, spellLevelLabel } from '../lib/format';
|
||||
import { matchesSearch, type EntryKind, type EntryRef } from '../lib/campaignEntries';
|
||||
import { speciesIcon } from '../lib/speciesIcons';
|
||||
import type { CampaignDiceMode, CharacterSummary, CritRule, Encounter, EncounterMode, HpMethod, RollVisibility, ScoreMethod } from '../api/types';
|
||||
@@ -86,7 +87,8 @@ function sortEncounters(encounters: Encounter[], sort: EncounterSort): Encounter
|
||||
return [...encounters].sort(compare[sort]);
|
||||
}
|
||||
|
||||
function CharacterRow({ character, isDM, onDelete }: { character: CharacterSummary; isDM: boolean; onDelete: () => void }) {
|
||||
// `mine`: the viewer's own character, who gets the way into a level up that is waiting.
|
||||
function CharacterRow({ character, isDM, mine = false, onDelete }: { character: CharacterSummary; isDM: boolean; mine?: boolean; onDelete: () => void }) {
|
||||
const inProgress = character.buildStage !== 'COMPLETE';
|
||||
return (
|
||||
<div className="card flex-between flex-wrap">
|
||||
@@ -97,10 +99,15 @@ function CharacterRow({ character, isDM, onDelete }: { character: CharacterSumma
|
||||
{character.name}
|
||||
</Link>
|
||||
{inProgress && <span className="badge">Building…</span>}
|
||||
{character.levelUpsPending > 0 && (isDM || mine) && (
|
||||
<span className="badge badge-live" title={mine ? 'Your DM has approved a level: open the sheet to choose what you gain' : 'Approved, and waiting for the picks to be made'}>
|
||||
⬆ Level up {mine ? 'ready' : 'waiting on picks'}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem' }}>
|
||||
{character.species ? `${character.species} ` : ''}
|
||||
{character.characterClass || (inProgress ? 'Not yet built' : '')}{character.subclassName && ` (${character.subclassName})`} · Level {character.level}
|
||||
{character.species ? `${SPECIES_LABELS[character.species] ?? character.species} ` : ''}
|
||||
{character.characterClass ? classLabel(character.characterClass, character.subclassName, character.classes) : inProgress ? 'Not yet built' : ''} · Level {character.level}
|
||||
{character.currentLocationName && ` · 📍 ${character.currentLocationName}`}
|
||||
</p>
|
||||
</div>
|
||||
@@ -110,6 +117,11 @@ function CharacterRow({ character, isDM, onDelete }: { character: CharacterSumma
|
||||
<LifeBadge deathSaves={character.deathSaves} /> HP {character.currentHp}/{character.maxHp} · AC {character.armorClass}
|
||||
</div>
|
||||
)}
|
||||
{mine && character.levelUpsPending > 0 && !inProgress && (
|
||||
<Link to={`/characters/${character.id}?levelup=1`} className="btn btn-primary">
|
||||
⬆ Level up
|
||||
</Link>
|
||||
)}
|
||||
<Link to={inProgress ? `/characters/${character.id}/build` : `/characters/${character.id}`} className="btn">
|
||||
{inProgress ? 'Continue Build' : 'Open Sheet'}
|
||||
</Link>
|
||||
@@ -180,6 +192,7 @@ export function CampaignHomePage() {
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [showDelete, setShowDelete] = useState(false);
|
||||
const [resting, setResting] = useState(false);
|
||||
const [levelling, setLevelling] = useState(false);
|
||||
const [deleteConfirmName, setDeleteConfirmName] = useState('');
|
||||
|
||||
const liveEncounters = encounters?.filter((e) => !e.archivedAt) || [];
|
||||
@@ -440,7 +453,7 @@ export function CampaignHomePage() {
|
||||
<div className="section-block">
|
||||
<h2 style={{ fontSize: '1.1rem' }}>Your Character{myCharacters.length > 1 ? 's' : ''}</h2>
|
||||
{myCharacters.map((c) => (
|
||||
<CharacterRow key={c.id} character={c} isDM={false} onDelete={() => {}} />
|
||||
<CharacterRow key={c.id} character={c} isDM={false} mine onDelete={() => {}} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
@@ -450,9 +463,23 @@ export function CampaignHomePage() {
|
||||
<div className="page-header" style={{ marginBottom: '0.75rem' }}>
|
||||
<h2 style={{ fontSize: '1.1rem', margin: 0 }}>{isDM ? 'Characters' : 'Rest of the Party'}</h2>
|
||||
{isDM && characters?.some((c) => c.buildStage === 'COMPLETE') && (
|
||||
<button className="btn" onClick={() => setResting(true)} title="A short or long rest for any of the party: Hit Dice, HP and spell slots">
|
||||
🛏 Rest…
|
||||
</button>
|
||||
<div className="flex-row flex-wrap">
|
||||
<button
|
||||
className="btn"
|
||||
onClick={() => setLevelling(true)}
|
||||
title="Approve a level for any of the party at once: each player is told, and picks what they gain themselves"
|
||||
>
|
||||
⬆ Level up…
|
||||
{campaign.trackXp && characters.some((c) => c.xpProgress.levelUpDue) && (
|
||||
<span className="badge badge-live" style={{ marginLeft: 6 }}>
|
||||
{characters.filter((c) => c.xpProgress.levelUpDue).length} due
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
<button className="btn" onClick={() => setResting(true)} title="A short or long rest for any of the party: Hit Dice, HP and spell slots">
|
||||
🛏 Rest…
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<form onSubmit={handleCreateCharacter} className="flex-row flex-wrap mt-sm" style={{ marginBottom: '0.75rem' }}>
|
||||
@@ -1010,6 +1037,9 @@ export function CampaignHomePage() {
|
||||
)}
|
||||
|
||||
{isDM && resting && <RestModal campaignId={campaignId} characters={characters ?? []} onClose={() => setResting(false)} />}
|
||||
{isDM && levelling && (
|
||||
<LevelUpBulkModal campaignId={campaignId} characters={characters ?? []} trackXp={campaign.trackXp} onClose={() => setLevelling(false)} />
|
||||
)}
|
||||
|
||||
{isDM && opened && (
|
||||
<EntryDetail
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, type FormEvent } from 'react';
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||
import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
useCharacter,
|
||||
usePatchCharacter,
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
useCampaigns,
|
||||
useCopyCharacter,
|
||||
useCampaignLocations,
|
||||
useApproveLevelUps,
|
||||
} from '../api/queries';
|
||||
import { useAuth } from '../auth/useAuth';
|
||||
import { useCampaignSocket } from '../hooks/useCampaignSocket';
|
||||
@@ -251,6 +252,7 @@ export function CharacterSheetPage() {
|
||||
const { data: character, isLoading, error } = useCharacter(characterId);
|
||||
useRememberCampaign(character?.campaignId);
|
||||
const patchCharacter = usePatchCharacter(characterId);
|
||||
const approveLevelUp = useApproveLevelUps(character?.campaignId ?? '');
|
||||
useCampaignSocket(character?.campaignId);
|
||||
|
||||
const { data: campaignData } = useCampaign(character?.campaignId);
|
||||
@@ -292,7 +294,9 @@ export function CharacterSheetPage() {
|
||||
const [pickedSpellId, setPickedSpellId] = useState('');
|
||||
const [copyTargetId, setCopyTargetId] = useState('');
|
||||
const [formError, setFormError] = useState<string | null>(null);
|
||||
const [levellingUp, setLevellingUp] = useState(false);
|
||||
// ?levelup=1 (the link in the "can level up" notice) opens the checklist straight away.
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [levellingUp, setLevellingUp] = useState(searchParams.get('levelup') === '1');
|
||||
|
||||
const weaponsPage = usePagination(character?.weapons, 8);
|
||||
const spellsPage = usePagination(character?.spells, 8);
|
||||
@@ -428,6 +432,22 @@ export function CharacterSheetPage() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
{character.levelUpsPending > 0 && canEdit && (
|
||||
<div className="notice-banner" role="status">
|
||||
<span style={{ flex: 1 }}>
|
||||
<strong>⬆ {isOwner ? 'You can level up!' : `${character.name} has a level up waiting.`}</strong>{' '}
|
||||
{isOwner
|
||||
? `Level ${character.level} → ${character.level + 1}: see what you gain and make your picks.`
|
||||
: character.userId
|
||||
? 'Their player has been told; you can also finish it for them.'
|
||||
: 'No player: it is yours to finish.'}
|
||||
{character.levelUpsPending > 1 && ` (${character.levelUpsPending} levels approved.)`}
|
||||
</span>
|
||||
<button className="btn btn-primary" onClick={() => setLevellingUp(true)}>
|
||||
{isOwner ? 'Choose what you gain' : 'Open the checklist'}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<div className="page-header">
|
||||
<div>
|
||||
<h1>
|
||||
@@ -606,13 +626,23 @@ export function CharacterSheetPage() {
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
{character.userId && character.userId !== user?.id && (
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={() => approveLevelUp.mutate({ characterIds: [character.id] }, { onError: (err) => setFormError(extractErrorMessage(err)) })}
|
||||
disabled={character.level + character.levelUpsPending >= 20 || approveLevelUp.isPending}
|
||||
title="Approves one level: their player is told, sees what they gain and makes the picks themselves"
|
||||
>
|
||||
⬆ Approve a level up{character.levelUpsPending > 0 ? ` (${character.levelUpsPending} waiting)` : ''}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
className="btn"
|
||||
onClick={() => setLevellingUp(true)}
|
||||
disabled={character.level >= 20}
|
||||
title="Go up one level with the levelling-up checklist: HP, new special abilities, spells and the free weapon upgrade"
|
||||
title="Go up one level yourself with the levelling-up checklist: HP, new special abilities, spells and the free weapon upgrade"
|
||||
>
|
||||
⬆ Level Up…
|
||||
⬆ Level up now…
|
||||
</button>
|
||||
<label className="flex-row gap-sm" title="Hit Dice this character still has to spend on a short rest. The Rest button on the campaign page keeps count for you.">
|
||||
Hit Dice left
|
||||
@@ -1288,7 +1318,16 @@ export function CharacterSheetPage() {
|
||||
<Pagination page={notesPage.page} pageCount={notesPage.pageCount} onPrev={notesPage.prevPage} onNext={notesPage.nextPage} onJump={notesPage.setPage} />
|
||||
</div>
|
||||
|
||||
{isDM && levellingUp && <LevelUpModal character={character} campaignSpells={campaignSpells ?? []} onClose={() => setLevellingUp(false)} />}
|
||||
{(isDM || (isOwner && character.levelUpsPending > 0)) && levellingUp && (
|
||||
<LevelUpModal
|
||||
character={character}
|
||||
isDM={isDM}
|
||||
onClose={() => {
|
||||
setLevellingUp(false);
|
||||
if (searchParams.has('levelup')) setSearchParams({}, { replace: true });
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { usePagination } from '../hooks/usePagination';
|
||||
import { InfoTip } from '../components/InfoTip';
|
||||
import { SPECIES_LABELS, classLabel, formatPurse, slotsSummary, xpLabel } from '../lib/format';
|
||||
import { RestModal } from '../components/RestModal';
|
||||
import { LevelUpBulkModal } from '../components/LevelUpBulkModal';
|
||||
import { HpBar } from '../components/HpBar';
|
||||
import { LifeBadge } from '../components/DeathSaves';
|
||||
import { ConditionChip, StateBadges } from '../components/CharacterState';
|
||||
@@ -29,6 +30,7 @@ export function PartyOverviewPage() {
|
||||
const { data: characters, isLoading: charsLoading, error: charsError } = useCampaignCharacters(campaignId);
|
||||
const { pageItems, page, pageCount, prevPage, nextPage, setPage } = usePagination(characters, 12);
|
||||
const [resting, setResting] = useState(false);
|
||||
const [levelling, setLevelling] = useState(false);
|
||||
const [checking, setChecking] = useState(false);
|
||||
|
||||
if (campaignLoading || charsLoading) return <Spinner label="Gathering the party…" />;
|
||||
@@ -51,6 +53,11 @@ export function PartyOverviewPage() {
|
||||
🎲 Call for a roll…
|
||||
</button>
|
||||
)}
|
||||
{isDM && characters?.some((c) => c.buildStage === 'COMPLETE') && (
|
||||
<button className="btn" onClick={() => setLevelling(true)} title="Approve a level for any of the party at once: each player is told, and picks what they gain themselves">
|
||||
⬆ Level up…
|
||||
</button>
|
||||
)}
|
||||
{isDM && characters?.some((c) => c.buildStage === 'COMPLETE') && (
|
||||
<button className="btn" onClick={() => setResting(true)} title="A short or long rest for any of the party: Hit Dice, HP and spell slots">
|
||||
🛏 Rest…
|
||||
@@ -64,6 +71,18 @@ export function PartyOverviewPage() {
|
||||
|
||||
{characters?.length === 0 && <div className="empty-state">No characters yet.</div>}
|
||||
|
||||
{isDM && characters?.some((c) => c.levelUpsPending > 0) && (
|
||||
<div className="notice-banner" role="status">
|
||||
<span style={{ flex: 1 }}>
|
||||
<strong>⬆ Level ups waiting on picks:</strong>{' '}
|
||||
{characters
|
||||
.filter((c) => c.levelUpsPending > 0)
|
||||
.map((c) => `${c.name}${c.userId ? '' : ' (no player: yours to finish)'}`)
|
||||
.join(', ')}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{characters && characters.length > 0 && (
|
||||
<div className="table-wrap">
|
||||
<table className="data-table">
|
||||
@@ -125,6 +144,7 @@ export function PartyOverviewPage() {
|
||||
<td data-label="Class">{c.characterClass ? classLabel(c.characterClass, c.subclassName, c.classes) : inProgress ? 'Building…' : '—'}</td>
|
||||
<td data-label="Level">
|
||||
{c.level}
|
||||
{c.levelUpsPending > 0 && <span title="A level up is approved and waiting for its picks"> ⬆</span>}
|
||||
{!inProgress && data?.campaign.trackXp && (
|
||||
<div className="combatant-sub mono" style={{ whiteSpace: 'nowrap' }}>
|
||||
{xpLabel(c.xp, c.xpProgress)}
|
||||
@@ -167,6 +187,9 @@ export function PartyOverviewPage() {
|
||||
<Pagination page={page} pageCount={pageCount} onPrev={prevPage} onNext={nextPage} onJump={setPage} />
|
||||
{isDM && checking && <GroupCheckModal characters={checkers} onClose={() => setChecking(false)} />}
|
||||
{isDM && resting && <RestModal campaignId={campaignId} characters={characters ?? []} onClose={() => setResting(false)} />}
|
||||
{isDM && levelling && (
|
||||
<LevelUpBulkModal campaignId={campaignId} characters={characters ?? []} trackXp={data?.campaign.trackXp ?? true} onClose={() => setLevelling(false)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user