Add and update name convention
Some checks failed
Continuous Integration / Code Formatting (push) Successful in 30s
Continuous Integration / Code Quality Check (push) Successful in 30s
Continuous Integration / Test Execution (push) Failing after 17s
Continuous Integration / CI Summary (push) Failing after 4s

This commit is contained in:
2025-09-30 00:09:55 +04:00
parent 61951a047b
commit 5275c5ca94
57 changed files with 455 additions and 68 deletions

View File

@@ -27,6 +27,9 @@ Coding standards and development practices for the Skelly project. These guideli
## GDScript Coding Standards
### Naming Conventions
> 📋 **Quick Reference**: For complete naming convention details, see the **[Naming Convention Quick Reference](#naming-convention-quick-reference)** section below.
```gdscript
# Variables and functions: snake_case
var player_health: int = 100
@@ -39,6 +42,11 @@ const TILE_SPACING := 54
# Classes: PascalCase
class_name PlayerController
# Scene files (.tscn) and Script files (.gd): PascalCase
# MainMenu.tscn, MainMenu.gd
# Match3Gameplay.tscn, Match3Gameplay.gd
# TestAudioManager.gd (test files)
# Signals: past_tense
signal health_changed
signal game_started
@@ -100,7 +108,7 @@ func _get_match_line(start: Vector2i, dir: Vector2i) -> Array:
GameManager.start_match3_game()
# ❌ Wrong
get_tree().change_scene_to_file("res://scenes/game.tscn")
get_tree().change_scene_to_file("res://scenes/game/Game.tscn")
```
### Autoload Usage
@@ -263,6 +271,207 @@ wip
- Verify debug state persists across scene changes
- Check debug code doesn't affect release builds
## Naming Convention Quick Reference
> 🎯 **Single Source of Truth**: This section contains all naming conventions for the Skelly project. All other documentation files reference this section to avoid duplication and ensure consistency.
### 1. GDScript Code Elements
```gdscript
# Variables and functions: snake_case
var player_health: int = 100
func calculate_damage() -> int:
# Constants: SCREAMING_SNAKE_CASE
const MAX_HEALTH := 100
const TILE_SPACING := 54
# Classes: PascalCase
class_name PlayerController
# Signals: past_tense_with_underscores
signal health_changed
signal game_started
signal match_found
# Private functions: prefix with underscore
func _ready():
func _initialize_grid():
```
### 2. File Naming Standards
#### Script and Scene Files
```gdscript
# ✅ Correct: All .gd and .tscn files use PascalCase
MainMenu.tscn / MainMenu.gd
Match3Gameplay.tscn / Match3Gameplay.gd
ClickomaniaGameplay.tscn / ClickomaniaGameplay.gd
ValueStepper.tscn / ValueStepper.gd
# Test files: PascalCase with "Test" prefix
TestAudioManager.gd
TestGameManager.gd
TestMatch3Gameplay.gd
# ❌ Wrong: Old snake_case style (being migrated)
main_menu.tscn / main_menu.gd
TestAudioManager.gd
```
**Rules:**
- Scene files (.tscn) must match their script file name exactly
- All new files must use PascalCase
- Test files use "Test" prefix + PascalCase
- Autoload scripts follow PascalCase (GameManager.gd, AudioManager.gd)
### 3. Directory Naming Conventions
#### Source Code Directories
```
# Source directories: snake_case
src/autoloads/
scenes/game/gameplays/
scenes/ui/components/
tests/helpers/
# Root directories: lowercase
docs/
tests/
tools/
data/
```
#### Asset Directories
```
# Asset directories: kebab-case
assets/audio-files/
assets/ui-sprites/
assets/game-textures/
assets/fonts/
localization/
```
### 4. Resource and Configuration Files
```bash
# Configuration files: lowercase with dots
project.godot
gdlintrc
.gdformatrc
.editorconfig
export_presets.cfg
# Godot resource files (.tres): PascalCase
data/DefaultBusLayout.tres
data/PlayerSaveData.tres
scenes/ui/DefaultTheme.tres
# Asset metadata: kebab-case
assets/asset-sources.yaml
assets/audio-files/audio-sources.yaml
assets/ui-sprites/sprite-sources.yaml
# Development files: kebab-case
requirements.txt
development-tools.md
```
### 5. Asset File Naming
```bash
# Audio files: kebab-case in kebab-case directories
assets/audio-files/background-music.ogg
assets/audio-files/ui-sounds/button-click.wav
assets/audio-files/game-sounds/match-sound.wav
# Visual assets: kebab-case
assets/ui-sprites/main-menu-background.png
assets/game-textures/gem-blue.png
assets/fonts/main-ui-font.ttf
# Import settings: match the original file
background-music.ogg.import
button-click.wav.import
```
**Asset Rules:**
- All asset files use kebab-case
- Organized in kebab-case directories
- Import files automatically match asset names
- Document all assets in `asset-sources.yaml`
### 6. Git Workflow Conventions
#### Branch Naming
```bash
# Feature branches: feature/description-with-hyphens
feature/new-gameplay-mode
feature/settings-ui-improvement
feature/audio-system-upgrade
# Bug fixes: fix/description-with-hyphens
fix/tile-positioning-bug
fix/save-data-corruption
fix/debug-menu-visibility
# Refactoring: refactor/component-name
refactor/match3-input-system
refactor/autoload-structure
# Documentation: docs/section-name
docs/code-of-conduct-update
docs/api-documentation
```
#### Commit Message Format
```bash
# Format: <type>: <description>
# Examples:
feat: add dark mode toggle to settings menu
fix: resolve tile swap animation timing issue
docs: update naming conventions in code of conduct
refactor: migrate print statements to DebugManager
test: add comprehensive match3 validation tests
```
### 7. Quick Reference Summary
| File Type | Convention | Example |
|-----------|------------|---------|
| **GDScript Files** | PascalCase | `MainMenu.gd`, `AudioManager.gd` |
| **Scene Files** | PascalCase | `MainMenu.tscn`, `Match3Gameplay.tscn` |
| **Test Files** | Test + PascalCase | `TestAudioManager.gd` |
| **Variables/Functions** | snake_case | `player_health`, `calculate_damage()` |
| **Constants** | SCREAMING_SNAKE_CASE | `MAX_HEALTH`, `TILE_SPACING` |
| **Classes** | PascalCase | `class_name PlayerController` |
| **Signals** | past_tense | `health_changed`, `game_started` |
| **Directories** | snake_case (src) / kebab-case (assets) | `src/autoloads/`, `assets/audio-files/` |
| **Assets** | kebab-case | `background-music.ogg`, `gem-blue.png` |
| **Config Files** | lowercase.extension | `project.godot`, `.gdformatrc` |
| **Branches** | type/kebab-case | `feature/new-gameplay`, `fix/tile-bug` |
> ✅ **Status**: All major file naming inconsistencies have been resolved. The project now follows consistent PascalCase naming for all .gd and .tscn files.
### 8. File Renaming Migration Guide
When renaming files to follow conventions:
**Step-by-step procedure:**
1. **Use Git rename**: `git mv old_file.gd NewFile.gd` (preserves history)
2. **Update .tscn references**: Modify script path in scene files
3. **Update code references**: Search and replace all `preload()` and `load()` statements
4. **Update project.godot**: If file is referenced in autoloads or project settings
5. **Update documentation**: Search all .md files for old references
6. **Update test files**: Modify any test files that reference the renamed file
7. **Run validation**: Execute `gdlint`, `gdformat`, and project tests
8. **Verify in editor**: Load scenes in Godot editor to confirm everything works
**Tools for validation:**
- `python tools/run_development.py --test` - Run all tests
- `python tools/run_development.py --lint` - Check code quality
- `python tools/run_development.py --format` - Ensure consistent formatting
## Common Mistakes to Avoid
### Architecture Violations
@@ -271,7 +480,7 @@ wip
get_tree().change_scene_to_file("some_scene.tscn")
# Don't hardcode paths
var tile = load("res://scenes/game/gameplays/tile.tscn")
var tile = load("res://scenes/game/gameplays/Tile.tscn")
# Don't ignore null checks
var node = get_node("SomeNode")