Save the quiz and continue it after a restart; load characters from a folder
Build / test (push) Successful in 1m25s
Build / build (push) Successful in 1m12s

The quiz is saved to current_quiz.json in the config folder after every
change, and the game goes on where it was when it starts again: the
players with their points and characters, every song with who got a point
for it and whether it was played, answered or is playing, and the songs
downloaded ahead with their files. The song that was playing is ready to
play again. Songs whose files are gone are downloaded again.

On a server, the saved songs are checked against the server's playlist. If
it changed, e.g. after a sync, or another server is used, the quiz starts
over with the same players. A quiz from a music folder continues offline,
including how far a prepared quiz has come. A new game is saved like any
other change, and a file that can't be read starts a new quiz.

Characters can be read from a folder picked in Settings instead of the
server, for this session. A music folder with a characters folder brings
its own characters, e.g. for a themed quiz; that folder is not counted as
a soundtrack. When the characters come from somewhere else, players pick
their characters again.

Closes #11, closes #44
This commit is contained in:
Sansan committed 2026-10-09 18:08:50 +02:00
1 parent 4a934840f6
commit e4352a9f34
33 files changed
+2886 -499

No files matched your search

+24
View File
@@ -83,3 +83,27 @@ func test_song_stays_in_memory_when_it_cannot_be_saved() -> void:
assert_str(song_object.song_path).is_empty()
assert_object(Playlist.get_song(0)).is_instanceof(AudioStreamMP3)
func test_new_songs_never_write_over_files_kept_from_a_saved_quiz() -> void:
var kept: SongObject = _add_song()
var kept_bytes: PackedByteArray = FileAccess.get_file_as_bytes(kept.song_path)
# As after a restart: the count of files written starts over
Playlist._song_files_written = 0
var new_song: SongObject = _add_song()
assert_str(new_song.song_path).is_not_equal(kept.song_path)
assert_array(FileAccess.get_file_as_bytes(kept.song_path)).is_equal(kept_bytes)
assert_array(DirAccess.get_files_at(Playlist.songs_folder())).has_size(2)
func test_clearing_can_keep_the_files_a_saved_quiz_uses() -> void:
var kept: SongObject = _add_song()
var dropped: SongObject = _add_song()
Playlist.clear_song_files(PackedStringArray([kept.song_path]))
assert_bool(FileAccess.file_exists(kept.song_path)).is_true()
assert_bool(FileAccess.file_exists(dropped.song_path)).is_false()