This document provides a high-level overview of the codebase for developers.
- Game Engine: Godot 4.5.1
- Scripting: GDScript
- Data: JSON files for game content
- Testing: GUT (Godot Unit Testing)
pdoom1/
├── godot/ # Main game project
│ ├── autoload/ # Singleton scripts (loaded globally)
│ │ ├── game_config.gd # Game settings and configuration
│ │ ├── game_manager.gd # Main game controller
│ │ ├── music_manager.gd # Audio system
│ │ └── ...
│ ├── scripts/
│ │ ├── core/ # Core game logic
│ │ │ ├── game_state.gd # Central game state
│ │ │ ├── turn_manager.gd # Turn processing
│ │ │ ├── actions.gd # Action definitions
│ │ │ ├── events.gd # Event system
│ │ │ ├── doom_system.gd # Doom calculation
│ │ │ └── researcher.gd # Researcher entities
│ │ └── ui/ # UI controllers
│ │ ├── main_ui.gd # Main game screen
│ │ └── ...
│ ├── scenes/ # Godot scene files (.tscn)
│ ├── data/ # JSON data files
│ ├── assets/ # Art, audio, fonts
│ └── tests/ # Unit and integration tests
├── docs/ # Documentation
└── .github/ # CI/CD workflows
The central data model containing all game state:
- Resources (money, compute, reputation)
- Doom percentage
- Researchers and their properties
- Turn counter
- Queued actions
Handles turn processing:
- Start Turn: Initialize new turn, check for events
- Action Selection: Player queues actions
- Execute Actions: Process queued actions
- End Turn: Apply effects, advance turn counter
Defines available player actions:
- Hiring researchers
- Publishing papers
- Acquiring compute
- Strategic decisions
Actions are data-driven dictionaries with:
id: Unique identifiername: Display namedescription: Tooltip textcosts: Resource costseffects: Resulting changes
Random and triggered events:
- Turn-based triggers
- Condition-based triggers
- Player choices with consequences
Calculates and tracks doom percentage:
- Base doom changes from actions
- Modifiers from upgrades and events
- Clamping to 0-100 range
User Input
│
▼
┌─────────────────┐
│ MainUI │ ─── Captures clicks/keys
└────────┬────────┘
│
▼
┌─────────────────┐
│ GameManager │ ─── Routes commands
└────────┬────────┘
│
▼
┌─────────────────┐
│ GameState │ ─── Updates state
└────────┬────────┘
│
▼
┌─────────────────┐
│ TurnManager │ ─── Processes turns
└────────┬────────┘
│
▼
┌─────────────────┐
│ MainUI │ ─── Renders updated state
└─────────────────┘
Godot signals are used for decoupled communication:
# GameManager emits signals
signal game_state_updated(state: Dictionary)
signal turn_phase_changed(phase: String)
signal action_executed(result: Dictionary)
signal event_triggered(event: Dictionary)
# UI connects to signals
game_manager.game_state_updated.connect(_on_state_updated)
game_manager.event_triggered.connect(_on_event)These scripts are loaded globally and accessible anywhere:
| Autoload | Purpose |
|---|---|
GameConfig |
Settings, difficulty, player preferences |
GameManager |
Main game controller |
MusicManager |
Background music and audio |
ThemeManager |
UI theming |
ErrorHandler |
Error logging and reporting |
Access via: GameConfig.setting_name or GameManager.method()
Tests use the GUT framework:
# Run all tests
godot --headless --path godot -s res://addons/gut/gut_cmdln.gd -gexit
# Run specific test file
godot --headless --path godot -s res://addons/gut/gut_cmdln.gd \
-gtest=res://tests/unit/test_game_state.gd -gexitTest files follow the pattern: test_<system>.gd
- Add definition to
scripts/core/actions.gd - Implement effect in
_execute_action()if needed - Add tests to
tests/unit/test_actions.gd
- Add definition to
scripts/core/events.gd - Define trigger condition and effects
- Add tests to
tests/unit/test_events.gd
- Create scene in
scenes/ - Add controller script in
scripts/ui/ - Connect to relevant signals
- Use signals instead of polling
- Cache frequently accessed data
- Minimize per-frame allocations
- Profile with Godot's built-in profiler
- CONTRIBUTING.md - How to contribute
- GOOD_FIRST_ISSUES.md - Starter issues
- ../DEVELOPERGUIDE.md - Detailed developer guide