diff --git a/client/src/PuzzleSet.lua b/client/src/PuzzleSet.lua index b6a3d85e..c04336e2 100644 --- a/client/src/PuzzleSet.lua +++ b/client/src/PuzzleSet.lua @@ -484,7 +484,8 @@ function PuzzleSet:saveTargetPuzzleToFile(targetPuzzleSet, puzzleIndex, updatedP -- Find and update the specific puzzle within the JSON data structure local updated = self:updatePuzzleInFileData(originalData, targetPuzzleSet, puzzleIndex, updatedPuzzle) if not updated then - error("Cannot save puzzle: target puzzle set not found in file or puzzle index out of range") + logger.warn("Cannot save solution to old puzzle format, please upgrade your puzzles to the latest file format") + return -- Early return, this is likely an old puzzle format. end -- Extract directory and filename from fileSource path diff --git a/common/tests/data/puzzles_v1_format.json b/common/tests/data/puzzles_v1_format.json new file mode 100644 index 00000000..d0a1d944 --- /dev/null +++ b/common/tests/data/puzzles_v1_format.json @@ -0,0 +1,11 @@ +{ + "Classic Puzzles": [ + ["010110", 1], + ["020220", 2], + ["030330", 3] + ], + "Advanced Puzzles": [ + ["111222333444555666", 5], + ["654321654321654321", 7] + ] +} diff --git a/common/tests/data/puzzles_v2_format.json b/common/tests/data/puzzles_v2_format.json new file mode 100644 index 00000000..2f02a56f --- /dev/null +++ b/common/tests/data/puzzles_v2_format.json @@ -0,0 +1,51 @@ +{ + "Version": 2, + "Puzzle Sets": [ + { + "Set Name": "Classic Puzzles", + "Puzzles": [ + { + "Puzzle Type": "moves", + "Do Countdown": false, + "Moves": 1, + "Stack": "010110" + }, + { + "Puzzle Type": "moves", + "Do Countdown": false, + "Moves": 2, + "Stack": "020220" + }, + { + "Puzzle Type": "moves", + "Do Countdown": true, + "Moves": 3, + "Stack": "030330", + "Stop": 60, + "Shake": 30 + } + ] + }, + { + "Set Name": "Advanced Puzzles", + "Puzzles": [ + { + "Puzzle Type": "clear", + "Do Countdown": false, + "Moves": 0, + "Stack": "111222333444555666", + "Stop": 120, + "Shake": 0 + }, + { + "Puzzle Type": "chain", + "Do Countdown": true, + "Moves": 0, + "Stack": "654321654321654321", + "Stop": null, + "Shake": null + } + ] + } + ] +}