Initial commit with existing project files

This commit is contained in:
ChaoticByte 2025-08-06 10:22:38 +02:00
commit 0a39a7772a
No known key found for this signature in database
62 changed files with 1415 additions and 0 deletions

33
src/global/SaveManager.gd Normal file
View file

@ -0,0 +1,33 @@
extends Node
const SAVEFILE = "user://save.dat"
func _ready() -> void:
load_game()
func save_game():
var data: Dictionary = {
"player_xp": XpLevelManager.player_xp,
"phrases": PhrasesManager.phrases,
"last_played_phrases": CoreGameplayManager.last_played_phrases
}
var data_json = JSON.stringify(data)
var f = FileAccess.open(SAVEFILE, FileAccess.WRITE)
f.store_string(data_json)
f.close()
func load_game():
if FileAccess.file_exists(SAVEFILE):
var data_json = FileAccess.get_file_as_string(SAVEFILE)
var data = JSON.parse_string(data_json)
# set variables
if "player_xp" in data:
XpLevelManager.loading = true
XpLevelManager.player_xp = data["player_xp"]
XpLevelManager.loading = false
if "phrases" in data and data["phrases"] is Array:
PhrasesManager.phrases = []
for p in data["phrases"]:
PhrasesManager.phrases.append(p)
if "last_played_phrases" in data and data["last_played_phrases"] is Dictionary:
CoreGameplayManager.last_played_phrases = data["last_played_phrases"]