Tales-of-PKMN/scripts/game_data.gd
2026-10-04 13:59:28 +02:00

18 lines
717 B
GDScript

extends Node
# Autoload : GameData
var story_progress : int = 0 # 0 = début, 1 = après 1er badge, 2 = après 2e badge, etc.
var player_team : PokemonTeam = PokemonTeam.new()
func save() -> void:
var config := ConfigFile.new()
config.set_value("progress", "story_progress", story_progress)
config.set_value("team", "data", player_team.to_dict())
config.save("user://save.cfg")
func load_data() -> void:
var config := ConfigFile.new()
if config.load("user://save.cfg") == OK:
story_progress = config.get_value("progress", "story_progress", 0)
var team_data : Variant = config.get_value("team", "data", {})
player_team = PokemonTeam.from_dict(team_data) if team_data is Dictionary else PokemonTeam.new()