1.3 KiB
1.3 KiB
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:intnotvar foo : int - Blank lines between logical sections; comment headers label groups:
# Health,# Signals
General Rules
assert()for invariants and preconditions — prefer over silent failuresparams:Dictionaryfor multi-argument constructors/callables; access with.get('key', default)or.has('key')guardsmatchfor enum dispatch;if/elifchains for non-exhaustive checkscontinue/ earlyreturnto flatten nesting instead of deep else-branches- Avoid long inline lambdas — extract named static functions when logic is non-trivial