V1.11.0: gear that applies itself, equipping that matters, a character panel

- Weapons and items can carry effects: bonuses and penalties to AC, speed,
  initiative, max HP, passive Perception, ability scores, saving throws
  and skills, plus a note. They apply on their own while equipped and stop
  when the thing comes off. Armor is an item with an AC effect. The DM
  sets them with "Effects" on a row in the weapon or item pool.
- The sheet's "armor bonus" is now "Extra AC", the DM's own adjustment on
  top of gear, and only the DM can set it.
- Only what is equipped counts: a weapon has to be equipped to be used in
  an encounter. A character can have two things equipped at once, one of
  them a weapon (campaign settings). Equipping at the limit is refused
  with a message, and can be changed at any time, mid-encounter included.
- A built-in item library: armor, shields, worn gear and supplies, with
  their effects set. The weapon library gains paired weapons (a pair of
  daggers is one weapon).
- A floating character button on every page opens a panel with a
  character's numbers and everything they hold, with equip ticks. Players
  get their own characters, the DM everyone's, and each character card in
  an encounter has an Inventory button. It replaces the quick stats drawer.
- A player's own characters stand out: marked and highlighted in
  encounters, with a button that jumps to their card; highlighted on the
  party screen; and listed once, not twice, on the campaign page.
- All packages at version 1.11.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 16:03:53 +02:00
co-authored by Claude Opus 5.5
parent 2dcb41ae4a
commit 0124e3bc53
36 changed files with 1810 additions and 272 deletions
+151 -9
View File
@@ -35,6 +35,7 @@ import {
useDeleteLocation,
useCampaignLibrary,
useAddWeaponFromLibrary,
useAddItemFromLibrary,
useAddSpellFromLibrary,
useAddMonsterFromLibrary,
} from '../api/queries';
@@ -46,10 +47,12 @@ import { JumpNav } from '../components/JumpNav';
import { LifeBadge } from '../components/DeathSaves';
import { usePagination, Pagination } from '../components/Paginated';
import { WaresEditor } from '../components/Wares';
import { EffectsEditor } from '../components/EffectsEditor';
import { effectsSummary } from '../lib/gear';
import { SPELL_DAMAGE_GROUPS, SPELL_DAMAGE_SPECIALS, extractErrorMessage, fmtMod, formatMoney, spellLevelLabel, spellRequirementLabel } from '../lib/format';
import { speciesIcon } from '../lib/speciesIcons';
import { ABILITY_ORDER, DAMAGE_SCALING_LABELS, MAX_GEAR_LEVEL } from '../lib/previewCalc';
import type { CharacterSummary, Encounter, EncounterMode, Item, LibraryMonster, LibrarySpell, LibraryWeapon, Monster, Npc, NpcDisposition, Weapon } from '../api/types';
import type { CharacterSummary, Encounter, EncounterMode, GearEffect, Item, LibraryItem, LibraryMonster, LibrarySpell, LibraryWeapon, Monster, Npc, NpcDisposition, Weapon } from '../api/types';
// How the encounter list can be ordered. "custom" is the campaign's own order,
// which the DM arranges; the rest only change what this browser shows.
@@ -128,10 +131,13 @@ function PoolRowControls({
entry,
onToggleStarting,
onDelete,
onEffects,
}: {
entry: { name: string; isStartingOption: boolean };
onToggleStarting: (isStartingOption: boolean) => void;
onDelete: () => void;
// For weapons and items: opens what it does while equipped.
onEffects?: () => void;
}) {
return (
<>
@@ -144,6 +150,11 @@ function PoolRowControls({
/>
</td>
<td className="cell-actions">
{onEffects && (
<button className="btn btn-ghost" aria-label={`What ${entry.name} does while equipped`} onClick={onEffects}>
Effects
</button>
)}
<button
className="btn btn-ghost"
aria-label={`Remove ${entry.name}`}
@@ -239,6 +250,48 @@ function SpellDamageSelect({
);
}
// The DM's editor for what one weapon or item does while equipped. Saving
// changes the sheet of every character who has it on.
function GearEffectsPanel({
entry,
saving,
onSave,
onClose,
}: {
entry: Weapon | Item;
saving: boolean;
onSave: (effects: GearEffect[], effectNote: string | null) => void;
onClose: () => void;
}) {
const [effects, setEffects] = useState<GearEffect[]>(entry.effects ?? []);
const [note, setNote] = useState(entry.effectNote ?? '');
return (
<div className="card mt-sm" style={{ background: 'var(--bg-inset)' }}>
<div className="section-label">What {entry.name} does</div>
<p className="combatant-sub" style={{ marginTop: 0 }}>
These count for a character only while it is equipped and they are high enough level to use it. Armor is an item with
+AC; a penalty is a negative number.
</p>
<EffectsEditor
effects={effects}
note={note}
onChange={(nextEffects, nextNote) => {
setEffects(nextEffects);
setNote(nextNote);
}}
/>
<div className="flex-row mt-sm">
<button className="btn btn-primary" disabled={saving} onClick={() => onSave(effects, note.trim() || null)}>
Save Effects
</button>
<button className="btn btn-ghost" onClick={onClose}>
Cancel
</button>
</div>
</div>
);
}
type MonsterInput = Omit<Monster, 'id' | 'campaignId'>;
type AbilityScores = Pick<Monster, 'strScore' | 'dexScore' | 'conScore' | 'intScore' | 'wisScore' | 'chaScore'>;
const scoreField = (ability: string) => `${ability.toLowerCase()}Score` as keyof AbilityScores;
@@ -536,6 +589,7 @@ export function CampaignHomePage() {
const createLocation = useCreateLocation(campaignId);
const deleteLocation = useDeleteLocation(campaignId);
const addWeaponFromLibrary = useAddWeaponFromLibrary(campaignId);
const addItemFromLibrary = useAddItemFromLibrary(campaignId);
const addSpellFromLibrary = useAddSpellFromLibrary(campaignId);
const addMonsterFromLibrary = useAddMonsterFromLibrary(campaignId);
@@ -555,10 +609,13 @@ export function CampaignHomePage() {
const [deleteConfirmName, setDeleteConfirmName] = useState('');
const [showMonsterForm, setShowMonsterForm] = useState(false);
const [editingMonsterId, setEditingMonsterId] = useState<string | null>(null);
// The weapon or item whose effects are being edited, as "weapons:<id>" or "items:<id>".
const [effectsFor, setEffectsFor] = useState<string | null>(null);
const [showWeaponForm, setShowWeaponForm] = useState(false);
const [showSpellForm, setShowSpellForm] = useState(false);
const [showItemForm, setShowItemForm] = useState(false);
const [showWeaponLibrary, setShowWeaponLibrary] = useState(false);
const [showItemLibrary, setShowItemLibrary] = useState(false);
const [showSpellLibrary, setShowSpellLibrary] = useState(false);
const [showMonsterLibrary, setShowMonsterLibrary] = useState(false);
@@ -584,7 +641,7 @@ export function CampaignHomePage() {
const { campaign, members } = data;
const isDM = campaign.role === 'DM';
const myCharacters = characters?.filter((c) => c.userId === user?.id) || [];
const partyCharacters = characters?.filter((c) => !isDM || c.userId !== user?.id) || [];
const partyCharacters = characters?.filter((c) => c.userId !== user?.id) || [];
async function handleCreateCharacter(e: FormEvent) {
e.preventDefault();
@@ -709,6 +766,8 @@ export function CampaignHomePage() {
skipMotivationRoll: fd.get('skipMotivationRoll') === 'on',
showMonsterHp: fd.get('showMonsterHp') === 'on',
areaAttackAcPenalty: Number(fd.get('areaAttackAcPenalty')),
maxEquipped: Number(fd.get('maxEquipped')),
maxEquippedWeapons: Number(fd.get('maxEquippedWeapons')),
});
}}
>
@@ -747,6 +806,32 @@ export function CampaignHomePage() {
/>
<span className="combatant-sub">added to each target's AC for every target beyond the first (0 for none)</span>
</label>
<label className="flex-row flex-wrap gap-sm mt-sm">
Equipped at once
<NumberInput
name="maxEquipped"
min={1}
max={20}
keepValue
defaultValue={campaign.maxEquipped}
style={{ width: 70 }}
title="How many weapons and items a character can have equipped together. Only equipped gear can be used in an encounter or gives its effects."
/>
things, of which
<NumberInput
name="maxEquippedWeapons"
min={0}
max={20}
keepValue
defaultValue={campaign.maxEquippedWeapons}
style={{ width: 70 }}
title="How many of those can be weapons. A weapon for each hand, like a pair of daggers, is made as one weapon."
/>
<span className="combatant-sub">
can be weapons. Armor and shields are items and count. Lowering these takes nothing off anyone; they are checked when
something is put on.
</span>
</label>
<button type="submit" className="btn btn-primary mt-md" disabled={updateCampaign.isPending}>
Save Settings
</button>
@@ -839,7 +924,7 @@ export function CampaignHomePage() {
</button>
</form>
{(isDM ? characters : partyCharacters)?.length === 0 && (
<div className="empty-state">No characters yet. Roll one up above.</div>
<div className="empty-state">{isDM || myCharacters.length === 0 ? 'No characters yet. Roll one up above.' : 'Nobody else has a character yet.'}</div>
)}
{(isDM ? characters : partyCharacters)?.map((c) => (
<CharacterRow
@@ -1180,6 +1265,7 @@ export function CampaignHomePage() {
onAdd={(key) => addWeaponFromLibrary.mutate(key)}
placeholder="Search the weapon library…"
renderMeta={(w) => `${w.category} · ${w.damageDice} ${w.damageType} · starts at level 1`}
renderDetail={(w) => effectsSummary(w.effects, w.effectNote)}
/>
)}
{showWeaponForm && (
@@ -1198,6 +1284,8 @@ export function CampaignHomePage() {
damageScaling: Number(fd.get('damageScaling')),
minLevel: Number(fd.get('minLevel')),
isStartingOption: fd.get('isStartingOption') === 'on',
effects: [],
effectNote: null,
});
(e.target as HTMLFormElement).reset();
}}
@@ -1220,6 +1308,20 @@ export function CampaignHomePage() {
<button type="submit" className="btn btn-primary">Add</button>
</form>
)}
{weapons
?.filter((w) => effectsFor === `weapons:${w.id}`)
.map((w) => (
<GearEffectsPanel
key={w.id}
entry={w}
saving={patchWeapon.isPending}
onClose={() => setEffectsFor(null)}
onSave={(effects, effectNote) => patchWeapon.mutate({ id: w.id, effects, effectNote }, { onSuccess: () => setEffectsFor(null), onError: (err) => setFormError(extractErrorMessage(err)) })}
/>
))}
<p className="subtitle" style={{ margin: '0.5rem 0 0' }}>
"Effects" on a row sets what a weapon does to whoever has it equipped: bonuses and penalties to AC, speed, saves and more.
</p>
<div className="table-wrap mt-sm">
<table className="data-table">
<thead>
@@ -1235,7 +1337,10 @@ export function CampaignHomePage() {
<tbody>
{weaponsPage.pageItems.map((w) => (
<tr key={w.id}>
<td className="cell-title">{w.name}</td>
<td className="cell-title">
{w.name}
{effectsSummary(w.effects, w.effectNote) && <div style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>✦ {effectsSummary(w.effects, w.effectNote)}</div>}
</td>
<td data-label="Base damage">{w.damageDice} {w.damageType}</td>
<td data-label="Level">
<StartLevelSelect value={w.minLevel} onChange={(minLevel) => patchWeapon.mutate({ id: w.id, minLevel })} />
@@ -1247,6 +1352,7 @@ export function CampaignHomePage() {
entry={w}
onToggleStarting={(isStartingOption) => patchWeapon.mutate({ id: w.id, isStartingOption })}
onDelete={() => deleteWeapon.mutate(w.id)}
onEffects={() => setEffectsFor(effectsFor === `weapons:${w.id}` ? null : `weapons:${w.id}`)}
/>
</tr>
))}
@@ -1259,10 +1365,25 @@ export function CampaignHomePage() {
<div data-jump="Items" className="mt-md card">
<div className="card-title">
<span>Items Pool</span>
<button className="btn btn-ghost" onClick={() => setShowItemForm((s) => !s)}>
{showItemForm ? 'Close' : '+ Add Item'}
</button>
<div className="flex-row gap-sm">
<button className="btn btn-ghost" onClick={() => setShowItemLibrary((s) => !s)}>
{showItemLibrary ? 'Close Library' : '📚 From Library'}
</button>
<button className="btn btn-ghost" onClick={() => setShowItemForm((s) => !s)}>
{showItemForm ? 'Close' : '+ Add Item'}
</button>
</div>
</div>
{showItemLibrary && library && (
<LibraryPicker<LibraryItem>
items={library.items}
adding={addItemFromLibrary.isPending}
onAdd={(key) => addItemFromLibrary.mutate(key)}
placeholder="Search the item library: armor, shields, worn gear, supplies…"
renderMeta={(i) => [i.category, effectsSummary(i.effects, i.effectNote), i.damageDice].filter(Boolean).join(' · ')}
renderDetail={(i) => i.description}
/>
)}
{showItemForm && (
<form
onSubmit={async (e) => {
@@ -1276,6 +1397,8 @@ export function CampaignHomePage() {
damageScaling: Number(fd.get('damageScaling')),
minLevel: Number(fd.get('minLevel')),
isStartingOption: fd.get('isStartingOption') === 'on',
effects: [],
effectNote: null,
});
form.reset();
}}
@@ -1293,7 +1416,22 @@ export function CampaignHomePage() {
<button type="submit" className="btn btn-primary">Add</button>
</form>
)}
{items?.length === 0 && <p style={{ color: 'var(--text-muted)' }}>No items yet. Add rope, potions, quest items…</p>}
{items?.length === 0 && <p style={{ color: 'var(--text-muted)' }}>No items yet. Add rope, potions, armor, quest items…</p>}
{items
?.filter((item) => effectsFor === `items:${item.id}`)
.map((item) => (
<GearEffectsPanel
key={item.id}
entry={item}
saving={patchItem.isPending}
onClose={() => setEffectsFor(null)}
onSave={(effects, effectNote) => patchItem.mutate({ id: item.id, effects, effectNote }, { onSuccess: () => setEffectsFor(null), onError: (err) => setFormError(extractErrorMessage(err)) })}
/>
))}
<p className="subtitle" style={{ margin: '0.5rem 0 0' }}>
Armor, shields, rings and the like are items with effects: add the item, then press "Effects" on its row (chain mail: +6 AC,
−10 Speed). They apply on their own while a character has the item equipped.
</p>
{items && items.length > 0 && (
<div className="table-wrap mt-sm">
<table className="data-table">
@@ -1311,7 +1449,10 @@ export function CampaignHomePage() {
<tbody>
{itemsPage.pageItems.map((item) => (
<tr key={item.id}>
<td className="cell-title">{item.name}</td>
<td className="cell-title">
{item.name}
{effectsSummary(item.effects, item.effectNote) && <div style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>✦ {effectsSummary(item.effects, item.effectNote)}</div>}
</td>
<td className="cell-wide">{item.description}</td>
<td data-label="Base dice">{item.damageDice || '—'}</td>
<td data-label="Level">
@@ -1328,6 +1469,7 @@ export function CampaignHomePage() {
entry={item}
onToggleStarting={(isStartingOption) => patchItem.mutate({ id: item.id, isStartingOption })}
onDelete={() => deleteItem.mutate(item.id)}
onEffects={() => setEffectsFor(effectsFor === `items:${item.id}` ? null : `items:${item.id}`)}
/>
</tr>
))}
+45 -16
View File
@@ -36,7 +36,8 @@ import { JumpNav } from '../components/JumpNav';
import { useRememberCampaign } from '../lib/lastCampaign';
import { HpBar } from '../components/HpBar';
import { DeathSaves } from '../components/DeathSaves';
import { QuickStatsFab } from '../components/QuickStatsDrawer';
import { GearInForce } from '../components/CharacterPanel';
import { effectsSummary } from '../lib/gear';
import { InfoTip } from '../components/InfoTip';
import { usePagination, Pagination } from '../components/Paginated';
import {
@@ -333,6 +334,16 @@ export function CharacterSheetPage() {
}
}
// Equipping can be refused (too much on already). The reason goes in the
// banner at the top, so the page goes there too.
const equipResult = {
onSuccess: () => setFormError(null),
onError: (err: unknown) => {
setFormError(extractErrorMessage(err));
window.scrollTo({ top: 0, behavior: 'smooth' });
},
};
async function handleGold(sign: 1 | -1) {
const amount = Math.floor(Number(goldAmount));
if (!(amount > 0)) return;
@@ -503,18 +514,21 @@ export function CharacterSheetPage() {
onBlur={(e) => patchCharacter.mutate({ tempHp: Number(e.target.value) })}
/>
</label>
<label className="flex-row gap-sm">
Armor Bonus <InfoTip term="ARMOR_BONUS" />
<NumberInput
key={`armor:${character.armorBonus}`}
min={0}
max={30}
keepValue
defaultValue={character.armorBonus}
style={{ width: 70 }}
onBlur={(e) => patchCharacter.mutate({ armorBonus: Number(e.target.value) })}
/>
</label>
{/* Armor is an equipped item now; this is the DM's own adjustment on top. */}
{isDM && (
<label className="flex-row gap-sm" title="Added to AC on top of what equipped gear gives. Can be negative.">
Extra AC (DM) <InfoTip term="ARMOR_BONUS" />
<NumberInput
key={`armor:${character.armorBonus}`}
min={-30}
max={30}
keepValue
defaultValue={character.armorBonus}
style={{ width: 70 }}
onBlur={(e) => patchCharacter.mutate({ armorBonus: Number(e.target.value) })}
/>
</label>
)}
</div>
)}
@@ -555,6 +569,16 @@ export function CharacterSheetPage() {
<p className="subtitle mt-sm">📍 Currently at: <strong>{character.currentLocation.name}</strong></p>
)}
{(sheet.gear.effects.length > 0 || sheet.gear.notes.length > 0) && (
<div className="card mt-md">
<div className="card-title">From Equipped Gear</div>
<GearInForce gear={sheet.gear} />
<p className="subtitle" style={{ margin: '0.4rem 0 0' }}>
Already counted in every number on this sheet. Take something off and its line goes.
</p>
</div>
)}
<JumpNav />
<div data-jump="Abilities" className="card mt-md">
@@ -632,6 +656,9 @@ export function CharacterSheetPage() {
Lv {cw.level} · {cw.scaledDamageDice} {cw.weapon.damageType} · x{cw.quantity}
</span>
{!cw.usable && <RequiresLevel level={cw.level} />}
{effectsSummary(cw.weapon.effects, cw.weapon.effectNote) && (
<div style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>✦ While equipped: {effectsSummary(cw.weapon.effects, cw.weapon.effectNote)}</div>
)}
</div>
{canEdit && (
<div className="flex-row gap-sm">
@@ -641,7 +668,7 @@ export function CharacterSheetPage() {
type="checkbox"
checked={cw.equipped}
disabled={!cw.usable}
onChange={(e) => patchWeapon.mutate({ weaponId: cw.weaponId, equipped: e.target.checked })}
onChange={(e) => patchWeapon.mutate({ weaponId: cw.weaponId, equipped: e.target.checked }, equipResult)}
/>
</label>
{isDM && (
@@ -758,6 +785,9 @@ export function CharacterSheetPage() {
{held.scaledDamageDice && ` · ${held.scaledDamageDice}`} · x{held.quantity}
</span>
{!held.usable && <RequiresLevel level={held.level} />}
{effectsSummary(held.item.effects, held.item.effectNote) && (
<div style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>✦ While equipped: {effectsSummary(held.item.effects, held.item.effectNote)}</div>
)}
{held.item.description && (
<div style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>{held.item.description}</div>
)}
@@ -770,7 +800,7 @@ export function CharacterSheetPage() {
type="checkbox"
checked={held.equipped}
disabled={!held.usable}
onChange={(e) => patchItem.mutate({ itemId: held.itemId, equipped: e.target.checked })}
onChange={(e) => patchItem.mutate({ itemId: held.itemId, equipped: e.target.checked }, equipResult)}
/>
</label>
{isDM && (
@@ -1031,7 +1061,6 @@ export function CharacterSheetPage() {
<Pagination page={notesPage.page} pageCount={notesPage.pageCount} onPrev={notesPage.prevPage} onNext={notesPage.nextPage} />
</div>
<QuickStatsFab characterId={characterId} />
</div>
);
}
+48 -5
View File
@@ -32,6 +32,8 @@ import { HpBar } from '../components/HpBar';
import { DeathSaves } from '../components/DeathSaves';
import { TradePanel } from '../components/TradePanel';
import { useRememberCampaign } from '../lib/lastCampaign';
import { openCharacterPanel } from '../lib/characterPanel';
import { GearInForce } from '../components/CharacterPanel';
import { ABILITY_LABELS, CLASS_LABELS, COIN_LABELS, CURRENCIES, SPECIES_LABELS, extractErrorMessage, fmtMod, formatMoney, spellLevelLabel } from '../lib/format';
import { abilityModifier, scaledDamageDice, MAX_GEAR_LEVEL } from '../lib/previewCalc';
import type {
@@ -105,6 +107,7 @@ function subline(p: EncounterParticipant): string {
function CombatantCard({
participant: p,
isDM,
isMine,
isActive,
onPatch,
canRollInitiative,
@@ -116,6 +119,8 @@ function CombatantCard({
}: {
participant: EncounterParticipant;
isDM: boolean;
// The viewer's own character: its card is marked so it is easy to find.
isMine: boolean;
isActive: boolean;
onPatch: (data: Partial<EncounterParticipant>) => void;
// The DM for anyone; a player for their own character. The same goes for
@@ -170,9 +175,13 @@ function CombatantCard({
}
return (
<div className={`card combatant combatant-${p.kind.toLowerCase()}${isActive ? ' is-active' : ''}${isDown && !isDying ? ' is-down' : ''}${isTargeted ? ' is-targeted' : ''}`}>
<div
id={`combatant-${p.id}`}
className={`card combatant combatant-${p.kind.toLowerCase()}${isMine ? ' is-mine' : ''}${isActive ? ' is-active' : ''}${isDown && !isDying ? ' is-down' : ''}${isTargeted ? ' is-targeted' : ''}`}
>
<div className="flex-between flex-wrap">
<div>
{isMine && <div className="mine-marker">★ Your character</div>}
{isActive && <div className="turn-marker">▶ On turn</div>}
{isTargeted && (
<div className="target-marker">
@@ -190,6 +199,15 @@ function CombatantCard({
<span className="combatant-name">{p.displayName}</span>
)}
{npc && <span className={`badge badge-${npc.disposition.toLowerCase()}`}>{npc.disposition}</span>}
{p.character && (isDM || isMine) && (
<button
className="btn btn-target"
title={`Everything ${p.displayName} holds: weapons, items, spells and money`}
onClick={() => p.character && openCharacterPanel(p.character.id)}
>
🎒 Inventory
</button>
)}
{isDown && !info && <span className="badge badge-hostile">Down</span>}
{p.hidden && (
<span className="badge" title="Out of the fight. Players no longer see this card, and it has no turn.">
@@ -367,11 +385,19 @@ function CombatantCard({
{ABILITIES.map((a) => `${a} ${fmtMod(info.saves[a].bonus)}${info.saves[a].proficient ? '*' : ''}`).join(' · ')}{' '}
<span title="Proficient">(* proficient)</span>
</p>
{info.weapons.length === 0 && info.spells.length === 0 && <p className="combatant-sub">No usable weapons or spells.</p>}
<GearInForce gear={info.gear} />
{info.weapons.length === 0 && (
<p className="combatant-sub">No weapon equipped. A weapon has to be equipped to be used: open 🎒 Inventory to put one on.</p>
)}
{info.items.length > 0 && (
<p className="combatant-sub">
Equipped: {info.items.map((i) => `${i.name}${i.damageDice ? ` (${i.damageDice})` : ''}`).join(' · ')}
</p>
)}
{info.weapons.map((w) => (
<div key={w.characterWeaponId} className="detail-row">
<span>
{w.name} {w.equipped && <span className="badge">equipped</span>}
{w.name}
<span className="combatant-sub" style={{ marginLeft: 6 }}>
Lv {w.level} · {w.damageDice} {fmtMod(w.damageBonus)} {w.damageType}
</span>
@@ -443,8 +469,7 @@ function CombatantCard({
function attackLines(p: EncounterParticipant): string[] {
const info = p.characterCombatInfo;
if (info) {
const equipped = info.weapons.filter((w) => w.equipped);
const weapons = (equipped.length ? equipped : info.weapons).map(
const weapons = info.weapons.map(
(w) => `${w.name}: ${fmtMod(w.attackBonus)} to hit · ${w.damageDice} ${fmtMod(w.damageBonus)} ${w.damageType}`
);
const spells = info.spells
@@ -877,6 +902,8 @@ export function EncounterPage() {
const outOfTheFight = participants.filter((p) => p.hidden);
const fallen = encounter.fallen ?? [];
const active = isBattle && encounter.status === 'ACTIVE' ? participants.find((p) => p.id === encounter.activeParticipantId) : undefined;
// The viewer's own characters here, to mark and to jump to.
const mine = participants.filter((p) => p.character != null && p.character.userId === user?.id);
const targetIds = encounter.targetParticipantIds ?? [];
const targets = targetIds.map((id) => participants.find((p) => p.id === id)).filter((p): p is EncounterParticipant => p !== undefined);
// The DM marks targets whenever they like; a player while their own character is on turn.
@@ -914,6 +941,7 @@ export function EncounterPage() {
key={p.id}
participant={p}
isDM={isDM}
isMine={p.character != null && p.character.userId === user?.id}
isActive={p.id === active?.id}
onPatch={(data) => patchParticipant.mutate({ participantId: p.id, ...data }, fail)}
canRollInitiative={isDM || (p.character != null && p.character.userId === user?.id)}
@@ -1044,6 +1072,21 @@ export function EncounterPage() {
{formError && <ErrorBanner message={formError} />}
{mine.length > 0 && (
<nav className="jump-nav" aria-label="Your characters in this scene">
{mine.map((p) => (
<button
key={p.id}
type="button"
className="jump-link is-mine"
onClick={() => document.getElementById(`combatant-${p.id}`)?.scrollIntoView({ behavior: 'smooth', block: 'center' })}
>
★ {p.displayName} · {p.currentHp}/{p.maxHp} HP{p.id === active?.id ? ' · your turn' : ''}
</button>
))}
</nav>
)}
{(isDM || encounter.description) && (
<div className="card">
<div className="card-title">{isBattle ? 'The Scene' : 'Quest'}</div>
+2 -2
View File
@@ -66,12 +66,12 @@ export function PartyOverviewPage() {
const inProgress = c.buildStage !== 'COMPLETE';
const isMine = c.userId === user?.id;
return (
<tr key={c.id}>
<tr key={c.id} className={isMine ? 'is-mine' : undefined}>
<td className="cell-title">
<Link to={inProgress ? `/characters/${c.id}/build` : `/characters/${c.id}`}>
<span aria-hidden="true">{speciesIcon(c.species)}</span> {c.name}
</Link>
{isMine && <span className="badge" style={{ marginLeft: 6 }}>you</span>}
{isMine && <span className="badge badge-mine" style={{ marginLeft: 6 }}>★ Yours</span>}
</td>
<td data-label="Species">{c.species ? SPECIES_LABELS[c.species] : '—'}</td>
<td data-label="Class">{c.characterClass ? CLASS_LABELS[c.characterClass] : inProgress ? 'Building…' : '—'}</td>