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:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "1.10.1",
|
||||
"version": "1.11.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
Encounter,
|
||||
EncounterMode,
|
||||
EncounterParticipant,
|
||||
GearEffect,
|
||||
GoldTransaction,
|
||||
Item,
|
||||
Location,
|
||||
@@ -470,9 +471,16 @@ export function usePatchPoolEntry(campaignId: string, pool: Pool) {
|
||||
description?: string | null;
|
||||
exchangeGold?: number | null;
|
||||
exchangeCash?: number | null;
|
||||
effects?: GearEffect[];
|
||||
effectNote?: string | null;
|
||||
}) =>
|
||||
(await apiClient.patch(`/campaigns/${campaignId}/${pool}/${id}`, data)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, pool] }),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['campaign', campaignId, pool] });
|
||||
// What an entry does while equipped changes the sheet of whoever holds it.
|
||||
qc.invalidateQueries({ queryKey: ['character'] });
|
||||
qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'characters'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -585,6 +593,14 @@ export function useAddWeaponFromLibrary(campaignId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useAddItemFromLibrary(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (key: string) => (await apiClient.post<{ item: Item }>(`/campaigns/${campaignId}/items/from-library`, { key })).data.item,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'items'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useAddSpellFromLibrary(campaignId: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
|
||||
@@ -95,6 +95,10 @@ export interface Campaign {
|
||||
showMonsterHp: boolean; // off: players get a health bar for monsters and NPCs, no numbers
|
||||
// Added to each target's AC for every target beyond the first in an area attack; 0 is off.
|
||||
areaAttackAcPenalty: number;
|
||||
// How many weapons and items a character can have equipped together, and
|
||||
// how many of those can be weapons. Only equipped gear is used in a fight.
|
||||
maxEquipped: number;
|
||||
maxEquippedWeapons: number;
|
||||
ownerId: string;
|
||||
archivedAt: string | null; // set while the campaign is archived
|
||||
role: 'DM' | 'PLAYER';
|
||||
@@ -162,6 +166,21 @@ export interface AbilityDetail {
|
||||
modifier: number;
|
||||
}
|
||||
|
||||
// One thing a weapon or item does to whoever has it equipped: a signed amount
|
||||
// on one of the sheet's numbers ("AC", "SPEED", "STR", "SAVE_DEX",
|
||||
// "SKILL_STEALTH"...). The full list is GEAR_STATS on the server.
|
||||
export interface GearEffect {
|
||||
stat: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
// What a character's equipped gear is doing right now. The sheet's numbers
|
||||
// already include it; this says where each change comes from.
|
||||
export interface ActiveGear {
|
||||
effects: (GearEffect & { source: string })[];
|
||||
notes: { source: string; note: string }[];
|
||||
}
|
||||
|
||||
export interface CharacterSheet {
|
||||
abilities: Record<Ability, AbilityDetail>;
|
||||
proficiencyBonus: number;
|
||||
@@ -174,6 +193,7 @@ export interface CharacterSheet {
|
||||
skills: Record<string, { ability: Ability; proficient: boolean; expertise: boolean; bonus: number }>;
|
||||
passivePerception: number;
|
||||
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
|
||||
gear: ActiveGear;
|
||||
}
|
||||
|
||||
export interface Weapon {
|
||||
@@ -192,6 +212,8 @@ export interface Weapon {
|
||||
damageScaling: number;
|
||||
minLevel: number;
|
||||
isStartingOption: boolean;
|
||||
effects: GearEffect[]; // what it does to whoever has it equipped
|
||||
effectNote: string | null; // and what it does that is not a number
|
||||
}
|
||||
|
||||
export interface CharacterWeapon {
|
||||
@@ -240,6 +262,8 @@ export interface Item {
|
||||
damageScaling: number;
|
||||
minLevel: number;
|
||||
isStartingOption: boolean;
|
||||
effects: GearEffect[]; // armor is an item with an AC effect
|
||||
effectNote: string | null;
|
||||
}
|
||||
|
||||
export interface InventoryItem {
|
||||
@@ -413,6 +437,15 @@ export interface CombatWeapon {
|
||||
damageType: string;
|
||||
}
|
||||
|
||||
// An item a character has equipped, as everyone in an encounter sees it.
|
||||
export interface CombatItem {
|
||||
inventoryItemId: string;
|
||||
name: string;
|
||||
level: number;
|
||||
quantity: number;
|
||||
damageDice: string | null;
|
||||
}
|
||||
|
||||
export interface CombatSpell {
|
||||
characterSpellId: string;
|
||||
name: string;
|
||||
@@ -437,7 +470,9 @@ export interface CharacterCombatInfo {
|
||||
abilities: Record<Ability, AbilityDetail>;
|
||||
saves: Record<Ability, { proficient: boolean; bonus: number }>;
|
||||
specialAbilities: string | null;
|
||||
weapons: CombatWeapon[];
|
||||
gear: ActiveGear;
|
||||
weapons: CombatWeapon[]; // the equipped ones: a weapon has to be in hand to be used
|
||||
items: CombatItem[]; // likewise
|
||||
spells: CombatSpell[];
|
||||
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
|
||||
}
|
||||
@@ -520,6 +555,18 @@ export interface LibraryWeapon {
|
||||
properties: string[];
|
||||
rangeNormal: number | null;
|
||||
rangeLong: number | null;
|
||||
effects?: GearEffect[];
|
||||
effectNote?: string | null;
|
||||
}
|
||||
|
||||
export interface LibraryItem {
|
||||
key: string;
|
||||
name: string;
|
||||
category: string;
|
||||
description: string | null;
|
||||
damageDice: string | null;
|
||||
effects: GearEffect[];
|
||||
effectNote: string | null;
|
||||
}
|
||||
|
||||
export interface LibrarySpell {
|
||||
@@ -557,6 +604,7 @@ export interface LibraryMonster {
|
||||
|
||||
export interface CampaignLibrary {
|
||||
weapons: LibraryWeapon[];
|
||||
items: LibraryItem[];
|
||||
spells: LibrarySpell[];
|
||||
monsters: LibraryMonster[];
|
||||
}
|
||||
@@ -568,14 +616,48 @@ export interface QuickStatsWeapon {
|
||||
level: number;
|
||||
equipped: boolean;
|
||||
quantity: number;
|
||||
usable: boolean; // false while the character is below this copy's level
|
||||
effects: GearEffect[];
|
||||
effectNote: string | null;
|
||||
attackBonus: number;
|
||||
damageBonus: number;
|
||||
damageDice: string;
|
||||
damageType: string;
|
||||
}
|
||||
|
||||
export interface QuickStats {
|
||||
export interface QuickStatsItem {
|
||||
inventoryItemId: string;
|
||||
itemId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
level: number;
|
||||
equipped: boolean;
|
||||
quantity: number;
|
||||
usable: boolean;
|
||||
damageDice: string | null; // at this copy's level
|
||||
effects: GearEffect[];
|
||||
effectNote: string | null;
|
||||
}
|
||||
|
||||
export interface QuickStatsSpell {
|
||||
characterSpellId: string;
|
||||
name: string;
|
||||
level: number;
|
||||
damageDice: string | null;
|
||||
description: string | null;
|
||||
prepared: boolean;
|
||||
usable: boolean;
|
||||
}
|
||||
|
||||
// A character at a glance, with everything it holds. The pack, the spell
|
||||
// list and the purse are only sent to the owning player and the DM
|
||||
// (`restricted` is true for anyone else).
|
||||
export interface QuickStats {
|
||||
id: string;
|
||||
name: string;
|
||||
level: number;
|
||||
species: Species | null;
|
||||
characterClass: CharacterClass | null;
|
||||
currentHp: number;
|
||||
maxHp: number;
|
||||
tempHp: number;
|
||||
@@ -585,6 +667,13 @@ export interface QuickStats {
|
||||
speed: number;
|
||||
proficiencyBonus: number;
|
||||
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
|
||||
passivePerception: number;
|
||||
abilities: Record<Ability, AbilityDetail>;
|
||||
specialAbilities: string | null;
|
||||
gear: ActiveGear;
|
||||
weapons: QuickStatsWeapon[];
|
||||
restricted: boolean;
|
||||
inventory: QuickStatsItem[];
|
||||
spells: QuickStatsSpell[];
|
||||
purse: { gold: number; silver: number; copper: number; cash: number } | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
import { Link, useMatch } from 'react-router-dom';
|
||||
import { useCampaign, useCampaignCharacters, usePatchCharacterWeapon, usePatchInventoryItem, useQuickStats } from '../api/queries';
|
||||
import { useAuth } from '../auth/AuthContext';
|
||||
import { useLastCampaignId } from '../lib/lastCampaign';
|
||||
import { closeCharacterPanel, openCharacterPanel, useCharacterPanelId } from '../lib/characterPanel';
|
||||
import { CLASS_LABELS, SPECIES_LABELS, fmtMod, formatPurse, spellLevelLabel } from '../lib/format';
|
||||
import { effectLabel, effectsSummary } from '../lib/gear';
|
||||
import { speciesIcon } from '../lib/speciesIcons';
|
||||
import { Spinner, ErrorBanner } from './Spinner';
|
||||
import { HpBar } from './HpBar';
|
||||
import { DeathSaves } from './DeathSaves';
|
||||
import { useState } from 'react';
|
||||
import { extractErrorMessage } from '../lib/format';
|
||||
import type { ActiveGear } from '../api/types';
|
||||
|
||||
// What equipped gear is doing, one line per thing: "Chain Mail: +6 AC · −10 Speed".
|
||||
export function GearInForce({ gear }: { gear: ActiveGear }) {
|
||||
const sources = [...new Set([...gear.effects.map((e) => e.source), ...gear.notes.map((n) => n.source)])];
|
||||
if (sources.length === 0) return null;
|
||||
return (
|
||||
<>
|
||||
{sources.map((source) => (
|
||||
<div key={source} className="detail-row">
|
||||
<strong>{source}</strong>
|
||||
<span>
|
||||
{[...gear.effects.filter((e) => e.source === source).map(effectLabel), ...gear.notes.filter((n) => n.source === source).map((n) => n.note)].join(' · ')}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Flags({ equipped, usable, level }: { equipped: boolean; usable: boolean; level: number }) {
|
||||
return (
|
||||
<>
|
||||
{equipped && <span className="badge badge-live" style={{ marginLeft: 6 }}>equipped</span>}
|
||||
{!usable && <span className="badge badge-hostile" style={{ marginLeft: 6 }}>needs level {level}</span>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// One character at a glance: the numbers for a fight, and everything they
|
||||
// hold. The pack, spells and purse are there for the character's own player
|
||||
// and the DM, who can also put gear on and take it off from here.
|
||||
function PanelBody({ characterId }: { characterId: string }) {
|
||||
const { data, isLoading, error } = useQuickStats(characterId, true);
|
||||
const patchWeapon = usePatchCharacterWeapon(characterId);
|
||||
const patchItem = usePatchInventoryItem(characterId);
|
||||
// Why something could not be equipped: too much on already.
|
||||
const [equipError, setEquipError] = useState<string | null>(null);
|
||||
const equip = { onError: (err: unknown) => setEquipError(extractErrorMessage(err)), onSuccess: () => setEquipError(null) };
|
||||
|
||||
if (isLoading) return <Spinner label="Reading the sheet…" />;
|
||||
if (error || !data) return <ErrorBanner message="Could not load this character." />;
|
||||
|
||||
const canEquip = !data.restricted;
|
||||
const stats: [string, string | number][] = [
|
||||
['AC', data.armorClass],
|
||||
['Initiative', fmtMod(data.initiative)],
|
||||
['Speed', data.speed],
|
||||
['Prof.', fmtMod(data.proficiencyBonus)],
|
||||
['Passive Perc.', data.passivePerception],
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="mt-md">
|
||||
<div className="flex-between flex-wrap">
|
||||
<div>
|
||||
<h3 style={{ margin: 0 }}>
|
||||
<span aria-hidden="true">{speciesIcon(data.species)}</span> {data.name}
|
||||
</h3>
|
||||
<div className="combatant-sub">
|
||||
{data.species && SPECIES_LABELS[data.species]} {data.characterClass && CLASS_LABELS[data.characterClass]} · Level {data.level}
|
||||
</div>
|
||||
</div>
|
||||
<Link to={`/characters/${data.id}`} className="btn" onClick={closeCharacterPanel}>
|
||||
Full sheet
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="stat-chips mt-sm">
|
||||
<span className="stat-chip">
|
||||
<span>HP</span>
|
||||
<b>
|
||||
{data.currentHp}/{data.maxHp}
|
||||
{data.tempHp > 0 && ` +${data.tempHp}`}
|
||||
</b>
|
||||
</span>
|
||||
{stats.map(([label, value]) => (
|
||||
<span key={label} className="stat-chip">
|
||||
<span>{label}</span>
|
||||
<b>{value}</b>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div className="mt-sm">
|
||||
<HpBar current={data.currentHp} max={data.maxHp} temp={data.tempHp} />
|
||||
</div>
|
||||
{/* Read-only here; the saves are rolled on the sheet or in the encounter. */}
|
||||
<DeathSaves characterId={characterId} name={data.name} deathSaves={data.deathSaves} canAct={false} isDM={false} />
|
||||
|
||||
<div className="stat-chips mt-sm">
|
||||
{(Object.keys(data.abilities) as (keyof typeof data.abilities)[]).map((a) => (
|
||||
<span key={a} className="stat-chip">
|
||||
<span>{a}</span>
|
||||
<b>
|
||||
{data.abilities[a].final} ({fmtMod(data.abilities[a].modifier)})
|
||||
</b>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{(data.gear.effects.length > 0 || data.gear.notes.length > 0) && (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">From equipped gear</div>
|
||||
<GearInForce gear={data.gear} />
|
||||
<p className="combatant-sub" style={{ margin: '0.4rem 0 0' }}>Already counted in the numbers above.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{data.spellcasting && (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Spellcasting</div>
|
||||
<p style={{ margin: 0 }}>
|
||||
Save DC {data.spellcasting.saveDC} · Attack {fmtMod(data.spellcasting.attackBonus)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{canEquip && (
|
||||
<p className="combatant-sub mt-md" style={{ marginBottom: 0 }}>
|
||||
Tick what is equipped. Only equipped weapons can be used in an encounter, and only equipped gear gives its effects.
|
||||
</p>
|
||||
)}
|
||||
{equipError && <ErrorBanner message={equipError} />}
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Weapons · {data.weapons.length}</div>
|
||||
{data.weapons.length === 0 && <p className="combatant-sub" style={{ margin: 0 }}>No weapons.</p>}
|
||||
{data.weapons.map((w) => (
|
||||
<div key={w.characterWeaponId} className="reward-row">
|
||||
<div className="flex-between">
|
||||
<div>
|
||||
<strong>{w.name}</strong>
|
||||
{w.quantity > 1 && <span className="combatant-sub"> ×{w.quantity}</span>}
|
||||
<Flags equipped={w.equipped} usable={w.usable} level={w.level} />
|
||||
<div className="combatant-sub">
|
||||
Lv {w.level} · attack {fmtMod(w.attackBonus)} · {w.damageDice} {fmtMod(w.damageBonus)} {w.damageType}
|
||||
</div>
|
||||
{effectsSummary(w.effects, w.effectNote) && <div className="combatant-sub">✦ {effectsSummary(w.effects, w.effectNote)}</div>}
|
||||
</div>
|
||||
{canEquip && (
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={`${w.name} is equipped`}
|
||||
title="Equipped"
|
||||
checked={w.equipped}
|
||||
disabled={!w.usable || patchWeapon.isPending}
|
||||
onChange={(e) => patchWeapon.mutate({ weaponId: w.weaponId, equipped: e.target.checked }, equip)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{data.restricted ? (
|
||||
<p className="combatant-sub mt-md">Their pack, spells and purse are their own business.</p>
|
||||
) : (
|
||||
<>
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Inventory · {data.inventory.length}</div>
|
||||
{data.inventory.length === 0 && <p className="combatant-sub" style={{ margin: 0 }}>Nothing carried.</p>}
|
||||
{data.inventory.map((item) => (
|
||||
<div key={item.inventoryItemId} className="reward-row">
|
||||
<div className="flex-between">
|
||||
<div>
|
||||
<strong>{item.name}</strong>
|
||||
<span className="combatant-sub"> ×{item.quantity}</span>
|
||||
<Flags equipped={item.equipped} usable={item.usable} level={item.level} />
|
||||
<div className="combatant-sub">
|
||||
Lv {item.level}
|
||||
{item.damageDice && ` · ${item.damageDice}`}
|
||||
</div>
|
||||
{effectsSummary(item.effects, item.effectNote) && <div className="combatant-sub">✦ {effectsSummary(item.effects, item.effectNote)}</div>}
|
||||
{item.description && <div className="combatant-sub">{item.description}</div>}
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={`${item.name} is equipped`}
|
||||
title="Equipped"
|
||||
checked={item.equipped}
|
||||
disabled={!item.usable || patchItem.isPending}
|
||||
onChange={(e) => patchItem.mutate({ itemId: item.itemId, equipped: e.target.checked }, equip)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">
|
||||
<span>Money</span>
|
||||
{data.purse && <span className="mono">{formatPurse(data.purse)}</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{data.spells.length > 0 && (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Spells · {data.spells.length}</div>
|
||||
{data.spells.map((s) => (
|
||||
<div key={s.characterSpellId} className="reward-row">
|
||||
<strong>{s.name}</strong>
|
||||
<span className="combatant-sub">
|
||||
{' '}
|
||||
{spellLevelLabel(s.level)}
|
||||
{s.damageDice && ` · ${s.damageDice}`}
|
||||
</span>
|
||||
{s.prepared && <span className="badge badge-live" style={{ marginLeft: 6 }}>prepared</span>}
|
||||
{!s.usable && <span className="badge badge-hostile" style={{ marginLeft: 6 }}>needs level {s.level}</span>}
|
||||
{s.description && <div className="combatant-sub">{s.description}</div>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{data.specialAbilities && (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Special Abilities</div>
|
||||
<p style={{ margin: 0, whiteSpace: 'pre-wrap' }}>{data.specialAbilities}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// The floating character button, on every page, and the panel it opens. A
|
||||
// player gets their own characters in the campaign they are in; the DM gets
|
||||
// everyone's. Other pages can open the panel for a particular character with
|
||||
// openCharacterPanel (lib/characterPanel.ts).
|
||||
export function CharacterPanel() {
|
||||
const { user } = useAuth();
|
||||
const campaignId = useLastCampaignId() ?? undefined;
|
||||
const { data: campaignData } = useCampaign(campaignId);
|
||||
const { data: characters } = useCampaignCharacters(campaignId);
|
||||
const onSheet = useMatch('/characters/:characterId');
|
||||
const openId = useCharacterPanelId();
|
||||
|
||||
const isDM = campaignData?.campaign.role === 'DM';
|
||||
const choices = (characters ?? []).filter((c) => c.buildStage === 'COMPLETE' && (isDM || c.userId === user?.id));
|
||||
if (choices.length === 0 && !openId) return null;
|
||||
|
||||
// On a character's own sheet the button opens that character; otherwise the first of yours.
|
||||
const fallback = choices.find((c) => c.id === onSheet?.params.characterId) ?? choices.find((c) => c.userId === user?.id) ?? choices[0];
|
||||
const shown = openId ?? undefined;
|
||||
|
||||
return (
|
||||
<>
|
||||
{fallback && (
|
||||
<button
|
||||
className="fab-quickstats"
|
||||
onClick={() => openCharacterPanel(fallback.id)}
|
||||
title={isDM ? 'Characters: stats and inventory' : 'Your character: stats and inventory'}
|
||||
aria-label="Open the character panel"
|
||||
>
|
||||
🧙
|
||||
</button>
|
||||
)}
|
||||
{shown && (
|
||||
<>
|
||||
<div className="drawer-backdrop" onClick={closeCharacterPanel} />
|
||||
<div className="drawer" role="dialog" aria-label="Character panel">
|
||||
<div className="flex-between">
|
||||
{choices.length > 1 && choices.some((c) => c.id === shown) ? (
|
||||
<select aria-label="Which character" value={shown} onChange={(e) => openCharacterPanel(e.target.value)} style={{ flex: 1, minWidth: 0 }}>
|
||||
{choices.map((c) => (
|
||||
<option key={c.id} value={c.id}>
|
||||
{c.name}
|
||||
{isDM && c.userId === user?.id ? ' (yours)' : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<h2 style={{ margin: 0 }}>Character</h2>
|
||||
)}
|
||||
<button className="btn btn-ghost" onClick={closeCharacterPanel} aria-label="Close the character panel">
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<PanelBody key={shown} characterId={shown} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { useState } from 'react';
|
||||
import { NumberInput } from './NumberInput';
|
||||
import { GEAR_STAT_GROUPS, effectLabel, gearStatLabel } from '../lib/gear';
|
||||
import type { GearEffect } from '../api/types';
|
||||
|
||||
// The DM's editor for what a weapon or item does to whoever has it equipped:
|
||||
// a list of signed amounts on the sheet's numbers (armor is "+6 AC"), and a
|
||||
// note for anything that is not a number. It holds nothing itself: the list
|
||||
// and the note live with whoever renders it.
|
||||
export function EffectsEditor({
|
||||
effects,
|
||||
note,
|
||||
onChange,
|
||||
}: {
|
||||
effects: GearEffect[];
|
||||
note: string;
|
||||
onChange: (effects: GearEffect[], note: string) => void;
|
||||
}) {
|
||||
const [stat, setStat] = useState('AC');
|
||||
const [amount, setAmount] = useState('');
|
||||
|
||||
function handleAdd() {
|
||||
const value = Math.trunc(Number(amount));
|
||||
if (!value) return;
|
||||
// One line per number: adding to one already listed replaces it.
|
||||
onChange([...effects.filter((e) => e.stat !== stat), { stat, amount: value }], note);
|
||||
setAmount('');
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="section-label">While equipped</div>
|
||||
{effects.length === 0 && (
|
||||
<p className="combatant-sub" style={{ marginTop: 0 }}>
|
||||
No effects. Add a bonus (armor: +AC) or a penalty (heavy armor: −Speed).
|
||||
</p>
|
||||
)}
|
||||
{effects.length > 0 && (
|
||||
<div className="stat-chips" style={{ marginBottom: '0.5rem' }}>
|
||||
{effects.map((effect) => (
|
||||
<span key={effect.stat} className={`condition-chip ${effect.amount > 0 ? 'is-bonus' : ''}`}>
|
||||
{effectLabel(effect)}
|
||||
<button type="button" aria-label={`Remove the ${gearStatLabel(effect.stat)} effect`} onClick={() => onChange(effects.filter((e) => e !== effect), note)}>
|
||||
✕
|
||||
</button>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex-row flex-wrap gap-sm">
|
||||
<select aria-label="What it changes" value={stat} onChange={(e) => setStat(e.target.value)} style={{ flex: 1, minWidth: 130 }}>
|
||||
{GEAR_STAT_GROUPS.map((group) => (
|
||||
<optgroup key={group.label} label={group.label}>
|
||||
{group.stats.map((s) => (
|
||||
<option key={s} value={s}>
|
||||
{gearStatLabel(s)}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
<NumberInput
|
||||
min={-100}
|
||||
max={100}
|
||||
placeholder="+ or −"
|
||||
aria-label="By how much (negative for a penalty)"
|
||||
title="By how much. A negative number is a penalty."
|
||||
value={amount}
|
||||
onChange={(e) => setAmount(e.target.value)}
|
||||
style={{ width: 90 }}
|
||||
/>
|
||||
<button type="button" className="btn" onClick={handleAdd} disabled={!Math.trunc(Number(amount))}>
|
||||
Add effect
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
className="mt-sm"
|
||||
style={{ width: '100%' }}
|
||||
placeholder="Anything else it does (e.g. Disadvantage on Stealth)"
|
||||
aria-label="What else it does, in words"
|
||||
maxLength={300}
|
||||
value={note}
|
||||
onChange={(e) => onChange(effects, e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export const STAT_HELP: Record<string, string> = {
|
||||
SKILL_BONUS: 'Skill Bonus — added when you roll to use a skill. The governing ability modifier, plus your proficiency bonus if you are proficient (doubled if you have expertise).',
|
||||
EXPERTISE: 'Expertise — doubles your proficiency bonus for this skill, on top of being proficient.',
|
||||
ABILITY_MODIFIER: 'Ability Modifier — the number added to rolls that use this ability. floor((score − 10) / 2).',
|
||||
ARMOR_BONUS: 'Armor Bonus — a flat bonus to AC from equipped armor or a shield, added on top of 10 + Dex modifier.',
|
||||
ARMOR_BONUS: 'Extra AC — a number the DM sets, added to AC on top of 10 + Dex modifier and whatever equipped gear gives. Armor itself is an equipped item.',
|
||||
SPEED: 'Speed — how far you can move on your turn, in feet. Set by your species, unless overridden.',
|
||||
SPELL_SAVE_DC: 'Spell Save DC — the difficulty a target must beat to resist your spell. 8 + proficiency bonus + your spellcasting ability modifier.',
|
||||
SPELL_ATTACK_BONUS: 'Spell Attack Bonus — added when you make a spell attack roll. Proficiency bonus + your spellcasting ability modifier.',
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Link, NavLink, Outlet, useMatch } from 'react-router-dom';
|
||||
import { useAuth } from '../auth/AuthContext';
|
||||
import { useLastCampaignId, useRememberCampaign } from '../lib/lastCampaign';
|
||||
import { DiceRoller } from './DiceRoller';
|
||||
import { CharacterPanel } from './CharacterPanel';
|
||||
|
||||
export function Layout() {
|
||||
const { user, logout } = useAuth();
|
||||
@@ -64,6 +65,7 @@ export function Layout() {
|
||||
</nav>
|
||||
)}
|
||||
<DiceRoller />
|
||||
{user && <CharacterPanel />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
import { useQuickStats } from '../api/queries';
|
||||
import { Spinner, ErrorBanner } from './Spinner';
|
||||
import { fmtMod } from '../lib/format';
|
||||
import { HpBar } from './HpBar';
|
||||
import { DeathSaves } from './DeathSaves';
|
||||
|
||||
export function QuickStatsFab({ characterId }: { characterId: string }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<button className="fab-quickstats" onClick={() => setOpen(true)} title="Quick Stats" aria-label="Open quick stats">
|
||||
⚡
|
||||
</button>
|
||||
{open && <QuickStatsDrawer characterId={characterId} onClose={() => setOpen(false)} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function QuickStatsDrawer({ characterId, onClose }: { characterId: string; onClose: () => void }) {
|
||||
const { data, isLoading, error } = useQuickStats(characterId, true);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="drawer-backdrop" onClick={onClose} />
|
||||
<div className="drawer">
|
||||
<div className="flex-between">
|
||||
<h2 style={{ margin: 0 }}>Quick Stats</h2>
|
||||
<button className="btn btn-ghost" onClick={onClose}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
{isLoading && <Spinner label="Reading the sheet…" />}
|
||||
{error && <ErrorBanner message="Could not load quick stats." />}
|
||||
{data && (
|
||||
<div className="mt-md">
|
||||
<h3 style={{ margin: 0 }}>{data.name}</h3>
|
||||
<div className="grid grid-cols-3 mt-sm">
|
||||
<div className="stat-block">
|
||||
<span className="stat-label">HP</span>
|
||||
<span className="stat-value">
|
||||
{data.currentHp}/{data.maxHp}
|
||||
</span>
|
||||
{data.tempHp > 0 && <span className="stat-sub">+{data.tempHp} temp</span>}
|
||||
</div>
|
||||
<div className="stat-block">
|
||||
<span className="stat-label">AC</span>
|
||||
<span className="stat-value">{data.armorClass}</span>
|
||||
</div>
|
||||
<div className="stat-block">
|
||||
<span className="stat-label">Initiative</span>
|
||||
<span className="stat-value">{fmtMod(data.initiative)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<HpBar current={data.currentHp} max={data.maxHp} temp={data.tempHp} />
|
||||
{/* Read-only here; the saves are rolled on the sheet or in the encounter. */}
|
||||
<DeathSaves characterId={characterId} name={data.name} deathSaves={data.deathSaves} canAct={false} isDM={false} />
|
||||
|
||||
{data.spellcasting && (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Spellcasting</div>
|
||||
<p style={{ margin: 0 }}>
|
||||
Save DC {data.spellcasting.saveDC} · Attack {fmtMod(data.spellcasting.attackBonus)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Weapons</div>
|
||||
{data.weapons.length === 0 && <p style={{ color: 'var(--text-muted)', margin: 0 }}>No weapons equipped.</p>}
|
||||
{data.weapons.map((w) => (
|
||||
<div key={w.characterWeaponId} className="flex-between mt-sm">
|
||||
<div>
|
||||
<strong>{w.name}</strong>
|
||||
{w.equipped && <span className="badge" style={{ marginLeft: 6 }}>equipped</span>}
|
||||
<p style={{ margin: 0, fontSize: '0.85rem', color: 'var(--text-muted)' }}>
|
||||
Lv {w.level} · {w.damageDice} {w.damageType} {fmtMod(w.damageBonus)}
|
||||
</p>
|
||||
</div>
|
||||
<span className="stat-value" style={{ fontSize: '1.1rem' }}>
|
||||
{fmtMod(w.attackBonus)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{data.specialAbilities && (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">Special Abilities</div>
|
||||
<p style={{ margin: 0, whiteSpace: 'pre-wrap' }}>{data.specialAbilities}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1705,3 +1705,51 @@ textarea {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* "This one is yours": a player's own character, wherever it is listed */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
.badge-mine {
|
||||
border-color: var(--arcane-strong);
|
||||
color: var(--arcane-strong);
|
||||
background: rgba(92, 127, 176, 0.18);
|
||||
}
|
||||
.mine-marker {
|
||||
color: var(--arcane-strong);
|
||||
font-family: var(--font-display);
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
.combatant.is-mine {
|
||||
border-color: var(--arcane-strong);
|
||||
background: linear-gradient(160deg, #1d2431 0%, var(--bg-elevated) 100%);
|
||||
box-shadow: 0 0 0 1px var(--arcane-strong), 0 0 20px rgba(127, 163, 214, 0.22), var(--shadow-deep);
|
||||
}
|
||||
/* Whose turn it is and who is targeted still win the border. */
|
||||
.combatant.is-mine.is-active {
|
||||
border-color: var(--accent-strong);
|
||||
box-shadow: 0 0 0 1px var(--accent-strong), 0 0 22px rgba(201, 162, 39, 0.25), var(--shadow-deep);
|
||||
}
|
||||
.combatant.is-mine.is-targeted {
|
||||
border-color: var(--danger-strong);
|
||||
box-shadow: 0 0 0 1px var(--danger-strong), 0 0 22px rgba(216, 84, 84, 0.3), var(--shadow-deep);
|
||||
}
|
||||
.jump-link.is-mine {
|
||||
border-color: var(--arcane-strong);
|
||||
color: var(--arcane-strong);
|
||||
background: rgba(92, 127, 176, 0.18);
|
||||
}
|
||||
table.data-table tbody tr.is-mine,
|
||||
table.data-table tbody tr.is-mine:hover {
|
||||
background: rgba(92, 127, 176, 0.16);
|
||||
box-shadow: inset 4px 0 0 var(--arcane-strong);
|
||||
}
|
||||
|
||||
/* A bonus from gear reads green; a penalty keeps the red of a condition. */
|
||||
.condition-chip.is-bonus {
|
||||
border-color: var(--success);
|
||||
color: var(--success-strong);
|
||||
background: rgba(95, 138, 79, 0.18);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useSyncExternalStore } from 'react';
|
||||
|
||||
// Which character the floating character panel is showing, if it is open.
|
||||
// Kept outside React so that any page — an encounter card, say — can open the
|
||||
// panel for a particular character without being wired to the layout.
|
||||
let openId: string | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function set(id: string | null) {
|
||||
openId = id;
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void) {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
}
|
||||
|
||||
export function openCharacterPanel(characterId: string) {
|
||||
set(characterId);
|
||||
}
|
||||
|
||||
export function closeCharacterPanel() {
|
||||
set(null);
|
||||
}
|
||||
|
||||
export function useCharacterPanelId(): string | null {
|
||||
return useSyncExternalStore(subscribe, () => openId);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { ABILITY_LABELS, SKILL_LABELS, fmtMod } from './format';
|
||||
import type { GearEffect } from '../api/types';
|
||||
|
||||
// What a weapon or item can change on the sheet of whoever has it equipped.
|
||||
// Mirrors GEAR_STATS in backend/src/game/calculations.js; the server is what
|
||||
// applies them, this is only for naming them and offering them in a form.
|
||||
const ABILITIES = Object.keys(ABILITY_LABELS);
|
||||
const SKILLS = Object.keys(SKILL_LABELS);
|
||||
|
||||
export const GEAR_STAT_GROUPS: { label: string; stats: string[] }[] = [
|
||||
{ label: 'Combat', stats: ['AC', 'SPEED', 'INITIATIVE', 'MAX_HP', 'PASSIVE_PERCEPTION'] },
|
||||
{ label: 'Ability scores', stats: ABILITIES },
|
||||
{ label: 'Saving throws', stats: ['SAVES', ...ABILITIES.map((a) => `SAVE_${a}`)] },
|
||||
{ label: 'Skills', stats: ['SKILLS', ...SKILLS.map((s) => `SKILL_${s}`)] },
|
||||
];
|
||||
|
||||
const FIXED_LABELS: Record<string, string> = {
|
||||
AC: 'AC',
|
||||
SPEED: 'Speed',
|
||||
INITIATIVE: 'Initiative',
|
||||
MAX_HP: 'Max HP',
|
||||
PASSIVE_PERCEPTION: 'Passive Perception',
|
||||
SAVES: 'All saving throws',
|
||||
SKILLS: 'All skill checks',
|
||||
};
|
||||
|
||||
export function gearStatLabel(stat: string): string {
|
||||
if (FIXED_LABELS[stat]) return FIXED_LABELS[stat];
|
||||
if (stat.startsWith('SAVE_')) return `${ABILITY_LABELS[stat.slice(5)] ?? stat} saves`;
|
||||
if (stat.startsWith('SKILL_')) return SKILL_LABELS[stat.slice(6)] ?? stat;
|
||||
return ABILITY_LABELS[stat] ?? stat;
|
||||
}
|
||||
|
||||
// "+6 AC", "−10 Speed".
|
||||
export function effectLabel(effect: GearEffect): string {
|
||||
return `${fmtMod(effect.amount).replace('-', '−')} ${gearStatLabel(effect.stat)}`;
|
||||
}
|
||||
|
||||
// "+6 AC · −10 Speed · Disadvantage on Stealth", or null when it does nothing.
|
||||
export function effectsSummary(effects: GearEffect[] | undefined, note?: string | null): string | null {
|
||||
const parts = [...(effects ?? []).map(effectLabel), ...(note ? [note] : [])];
|
||||
return parts.length ? parts.join(' · ') : null;
|
||||
}
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user