12 lines
364 B
TypeScript
12 lines
364 B
TypeScript
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";
|
|
}
|