Files
2026-06-11 19:59:31 -05:00

28 lines
1.3 KiB
Markdown

# Code Style
## Naming
| Kind | Convention | Examples |
|---|---|---|
| Variables & functions | camelCase | `fighterMap`, `startBattle()`, `getFullParty()` |
| Classes, enums, enum values | PascalCase | `BattleFighter`, `FighterTeam`, `ALLY` |
| Constants & static data | SCREAMING_SNAKE_CASE | `CUTSCENE_CONTINUE`, `ITEM_DATA`, `PARTY_JOHN` |
| Private/internal helpers | leading underscore | `_onConversationInteract()`, `_applyGravity()` |
No trailing underscores. Leading underscore = "don't call this externally."
## Formatting
- **2-space indent** — not 4, not tabs
- **Type annotations everywhere**: `var health:int`, `func damage(amount:int, crit:bool) -> void:`
- **No space** between name and type: `var foo:int` not `var foo : int`
- Blank lines between logical sections; comment headers label groups: `# Health`, `# Signals`
## General Rules
- `assert()` for invariants and preconditions — prefer over silent failures
- `params:Dictionary` for multi-argument constructors/callables; access with `.get('key', default)` or `.has('key')` guards
- `match` for enum dispatch; `if/elif` chains for non-exhaustive checks
- `continue` / early `return` to flatten nesting instead of deep else-branches
- Avoid long inline lambdas — extract named static functions when logic is non-trivial