2024-02-22 06:22:22 +11:00
|
|
|
class_name SaveStats extends Resource
|
2023-12-17 02:02:16 +11:00
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
const SAVE_PATH: String = "user://save_stats.tres"
|
2023-12-17 02:02:16 +11:00
|
|
|
|
|
|
|
@export var wins: int
|
|
|
|
@export var losses: int
|
|
|
|
@export var twenty_game_history: Array[bool]
|
|
|
|
|
|
|
|
|
|
|
|
func add_game_outcome(outcome: bool) -> void:
|
|
|
|
if outcome:
|
|
|
|
wins += 1
|
|
|
|
else:
|
|
|
|
losses += 1
|
|
|
|
twenty_game_history.push_back(outcome)
|
|
|
|
if twenty_game_history.size() > 20:
|
|
|
|
twenty_game_history.pop_front()
|
|
|
|
|
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
func save_profile_to_disk() -> void:
|
2023-12-17 02:02:16 +11:00
|
|
|
ResourceSaver.save(self, SAVE_PATH)
|
|
|
|
static func load_profile_from_disk() -> SaveStats:
|
|
|
|
if ResourceLoader.exists(SAVE_PATH):
|
|
|
|
return ResourceLoader.load(SAVE_PATH)
|
|
|
|
return SaveStats.new()
|