Enforce maximum values for PF2e numbered conditions

Cap dying (4), doomed (3), wounded (3), and slowed (3) at their
rule-defined maximums. The domain clamps values in setConditionValue
and the condition picker disables the [+] button at the cap.

Closes #31

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-09 00:04:47 +02:00
parent 1c107a500b
commit 553e09f280
5 changed files with 120 additions and 20 deletions

View File

@@ -162,20 +162,35 @@ export function ConditionPicker({
<span className="min-w-5 rounded-full bg-accent px-1.5 py-0.5 text-center font-medium text-primary-foreground text-xs">
{editing.value}
</span>
<button
type="button"
className="rounded p-0.5 text-foreground hover:bg-accent/40"
onMouseDown={(e) => e.preventDefault()}
onClick={(e) => {
e.stopPropagation();
setEditing({
...editing,
value: editing.value + 1,
});
}}
>
<Plus className="h-3 w-3" />
</button>
{(() => {
const atMax =
def.maxValue !== undefined &&
editing.value >= def.maxValue;
return (
<button
type="button"
className={cn(
"rounded p-0.5",
atMax
? "cursor-not-allowed text-muted-foreground opacity-50"
: "text-foreground hover:bg-accent/40",
)}
disabled={atMax}
onMouseDown={(e) => e.preventDefault()}
onClick={(e) => {
e.stopPropagation();
if (!atMax) {
setEditing({
...editing,
value: editing.value + 1,
});
}
}}
>
<Plus className="h-3 w-3" />
</button>
);
})()}
<button
type="button"
className="ml-0.5 rounded p-0.5 text-foreground hover:bg-accent/40"