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
+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>