Skip to content

Commit

Permalink
Reset Map behavior when canceling undo.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 18415676379e4ec33f10fc17e7fb9213d4411c1a
  • Loading branch information
cpojer committed Nov 29, 2024
1 parent 84f1fab commit 95979df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hera/ui/GameActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,10 @@ export default function GameActions({
inset?: number;
setZoom?: SetZoomFn;
subscribe?: (map: MapData) => Promise<void>;
undoTurn?: () => void | Promise<void>;
undoTurn?: (onCancel: () => void) => void | Promise<void>;
zoom: number;
}) {
const { update } = actions;
const {
currentViewer,
inlineUI,
Expand All @@ -499,6 +500,7 @@ export default function GameActions({
currentViewer != null ? map.maybeGetPlayer(currentViewer) : null;
const canUndo =
undoTurn &&
!hasEnded &&
viewerPlayer?.isHumanPlayer() &&
viewerPlayer.crystal == null &&
playerCanEndTurn &&
Expand All @@ -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 && (
Expand Down

0 comments on commit 95979df

Please sign in to comment.