Skip to content

Commit

Permalink
Fix rotation after reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
RheingoldRiver committed Oct 29, 2023
1 parent 7aa436e commit 6445365
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/GameStateProvider/currentPentominoReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const orientationReducer: Reducer<Orientation, OrientationAction> = (
case OrientationActionType.reflect:
return produce(currentOrientation, (o: Orientation) => {
o.reflection = (o.reflection + 1) % 2;
if (o.rotation % 2 === 1) o.rotation = (o.rotation + 2) % 4;
const direction = action.direction === ReflectionDirection.Y ? 0 : 1;
if (o.rotation % 2 === direction) o.rotation = (o.rotation + 2) % 4;
});
case OrientationActionType.replace:
return action.newOrientation ? { ...action.newOrientation } : { rotation: 0, reflection: 0 };
Expand Down

0 comments on commit 6445365

Please sign in to comment.