diff --git a/hera/ui/GameActions.tsx b/hera/ui/GameActions.tsx index ce93c07..b53b37e 100644 --- a/hera/ui/GameActions.tsx +++ b/hera/ui/GameActions.tsx @@ -478,9 +478,10 @@ export default function GameActions({ inset?: number; setZoom?: SetZoomFn; subscribe?: (map: MapData) => Promise; - undoTurn?: () => void | Promise; + undoTurn?: (onCancel: () => void) => void | Promise; zoom: number; }) { + const { update } = actions; const { currentViewer, inlineUI, @@ -499,6 +500,7 @@ export default function GameActions({ currentViewer != null ? map.maybeGetPlayer(currentViewer) : null; const canUndo = undoTurn && + !hasEnded && viewerPlayer?.isHumanPlayer() && viewerPlayer.crystal == null && playerCanEndTurn && @@ -508,10 +510,10 @@ export default function GameActions({ const undo = useCallback(() => { if (canUndo && undoTurn) { AudioPlayer.playSound('UI/Accept'); - actions.update(resetBehavior(NullBehavior)); - undoTurn(); + update(resetBehavior(NullBehavior)); + undoTurn(() => update(resetBehavior())); } - }, [actions, canUndo, undoTurn]); + }, [canUndo, undoTurn, update]); useInput('undo', undo); const replayBar = !hasEnded && (