diff --git a/docs/CLAUDE.md b/docs/CLAUDE.md index 930c81b..e81f810 100644 --- a/docs/CLAUDE.md +++ b/docs/CLAUDE.md @@ -110,9 +110,9 @@ Guidance for Claude Code (claude.ai/code) when working with this repository. - `src/autoloads/SaveManager.gd` - **Save system with security features** - `src/autoloads/SettingsManager.gd` - Settings management with input validation and security - `src/autoloads/DebugManager.gd` - Debug system integration -- `scenes/game/game.gd` - Main game scene with modular gameplay system +- `scenes/game/Game.gd` - Main game scene with modular gameplay system - `scenes/game/gameplays/Match3Gameplay.gd` - Match-3 implementation with input validation -- `scenes/game/gameplays/tile.gd` - Instance-based tile behavior without global state +- `scenes/game/gameplays/Tile.gd` - Instance-based tile behavior without global state - `scenes/ui/DebugMenuBase.gd` - Unified debug menu base class - `scenes/ui/SettingsMenu.gd` - Settings UI with input validation - `scenes/game/gameplays/` - Individual gameplay mode implementations diff --git a/docs/CODE_QUALITY.md b/docs/CODE_QUALITY.md index c8c0d20..1375290 100644 --- a/docs/CODE_QUALITY.md +++ b/docs/CODE_QUALITY.md @@ -31,7 +31,7 @@ for child in children_to_remove: **Files Improved:** - `scenes/game/gameplays/Match3Gameplay.gd` -- `scenes/game/gameplays/tile.gd` +- `scenes/game/gameplays/Tile.gd` ### 2. Error Handling & Recovery @@ -112,7 +112,7 @@ static func set_active_gem_pool(gem_indices: Array) -> void: ``` **Files Improved:** -- `scenes/game/gameplays/tile.gd` +- `scenes/game/gameplays/Tile.gd` - `scenes/game/gameplays/Match3Gameplay.gd` ## 🟡 Code Quality Improvements @@ -289,4 +289,4 @@ func test_volume_validation(): 3. **Event System**: Expand event-driven architecture 4. **Configuration Management**: Centralized configuration system -This document serves as the foundation for maintaining and improving code quality in the Skelly project. All new code should adhere to these standards, and existing code should be gradually updated to meet these requirements. \ No newline at end of file +This document serves as the foundation for maintaining and improving code quality in the Skelly project. All new code should adhere to these standards, and existing code should be gradually updated to meet these requirements. diff --git a/docs/MAP.md b/docs/MAP.md index 88cbc01..b28dd09 100644 --- a/docs/MAP.md +++ b/docs/MAP.md @@ -90,7 +90,7 @@ game.tscn (Gameplay Container) ``` ### Game Flow -1. **Main Scene** (`scenes/main/main.tscn` + `Main.gd`) +1. **Main Scene** (`scenes/main/Main.tscn` + `Main.gd`) - Application entry point - Manages splash screen - Transitions to main menu @@ -112,7 +112,7 @@ game.tscn (Gameplay Container) - Audio volume controls - Connected to SettingsManager and AudioManager -5. **Game Scene** (`scenes/game/game.tscn` + `game.gd`) +5. **Game Scene** (`scenes/game/Game.tscn` + `Game.gd`) - Main gameplay container with modular gameplay system - Dynamic loading of gameplay modes into GameplayContainer - Global score management and display @@ -145,7 +145,7 @@ scenes/ui/ The game now uses a modular gameplay architecture where different game modes can be dynamically loaded into the main game scene. ### Gameplay Architecture -- **Main Game Scene** (`scenes/game/game.gd`) - Container and coordinator +- **Main Game Scene** (`scenes/game/Game.gd`) - Container and coordinator - **Gameplay Directory** (`scenes/game/gameplays/`) - Individual gameplay implementations - **Dynamic Loading** - Gameplay scenes loaded at runtime based on mode selection - **Signal-based Communication** - Gameplays communicate with main scene via signals @@ -168,7 +168,7 @@ The game now uses a modular gameplay architecture where different game modes can - Smooth tile position animations with Tween - Cursor-based navigation with visual highlighting and bounds checking -2. **Tile System** (`scenes/game/gameplays/tile.gd` + `Tile.tscn`) +2. **Tile System** (`scenes/game/gameplays/Tile.gd` + `Tile.tscn`) - Tile behavior with instance-based architecture (no global state) - Gem type management with validation and bounds checking - Visual representation with scaling and color diff --git a/project.godot b/project.godot index a735df5..196bb57 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Skelly" -run/main_scene="res://scenes/main/main.tscn" +run/main_scene="res://scenes/main/Main.tscn" config/features=PackedStringArray("4.4", "Mobile") config/icon="res://icon.svg" boot_splash/handheld/orientation=0 @@ -222,6 +222,6 @@ locale/translations=PackedStringArray("res://localization/MainStrings.en.transla [rendering] textures/canvas_textures/default_texture_filter=0 -textures/vram_compression/import_etc2_astc=true renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" +textures/vram_compression/import_etc2_astc=true diff --git a/scenes/game/game.gd b/scenes/game/Game.gd similarity index 100% rename from scenes/game/game.gd rename to scenes/game/Game.gd diff --git a/scenes/game/game.tscn b/scenes/game/Game.tscn similarity index 100% rename from scenes/game/game.tscn rename to scenes/game/Game.tscn diff --git a/scenes/game/gameplays/Match3Gameplay.gd b/scenes/game/gameplays/Match3Gameplay.gd index 2f57040..15c607a 100644 --- a/scenes/game/gameplays/Match3Gameplay.gd +++ b/scenes/game/gameplays/Match3Gameplay.gd @@ -470,7 +470,7 @@ func regenerate_grid(): # More robust tile detection if child.has_method("get_script") and child.get_script(): var script_path = child.get_script().resource_path - if script_path == "res://scenes/game/gameplays/tile.gd": + if script_path == "res://scenes/game/gameplays/Tile.gd": children_to_remove.append(child) removed_count += 1 elif "grid_position" in child: # Fallback detection @@ -1084,7 +1084,7 @@ func _restore_grid_from_layout(grid_layout: Array, active_gems: Array[int]) -> v for child in get_children(): if child.has_method("get_script") and child.get_script(): var script_path = child.get_script().resource_path - if script_path == "res://scenes/game/gameplays/tile.gd": + if script_path == "res://scenes/game/gameplays/Tile.gd": all_tile_children.append(child) DebugManager.log_debug( diff --git a/scenes/game/gameplays/Match3SaveManager.gd b/scenes/game/gameplays/Match3SaveManager.gd index 3dfe778..fd894ae 100644 --- a/scenes/game/gameplays/Match3SaveManager.gd +++ b/scenes/game/gameplays/Match3SaveManager.gd @@ -94,7 +94,7 @@ static func restore_grid_from_layout( for child in match3_node.get_children(): if child.has_method("get_script") and child.get_script(): var script_path = child.get_script().resource_path - if script_path == "res://scenes/game/gameplays/tile.gd": + if script_path == "res://scenes/game/gameplays/Tile.gd": all_tile_children.append(child) # Remove all found tile children diff --git a/scenes/game/gameplays/Tile.tscn b/scenes/game/gameplays/Tile.tscn index 6747650..d3d57b3 100644 --- a/scenes/game/gameplays/Tile.tscn +++ b/scenes/game/gameplays/Tile.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://bnk1gqom3oi6q"] -[ext_resource type="Script" path="res://scenes/game/gameplays/tile.gd" id="1_tile_script"] +[ext_resource type="Script" path="res://scenes/game/gameplays/Tile.gd" id="1_tile_script"] [node name="Tile" type="Node2D"] script = ExtResource("1_tile_script") diff --git a/scenes/main/main.tscn b/scenes/main/Main.tscn similarity index 100% rename from scenes/main/main.tscn rename to scenes/main/Main.tscn diff --git a/src/autoloads/GameManager.gd b/src/autoloads/GameManager.gd index e97b248..4288db2 100644 --- a/src/autoloads/GameManager.gd +++ b/src/autoloads/GameManager.gd @@ -6,8 +6,9 @@ extends Node -const GAME_SCENE_PATH := "res://scenes/game/game.tscn" -const MAIN_SCENE_PATH := "res://scenes/main/main.tscn" +const GAME_SCENE_PATH := "res://scenes/game/Game.tscn" +const MAIN_SCENE_PATH := "res://scenes/main/Main.tscn" +const CREDITS_SCENE_PATH := "res://scenes/ui/Credits.tscn" var pending_gameplay_mode: String = "match3" var is_changing_scene: bool = false @@ -97,6 +98,41 @@ func save_game() -> void: DebugManager.log_info("Game saved with score: %d" % current_score, "GameManager") +func show_credits() -> void: + """Show credits scene with race condition protection""" + # Prevent concurrent scene changes + if is_changing_scene: + DebugManager.log_warn( + "Scene change already in progress, ignoring show credits request", "GameManager" + ) + return + + is_changing_scene = true + DebugManager.log_info("Attempting to show credits scene", "GameManager") + + var packed_scene := load(CREDITS_SCENE_PATH) + if not packed_scene or not packed_scene is PackedScene: + DebugManager.log_error( + "Failed to load Credits scene at: %s" % CREDITS_SCENE_PATH, "GameManager" + ) + is_changing_scene = false + return + + var result = get_tree().change_scene_to_packed(packed_scene) + if result != OK: + DebugManager.log_error( + "Failed to change to credits scene (Error code: %d)" % result, "GameManager" + ) + is_changing_scene = false + return + + DebugManager.log_info("Successfully loaded credits scene", "GameManager") + + # Wait for scene to be ready, then mark scene change as complete + await get_tree().process_frame + is_changing_scene = false + + func exit_to_main_menu() -> void: """Exit to main menu with race condition protection""" # Prevent concurrent scene changes diff --git a/tests/TestSceneValidation.gd b/tests/TestSceneValidation.gd index 2b194ad..9cdb649 100644 --- a/tests/TestSceneValidation.gd +++ b/tests/TestSceneValidation.gd @@ -148,8 +148,8 @@ func test_critical_scenes(): # Define critical scenes that must work var critical_scenes = [ - "res://scenes/main/main.tscn", - "res://scenes/game/game.tscn", + "res://scenes/main/Main.tscn", + "res://scenes/game/Game.tscn", "res://scenes/ui/MainMenu.tscn", "res://scenes/game/gameplays/Match3Gameplay.tscn" ]