Implement the 013-hp-status-indicators feature that adds visual HP status indicators to combatant rows with a pure domain function deriving bloodied/unconscious states
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
11
packages/domain/src/hp-status.ts
Normal file
11
packages/domain/src/hp-status.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export type HpStatus = "healthy" | "bloodied" | "unconscious";
|
||||
|
||||
export function deriveHpStatus(
|
||||
currentHp: number | undefined,
|
||||
maxHp: number | undefined,
|
||||
): HpStatus | undefined {
|
||||
if (currentHp === undefined || maxHp === undefined) return undefined;
|
||||
if (currentHp <= 0) return "unconscious";
|
||||
if (currentHp < maxHp / 2) return "bloodied";
|
||||
return "healthy";
|
||||
}
|
||||
Reference in New Issue
Block a user