Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/src/PuzzleSet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions common/tests/data/puzzles_v1_format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Classic Puzzles": [
["010110", 1],
["020220", 2],
["030330", 3]
],
"Advanced Puzzles": [
["111222333444555666", 5],
["654321654321654321", 7]
]
}
51 changes: 51 additions & 0 deletions common/tests/data/puzzles_v2_format.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}