2.2 KiB
2.2 KiB
🎲 Monopoly Game Design & Operations
This section caches the current architecture, conventions, and implementation standards for the Monopoly project.
🚀 Architecture Overview
The game follows a polymorphic architecture based on a Game interface.
- Game Controller:
MonopolyGame(Inherits fromGame). - Modal System: Modals (Dice, Property, Board) are also
Gameobjects. When active, the main game delegatesupdate()anddraw()toactive_modal. - System Constraints: 1-bit Monochrome (ST7789/E-Ink). RTTI IS DISABLED (
-fno-rtti). Useactive_modal->get_type()for safe casting.
🛠️ Design Patterns
1. Cycle/Execute Input Pattern
To prevent accidental choices on simple 2-button hardware:
- Button 0 (A): Cycles through options (increments selection).
- Button 1 (B): Executes/Confirms current selection or dismisses modal.
- Visual: Selected items MUST be prefixed with
>.
2. Centralized Rendering
MonopolyBoardRenderer: All shared board drawing logic (40-tile perimeter) MUST live here.- Tile Inversion: Highlight tiles (current position or property view) using solid black fill + white text.
- Legibility: Use Scale 2 (
draw_string_scaled) for player names and primary titles. Scale 1 for details.
3. Logic Conventions
- Rent Calculation:
- Properties:
tile->rent[0](Base). - Railroads: $25 / $50 / $100 / $200 based on owner count.
- Utilities: Dice Total * 4 (1 owned) or * 10 (2 owned).
- Properties:
- Modal Chaining: Dice Modal dismissal triggers
modal_property_indexcheck inMonopolyGame::updateto immediately launch the Property Modal.
➕ How to Implement New Features
Adding a New Tile
- Update
TileTypeandMONOPOLY_BOARDin games/monopoly/monopoly_board.h. - Update
MonopolyBoardRenderer.hif a new symbol or boundary is needed.
Adding a New Modal
- Create
NewModalGame.hinheriting fromGame. - Register a new
Typein lib/game.h and overrideget_type(). - Use the Cycle/Execute pattern for input.
- Add handling logic in
MonopolyGame::updatenear whereDiceModalGameorPropertyModalGameare handled.