import clsx from "clsx"; import { FC, HTMLAttributes } from "react"; import { Constants } from "@dndbeyond/character-rules-engine"; import { useCharacterEngine } from "~/hooks/useCharacterEngine"; import styles from "./styles.module.css"; interface Props extends HTMLAttributes {} export const DeathSummary: FC = ({ className, onClick, ...props }) => { const { deathSaveInfo, ruleData, ruleDataUtils, deathCause, characterTheme } = useCharacterEngine(); const renderDeathSavesSummaryMarkGroup = ( key: string, label: string, activeCount: number, totalCount: number, isDarkMode: boolean ): React.ReactNode => { let marks: Array = []; for (let i = 0; i < totalCount; i++) { marks.push( ); } return (

{label}

{marks}
); }; return ( <> {/* If the death cause is exhaustion, render the exhaustion summary. Otherwise, render the death saves summary. */} {deathCause === Constants.DeathCauseEnum.CONDITION ? (

Exhaustion Level 6

Death

) : (
{renderDeathSavesSummaryMarkGroup( "fail", "Failure", deathSaveInfo.failCount, ruleDataUtils.getMaxDeathsavesFail(ruleData), characterTheme.isDarkMode )} {renderDeathSavesSummaryMarkGroup( "success", "Success", deathSaveInfo.successCount, ruleDataUtils.getMaxDeathsavesSuccess(ruleData), characterTheme.isDarkMode )}

Death Saves

)} ); };