Implement the 016-combatant-ac feature that adds an optional Armor Class field to combatants with shield icon display and inline editing in the encounter tracker

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-06 10:41:56 +01:00
parent 2793a66672
commit 78c6591973
20 changed files with 914 additions and 4 deletions

View File

@@ -48,6 +48,13 @@ export function loadEncounter(): Encounter | null {
typeof entry.initiative === "number" ? entry.initiative : undefined,
};
// Validate AC field
const ac = entry.ac;
const validAc =
typeof ac === "number" && Number.isInteger(ac) && ac >= 0
? ac
: undefined;
// Validate and attach HP fields if valid
const maxHp = entry.maxHp;
const currentHp = entry.currentHp;
@@ -59,12 +66,13 @@ export function loadEncounter(): Encounter | null {
currentHp <= maxHp;
return {
...base,
ac: validAc,
maxHp,
currentHp: validCurrentHp ? currentHp : maxHp,
};
}
return base;
return { ...base, ac: validAc };
});
const result = createEncounter(