Rails of 1914 - Development Documentation
Project Overview
Rails of 1914 is a turn-based strategy game set during World War I, where players engage in city building, railway construction, and military transportation to achieve victory in conflict zones.
Technical Architecture
Technology Stack
- Backend: Python 3.8+
- Web Framework: Flask
- Frontend: HTML5, CSS3, JavaScript
- Map Rendering: SVG/Canvas for hexagonal grid
- Data Storage: JSON-based state management
Project Structure
rails-of-1914/
├── app.py # Flask application entry point
├── routes.py # API routes and endpoints
├── game/ # Core game logic
│ ├── __init__.py
│ ├── models.py # Game models (cities, railways, etc.)
│ ├── controller.py # Game controller
│ └── map_generator.py # Map generation logic
├── static/ # Static resources
├── templates/ # HTML templates
└── docs/ # Documentation
Core Components
1. Game State Management
- Implemented in
app.py
- Uses JSON-based state persistence
- Key features:
- Round tracking
- Phase management
- Player state
- Region control
- War status
2. Game Controller (game/controller.py
)
- Central game logic management
- Handles:
- Turn processing
- Action validation
- State updates
- Player interactions
3. Game Models (game/models.py
)
- Defines core game entities:
- Regions
- Cities
- Railways
- Military units
- Resources
4. Map System (game/map_generator.py
)
- Hexagonal grid-based map
- Region generation
- Territory control
- Resource distribution
API Endpoints
Game State
GET /api/game-state
: Retrieve current game stateGET /api/map-data
: Get map rendering dataPOST /api/next-round
: Advance to next roundPOST /api/reset-game
: Reset game state
Game Actions
POST /api/build-town
: Construct new cityPOST /api/build-railway
: Build railway connectionPOST /api/mobilize-troops
: Deploy military unitsPOST /api/declare-war
: Initiate conflictPOST /api/upgrade-town
: Upgrade city facilities
Game Mechanics
1. Turn Structure
- Protection Phase
- Building Phase
- Military Phase
- Resource Collection
2. Resource Management
- GDP
- Population
- Military strength
- Infrastructure
3. Victory Conditions
- Territorial control
- Economic dominance
- Military victory
Development Guidelines
Setup
- Clone repository
- Create virtual environment
- Install dependencies:
pip install -r requirements.txt
- Run development server:
python app.py
Code Style
- Follow PEP 8 guidelines
- Use type hints
- Document all functions and classes
- Write unit tests for new features
Deployment
- Supports multiple deployment platforms:
- Heroku
- Render
- Vercel
- Traditional VPS
Future Development
Planned Features
- Enhanced AI opponents
- Multiplayer support
- Additional scenarios
- Historical events system
- Advanced diplomacy mechanics
Known Issues
- Document any known bugs or limitations
- Track in issue management system
Contributing
Development Process
- Fork repository
- Create feature branch
- Implement changes
- Submit pull request
- Code review
- Merge to main branch
Testing
- Unit tests for core logic
- Integration tests for API endpoints
- UI/UX testing
- Performance testing
License
MIT License - See LICENSE file for details
GitHub Issues