feature/saves-and-score (#8)

Reviewed-on: #8
Co-authored-by: Vladimir nett00n Budylnikov <git@nett00n.org>
Co-committed-by: Vladimir nett00n Budylnikov <git@nett00n.org>
This commit is contained in:
2025-09-25 20:58:23 +02:00
committed by nett00n
parent ea8c85d7ad
commit ca233f4171
14 changed files with 1200 additions and 118 deletions

View File

@@ -7,12 +7,19 @@ var pending_gameplay_mode: String = "match3"
var is_changing_scene: bool = false
func start_new_game() -> void:
SaveManager.start_new_game()
start_game_with_mode("match3")
func continue_game() -> void:
# Don't reset score - just load the game scene
start_game_with_mode("match3")
func start_match3_game() -> void:
SaveManager.start_new_game()
start_game_with_mode("match3")
func start_clickomania_game() -> void:
SaveManager.start_new_game()
start_game_with_mode("clickomania")
func start_game_with_mode(gameplay_mode: String) -> void:
@@ -65,13 +72,25 @@ func start_game_with_mode(gameplay_mode: String) -> void:
if get_tree().current_scene.has_method("set_gameplay_mode"):
DebugManager.log_info("Setting gameplay mode to: %s" % pending_gameplay_mode, "GameManager")
get_tree().current_scene.set_gameplay_mode(pending_gameplay_mode)
# Load saved score
if get_tree().current_scene.has_method("set_global_score"):
var saved_score = SaveManager.get_current_score()
DebugManager.log_info("Loading saved score: %d" % saved_score, "GameManager")
get_tree().current_scene.set_global_score(saved_score)
else:
DebugManager.log_error("Game scene does not have set_gameplay_mode method", "GameManager")
is_changing_scene = false
func save_game() -> void:
DebugManager.log_info("Game saved (mock)", "GameManager")
# Get current score from the active game scene
var current_score = 0
if get_tree().current_scene and get_tree().current_scene.has_method("get_global_score"):
current_score = get_tree().current_scene.get_global_score()
SaveManager.finish_game(current_score)
DebugManager.log_info("Game saved with score: %d" % current_score, "GameManager")
func exit_to_main_menu() -> void:
# Prevent concurrent scene changes