diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index bf41c2c..ef5c039 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -117,6 +117,7 @@ export function App() { const sidePanel = useSidePanelState(); const [rollSkippedCount, setRollSkippedCount] = useState(0); + const [rollSingleSkipped, setRollSingleSkipped] = useState(false); const selectedCreature: Creature | null = sidePanel.selectedCreatureId ? (getCreature(sidePanel.selectedCreatureId) ?? null) @@ -145,9 +146,21 @@ export function App() { const handleRollInitiative = useCallback( (id: CombatantId) => { - rollInitiativeUseCase(makeStore(), id, rollDice(), getCreature); + const result = rollInitiativeUseCase( + makeStore(), + id, + rollDice(), + getCreature, + ); + if (isDomainError(result)) { + setRollSingleSkipped(true); + const combatant = encounter.combatants.find((c) => c.id === id); + if (combatant?.creatureId) { + sidePanel.showCreature(combatant.creatureId); + } + } }, - [makeStore, getCreature], + [makeStore, getCreature, encounter.combatants, sidePanel.showCreature], ); const handleRollAllInitiative = useCallback(() => { @@ -363,6 +376,14 @@ export function App() { /> )} + {!!rollSingleSkipped && ( + setRollSingleSkipped(false)} + autoDismissMs={4000} + /> + )} +