add unit tests

saveload fixes
This commit is contained in:
2025-09-27 12:17:14 +04:00
parent 3e960a955c
commit dd0c1a123c
31 changed files with 3400 additions and 282 deletions

View File

@@ -2,19 +2,19 @@
## Overview
This document establishes coding standards and development practices for the Skelly project. These guidelines are designed to help junior developers contribute effectively while maintaining code quality and project consistency.
Coding standards and development practices for the Skelly project. These guidelines help developers contribute effectively while maintaining code quality and project consistency.
## Core Principles
### 1. Code Clarity Over Cleverness
- Write code that is easy to read and understand
- Write code that is easy to read
- Use descriptive variable and function names
- Prefer explicit code over implicit or "clever" solutions
- Prefer explicit code over "clever" solutions
- Comment complex logic and business rules
### 2. Consistency First
- Follow existing code patterns in the project
- Use the same naming conventions throughout
- Follow existing code patterns
- Use same naming conventions throughout
- Maintain consistent indentation and formatting
- Follow Godot's GDScript style guide
@@ -22,7 +22,7 @@ This document establishes coding standards and development practices for the Ske
- Make small, focused commits
- Test changes before committing
- Don't break existing functionality
- Use the debug system to verify your changes
- Use debug system to verify changes
## GDScript Coding Standards
@@ -91,7 +91,7 @@ func _get_match_line(start: Vector2i, dir: Vector2i) -> Array:
## Project-Specific Guidelines
### Scene Management
- All scene transitions MUST go through `GameManager`
- All scene transitions go through `GameManager`
- Never use `get_tree().change_scene_to_file()` directly
- Define scene paths as constants in GameManager
@@ -100,7 +100,7 @@ func _get_match_line(start: Vector2i, dir: Vector2i) -> Array:
GameManager.start_match3_game()
# ❌ Wrong
GameManager.start_match3_game() # Use GameManager instead of direct scene loading
get_tree().change_scene_to_file("res://scenes/game.tscn")
```
### Autoload Usage
@@ -142,9 +142,9 @@ print(some_variable) # No context, use proper log level
```
### Logging Standards
- **ALWAYS** use `DebugManager.log_*()` functions instead of `print()` or `push_error()`
- Choose appropriate log levels based on message importance and audience
- Include meaningful categories to organize log output by system/component
- Use `DebugManager.log_*()` functions instead of `print()` or `push_error()`
- Choose log levels based on message importance and audience
- Include categories to organize log output by system/component
- Format messages with clear, descriptive text and relevant context
```gdscript
@@ -160,11 +160,11 @@ if debug_mode: print("debug info") # Use DebugManager.log_debug()
```
### Asset Management
- **MANDATORY**: Every asset added to the project must be documented in `assets/sources.yaml`
- Include complete source information, license details, and attribution requirements
- Document any modifications made to original assets
- Verify license compatibility with project usage before adding assets
- Update sources.yaml in the same commit as adding the asset
- **Document every asset** in `assets/sources.yaml`
- Include source information, license details, and attribution
- Document modifications made to original assets
- Verify license compatibility before adding assets
- Update sources.yaml in same commit as adding asset
```gdscript
# ✅ Correct asset addition workflow
@@ -184,13 +184,13 @@ if debug_mode: print("debug info") # Use DebugManager.log_debug()
```
### Error Handling
- Always check if resources loaded successfully
- Check if resources loaded successfully
- Use `DebugManager.log_error()` for critical failures
- Provide fallback behavior when possible
- Include meaningful context in error messages
```gdscript
# ✅ Correct error handling with structured logging
# Good error handling with structured logging
func load_scene(path: String) -> void:
var packed_scene := load(path)
if not packed_scene or not packed_scene is PackedScene:
@@ -209,12 +209,12 @@ func load_scene(path: String) -> void:
- Add body if needed for complex changes
```bash
# Good commit messages
# Good commit messages
Add gem pool management to match-3 system
Fix debug UI visibility toggle issue
Update documentation for new debug system
# Bad commit messages
# Bad commit messages
fix bug
update
wip
@@ -253,7 +253,7 @@ wip
### Manual Testing Requirements
- Test in Godot editor with F5 run
- Verify debug UI works with F12 toggle
- Check scene transitions work correctly
- Check scene transitions work
- Test on different screen sizes (mobile target)
- Verify audio and settings integration
@@ -261,53 +261,53 @@ wip
- Ensure debug panels appear/disappear correctly
- Test all debug buttons and controls
- Verify debug state persists across scene changes
- Check that debug code doesn't affect release builds
- Check debug code doesn't affect release builds
## Common Mistakes to Avoid
### Architecture Violations
```gdscript
# Don't bypass GameManager
# Don't bypass GameManager
get_tree().change_scene_to_file("some_scene.tscn")
# Don't hardcode paths
# Don't hardcode paths
var tile = load("res://scenes/game/gameplays/tile.tscn")
# Don't ignore null checks
# Don't ignore null checks
var node = get_node("SomeNode")
node.do_something() # Could crash if node doesn't exist
# Don't create global state in random scripts
# Don't create global state in random scripts
# Use autoloads instead
```
### Asset Management Violations
```gdscript
# Don't add assets without documentation
# Don't add assets without documentation
# Adding audio/new_music.mp3 without updating sources.yaml
# Don't use assets without verifying licenses
# Don't use assets without verifying licenses
# Using copyrighted music without permission
# Don't modify assets without documenting changes
# Don't modify assets without documenting changes
# Editing sprites without noting modifications in sources.yaml
# Don't commit assets and documentation separately
# Don't commit assets and documentation separately
git add assets/sprites/new_sprite.png
git commit -m "add sprite" # Missing sources.yaml update
# Correct approach
# Correct approach
git add assets/sprites/new_sprite.png assets/sources.yaml
git commit -m "add new sprite with attribution"
```
### Performance Issues
```gdscript
# Don't search nodes repeatedly
# Don't search nodes repeatedly
func _process(delta):
var ui = get_node("UI") # Expensive every frame
# Cache node references
# Cache node references
@onready var ui = $UI
func _process(delta):
ui.update_display() # Much better
@@ -315,11 +315,11 @@ func _process(delta):
### Debug System Misuse
```gdscript
# Don't create separate debug systems
# Don't create separate debug systems
var my_debug_enabled = false
print("debug: " + some_info) # Don't use plain print()
# Use the global debug and logging systems
# Use the global debug and logging systems
if DebugManager.is_debug_enabled():
show_debug_info()
DebugManager.log_debug("Debug information: " + some_info, "MyComponent")