Save the quiz that is going on to a file, so it can be continued if the game is closed or crashes.
What is saved
Players. Name, UUID (PlayerObject.id), score, whether they got their first point, and their character by name.
Songs.
Every song in the playlist, from SongObject: number, title, soundtrack, path or server song number, players_given_point, is_answered, has_played.
The playlist positions: latest_played_song, currently_playing_song, game_start_song.
Statistics pause. Whether statistics are paused by a win (stats_paused_by_win).
Music source.
Server mode: which server, so it isn't resumed against another one.
Offline mode: the music folder path, and for a prepared quiz its play order and how far it has come (MusicFolder._quiz_queue/_quiz_next).
When
Saved after every change: point given or taken, song played, Show answer, player added, removed or renamed, character picked.
Writing a small JSON file is cheap. Write to a temp file, then rename, so a crash never leaves half a file.
Deleted or reset when a new game starts: Reset points, after a sync, and on server or music folder change. The same moments the server's play queue is reset (Quiz.reset_points, on_sync_finished, on_server_changed).
Where
Settings.config_dir()/current_quiz.json (current_quiz_debug.json in debug mode, like the settings).
Plan
New class data/quiz_save.gd.save(), load() -> bool, clear(), plus to_dict()/from_dict() on PlayerObject and SongObject.
Saving.Quiz calls QuizSave.save() from the places listed above. A single "quiz changed" signal could trigger it, so nothing is forgotten.
Characters.
Players only keep a Texture now, so add character_name to PlayerObject, set in _on_new_character_selected.
On load, get the picture from CharacterCache, or from the local character folder (see #44).
Song files.
Playlist._ready() empties the songs folder at startup (clear_song_files()), so saved song files would be gone. Only clear it when there is no saved quiz.
Songs whose file is missing are downloaded again by number.
Server queue.
The server's play queue survives a restart (Settings.queue_ids). Check that resuming doesn't call reset_playlist, so the server's queue and "played" state stay in step.
Songs already marked played are not marked again.
Startup.
When a saved quiz exists, ask "Continue the last quiz? (n players, n songs played)", with Continue and New game.
Or always continue silently. See the question below.
Tests
to_dict/from_dict round trips.
Save, then load into a fresh MainWindowTestSuite → same players, scores, points per song, answered and played flags.
Reset points, a sync, or a server change deletes the save.
A broken or old file is ignored, not a crash.
Questions
Ask on startup, or always continue?
Should the queue of preloaded songs not yet played also be kept, or just downloaded again?
Save the quiz that is going on to a file, so it can be continued if the game is closed or crashes.
## What is saved
- **Players.** Name, UUID (`PlayerObject.id`), score, whether they got their first point, and their character by name.
- **Songs.**
- Every song in the playlist, from `SongObject`: number, title, soundtrack, path or server song number, `players_given_point`, `is_answered`, `has_played`.
- The playlist positions: `latest_played_song`, `currently_playing_song`, `game_start_song`.
- **Statistics pause.** Whether statistics are paused by a win (`stats_paused_by_win`).
- **Music source.**
- Server mode: which server, so it isn't resumed against another one.
- Offline mode: the music folder path, and for a prepared quiz its play order and how far it has come (`MusicFolder._quiz_queue`/`_quiz_next`).
## When
- Saved after every change: point given or taken, song played, Show answer, player added, removed or renamed, character picked.
- Writing a small JSON file is cheap. Write to a temp file, then rename, so a crash never leaves half a file.
- Deleted or reset when a new game starts: Reset points, after a sync, and on server or music folder change. The same moments the server's play queue is reset (`Quiz.reset_points`, `on_sync_finished`, `on_server_changed`).
## Where
- `Settings.config_dir()/current_quiz.json` (`current_quiz_debug.json` in debug mode, like the settings).
## Plan
- **New class `data/quiz_save.gd`.** `save()`, `load() -> bool`, `clear()`, plus `to_dict()`/`from_dict()` on `PlayerObject` and `SongObject`.
- **Saving.** `Quiz` calls `QuizSave.save()` from the places listed above. A single "quiz changed" signal could trigger it, so nothing is forgotten.
- **Characters.**
- Players only keep a `Texture` now, so add `character_name` to `PlayerObject`, set in `_on_new_character_selected`.
- On load, get the picture from `CharacterCache`, or from the local character folder (see #44).
- **Song files.**
- `Playlist._ready()` empties the songs folder at startup (`clear_song_files()`), so saved song files would be gone. Only clear it when there is no saved quiz.
- Songs whose file is missing are downloaded again by number.
- **Server queue.**
- The server's play queue survives a restart (`Settings.queue_ids`). Check that resuming doesn't call `reset_playlist`, so the server's queue and "played" state stay in step.
- Songs already marked played are not marked again.
- **Startup.**
- When a saved quiz exists, ask "Continue the last quiz? (n players, n songs played)", with Continue and New game.
- Or always continue silently. See the question below.
## Tests
- `to_dict`/`from_dict` round trips.
- Save, then load into a fresh `MainWindowTestSuite` → same players, scores, points per song, answered and played flags.
- Reset points, a sync, or a server change deletes the save.
- A broken or old file is ignored, not a crash.
## Questions
- Ask on startup, or always continue?
- Should the queue of preloaded songs not yet played also be kept, or just downloaded again?
Sansan
changed title from Add functionallity to save current game and continue to Save the current quiz locally and continue it after a restart2026-10-09 16:06:02 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Save the quiz that is going on to a file, so it can be continued if the game is closed or crashes.
What is saved
PlayerObject.id), score, whether they got their first point, and their character by name.SongObject: number, title, soundtrack, path or server song number,players_given_point,is_answered,has_played.latest_played_song,currently_playing_song,game_start_song.stats_paused_by_win).MusicFolder._quiz_queue/_quiz_next).When
Quiz.reset_points,on_sync_finished,on_server_changed).Where
Settings.config_dir()/current_quiz.json(current_quiz_debug.jsonin debug mode, like the settings).Plan
data/quiz_save.gd.save(),load() -> bool,clear(), plusto_dict()/from_dict()onPlayerObjectandSongObject.QuizcallsQuizSave.save()from the places listed above. A single "quiz changed" signal could trigger it, so nothing is forgotten.Texturenow, so addcharacter_nametoPlayerObject, set in_on_new_character_selected.CharacterCache, or from the local character folder (see #44).Playlist._ready()empties the songs folder at startup (clear_song_files()), so saved song files would be gone. Only clear it when there is no saved quiz.Settings.queue_ids). Check that resuming doesn't callreset_playlist, so the server's queue and "played" state stay in step.Tests
to_dict/from_dictround trips.MainWindowTestSuite→ same players, scores, points per song, answered and played flags.Questions
Add functionallity to save current game and continueto Save the current quiz locally and continue it after a restartDone in
e4352a9on develop. The quiz always continues at startup, and songs downloaded ahead are kept with their files.