Overhaul savegame.json format #86

Closed
opened 2023-02-19 02:04:03 +00:00 by kirsle · 1 comment

The current savegame.json format (example below) is jank:

  • It is too verbose.
  • It depends on the file names of LevelPacks + the names of the levels inside.
  • It will cause issues if levelpacks or levels ever get renamed.

How the savegame.json currently looks:

{
  "levelPacks": {
    "001000-TUTORIAL.levelpack": {
      "levels": {
        "Tutorial 3.level": {
          "completed": true,
          "bestTime": null,
          "perfectTime": 81905972479
        },
        "Tutorial 4.level": {
          "completed": true,
          "bestTime": null,
          "perfectTime": 31348084356
        }
      }
    },
    "AzulianTag.levelpack": {
      "levels": {
        "AzulianTag-Forest.level": {
          "completed": true,
          "bestTime": 74136000489,
          "perfectTime": 87249081310
        },
        "AzulianTag-Night.level": {
          "completed": true,
          "bestTime": 37335603926,
          "perfectTime": 111194718913
        }
      }
    }
  }
}

It could be improved by:

  • Giving every level a unique UUID identifier.
  • Only storing scores by level UUID instead of by levelpack/file name.

Then if built-in levels are rearranged and put into different levelpacks, the player still retains their high score data. Makes it less brittle to levelpack file names too.

The transition as always can be done gracefully:

  • Create new json keys for the new syntax.
  • On next save, convert old format into the new format.
The current savegame.json format (example below) is jank: * It is too verbose. * It depends on the file names of LevelPacks + the names of the levels inside. * It will cause issues if levelpacks or levels ever get renamed. How the savegame.json currently looks: ```json { "levelPacks": { "001000-TUTORIAL.levelpack": { "levels": { "Tutorial 3.level": { "completed": true, "bestTime": null, "perfectTime": 81905972479 }, "Tutorial 4.level": { "completed": true, "bestTime": null, "perfectTime": 31348084356 } } }, "AzulianTag.levelpack": { "levels": { "AzulianTag-Forest.level": { "completed": true, "bestTime": 74136000489, "perfectTime": 87249081310 }, "AzulianTag-Night.level": { "completed": true, "bestTime": 37335603926, "perfectTime": 111194718913 } } } } } ``` It could be improved by: * Giving every level a unique UUID identifier. * Only storing scores by level UUID instead of by levelpack/file name. Then if built-in levels are rearranged and put into different levelpacks, the player still retains their high score data. Makes it less brittle to levelpack file names too. The transition as always can be done gracefully: * Create new json keys for the new syntax. * On next save, convert old format into the new format.
kirsle added the
enhancement
label 2023-02-19 02:04:10 +00:00
Poster
Owner

Implemented in cf1bc81f25 - see commit for notes.

Implemented in cf1bc81f2544bc8ec693bdafb777b2a3b6590113 - see commit for notes.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#86
There is no content yet.