How tsaglam/carcassonne works
Main Components
• Entry Point & Application Bootstrap: Represent the main class (Carcassonne.java), which starts the game.
• Controller/State Management: Create a component for game control that includes classes such as ControllerFacade, MainController, and the state-related classes (StateGameOver, StateIdle, StateManning, StatePlacing, StateMachine, AbstractGameState). This area employs the State pattern to manage different game phases.
• Model: Group together all business logic and game entities found under “model” (Player, Meeple, Round, grid, tile, terrain, and settings). Include the Artificial Intelligence components (AbstractCarcassonneMove, ArtificialIntelligence, RuleBasedAI, etc.) that are responsible for move selection and game strategy.
• View: Split the user interface into its subcomponents (main, secondary, tertiary, menubar, util). Clearly represent how these packages support user interaction, from the main game view (MainView, TileLayer, MeepleLayer, etc.) to specialized dialogs and controls (GridSizeDialog, PlayerSettingsView, etc.). Note that there’s a separation into multiple views (e.g., primary game board view, secondary panels for in-game actions, and tertiary views for statistics and settings).
• Utilities & Helpers: In the “util” package, include image scaling, caching, error reporting, and threading utilities that support the main functionalities. Also include configuration and settings from the “settings” package.
Relationships and Interactions
• Entry Flow: Start with the Carcassonne.java class which initializes the game, pulling together various submodules.
• Controller and State Machine: Show that user input (possibly coming from the View components, e.g., via mouse events and key bindings) is handled by the controller. The controller, through its façade and adapter classes, communicates with the game’s state machine, which transitions between states (Idle, Manning, Placing, Game Over) based on user actions.
• Model-View Interaction: Highlight how the model (game engine and objects) works in tandem with the view. For instance, when a tile is placed or a move is made, the model is updated and the View components (MainView, SecondaryView, etc.) get notified to render the changes.
• Artificial Intelligence: Include a separate block for AI components (AI classes and rule-based systems), interacting with the controller and model to simulate computer opponents.
Architectural Patterns and Design Principles
• MVC Pattern: Distinguish between the Model (game logic and data), View (graphical user interface), and Controller (logic for processing user inputs and managing game states).
• State Pattern: Clearly show the state machine and its various states that control the game flow.
• Facade/Adapter Patterns: Mark components such as ControllerFacade and ControllerAdapter that simplify interactions between various subsystems.
• Utility Modules: Represent helper and utility modules (for image scaling and error handling) that are used by multiple parts of the system.
Relevant Technologies and Tools
• Java SE 17+ is required, and Maven is used as the build tool.
• CI/CD is configured using GitHub workflows (CI.yml and sonar.yml), indicating automated build and code quality checks.
• An “Entry Point & Bootstrap” block (Carcassonne.java).
• A “Game Controller” block showing the façade and adapter classes, linked with a “State Machine” block that enumerates its states.
• A “Game Model” block containing entities (Player, Meeple, Round, Tile, Grid, etc.) along with an embedded “AI Module” block.
• A “View” block subdivided into main, secondary, tertiary, and menubar components.
• A “Utilities & Settings” block for helper classes, configuration, and image handling.