Implement the 017-combat-conditions feature that adds D&D 5e status conditions to combatants with icon tags, color coding, and a compact toggle picker in the encounter tracker
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import {
|
||||
type ConditionId,
|
||||
combatantId,
|
||||
createEncounter,
|
||||
type Encounter,
|
||||
isDomainError,
|
||||
VALID_CONDITION_IDS,
|
||||
} from "@initiative/domain";
|
||||
|
||||
const STORAGE_KEY = "initiative:encounter";
|
||||
@@ -55,6 +57,21 @@ export function loadEncounter(): Encounter | null {
|
||||
? ac
|
||||
: undefined;
|
||||
|
||||
// Validate conditions field
|
||||
const rawConditions = entry.conditions;
|
||||
const validConditions: ConditionId[] | undefined = Array.isArray(
|
||||
rawConditions,
|
||||
)
|
||||
? (rawConditions.filter(
|
||||
(v): v is ConditionId =>
|
||||
typeof v === "string" && VALID_CONDITION_IDS.has(v),
|
||||
) as ConditionId[])
|
||||
: undefined;
|
||||
const conditions =
|
||||
validConditions && validConditions.length > 0
|
||||
? validConditions
|
||||
: undefined;
|
||||
|
||||
// Validate and attach HP fields if valid
|
||||
const maxHp = entry.maxHp;
|
||||
const currentHp = entry.currentHp;
|
||||
@@ -67,12 +84,13 @@ export function loadEncounter(): Encounter | null {
|
||||
return {
|
||||
...base,
|
||||
ac: validAc,
|
||||
conditions,
|
||||
maxHp,
|
||||
currentHp: validCurrentHp ? currentHp : maxHp,
|
||||
};
|
||||
}
|
||||
|
||||
return { ...base, ac: validAc };
|
||||
return { ...base, ac: validAc, conditions };
|
||||
});
|
||||
|
||||
const result = createEncounter(
|
||||
|
||||
Reference in New Issue
Block a user