import { useState } from 'react'; import { useDeathSave } from '../api/queries'; import { InfoTip } from './InfoTip'; import { NumberInput } from './NumberInput'; import type { DeathSaves as DeathSavesInfo } from '../api/types'; const STATE_LABELS = { DYING: 'Dying', STABLE: 'Stable', DEAD: '☠ Dead' } as const; // Nothing for a character on their feet; otherwise where they stand at 0 HP. export function LifeBadge({ deathSaves }: { deathSaves: DeathSavesInfo }) { if (deathSaves.state === 'UP') return null; return {STATE_LABELS[deathSaves.state]}; } // Three pips for one tally. For the DM each is a button: clicking a pip sets // the tally to it, and clicking the last filled one takes it back off. function Pips({ kind, count, onSet }: { kind: 'success' | 'failure'; count: number; onSet?: (count: number) => void }) { const noun = kind === 'success' ? 'successes' : 'failures'; return ( {[1, 2, 3].map((n) => { const className = `death-pip is-${kind}${n <= count ? ' is-filled' : ''}`; return onSet ? ( )} {state === 'DEAD' && isDM && ( )} ); }