From 6ae5e3afdf0bf12e6149dd44a625718c6ae21ce3 Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Sat, 7 Oct 2023 01:19:32 -0400 Subject: [PATCH] initialize before new length check fixes #9 related to #1 as we were seeing a thrown-away grid compared to saved --- src/lib/puzzle/grids/penrosegrid.js | 1 - src/lib/puzzleWrapper/PuzzleInstanceWrapper.svelte | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/puzzle/grids/penrosegrid.js b/src/lib/puzzle/grids/penrosegrid.js index bdd00a05..73e52d0e 100644 --- a/src/lib/puzzle/grids/penrosegrid.js +++ b/src/lib/puzzle/grids/penrosegrid.js @@ -250,7 +250,6 @@ export class PenroseGrid extends AbstractGrid { } else { path = points.map((p, i) => `L ${p.x} ${p.y}`).join(' '); } - console.log('gpp', path); return path; }) ] diff --git a/src/lib/puzzleWrapper/PuzzleInstanceWrapper.svelte b/src/lib/puzzleWrapper/PuzzleInstanceWrapper.svelte index 2a5a9fa6..1be12fed 100644 --- a/src/lib/puzzleWrapper/PuzzleInstanceWrapper.svelte +++ b/src/lib/puzzleWrapper/PuzzleInstanceWrapper.svelte @@ -146,12 +146,12 @@ if (instance !== null) { let gridState; ({ grid: gridState, tiles } = JSON.parse(instance)); + if (grid.initialize) grid.initialize(gridState); // if the grid was refactored and handles size differently // then ignore the previously saved instance if (tiles.length !== grid.total) { tiles = []; } - if (grid.initialize) grid.initialize(gridState); } } solved = false;