# asiercl/monopoly architecture

> Architecture diagram of the GitHub repository asiercl/monopoly, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asiercl/monopoly
- Repository: https://github.com/asiercl/monopoly

## Overview

##### Main Components
- Entry Point & Game Controller: At the heart of the application is the main class (MonopolyETSE) which serves as the entry point. Include a “Game Controller” or “Game Engine” node that manages game initialization and the main game loop.
- Game Core Model (Juego and Tablero): These classes manage key game logistics, including turn-taking, state management, and the game board representation.
- Board & Casillas (Squares): Under the “monopoly” package, the “casillas” folder organizes the different types of board squares:
– Acciones: Represents action squares (community and chance),
– Especiales: Special squares like Jail (Carcel, IrCarcel), Parking, and Salida,
– Impuesto: Tax squares,
– Propiedades: Properties, which are further classified by type (Propiedad, Servicio, Solar, Transporte).
- Edificios (Buildings): Represents buildings that can be constructed (Casa, Hotel, Piscina, Pista) which likely interact with property management.
- Partida (Gameplay Components): Contains classes that model the gameplay session:
– Jugador: Represents a player,
– Dado: The dice logic,
– Avatares: Visual or logical representation of player tokens (e.g., Coche, Pelota, Sombrero).
– Tratos: Represents trading functionality between players.
– Cartas: Represents cards (Carta, CartaCajaComunidad, CartaSuerte) and the deck (Baraja).
- Exceptions: A robust exception hierarchy is used to handle game-specific errors (e.g., DineroInsuficiente, JuegoException). Represent this as a separate “Error Handling” component.
- Interfaces: Provide abstraction layers (e.g., Consola, Comando, ConsolaNormal) for user input and output in the terminal – link these to how commands are processed by the game engine.

##### Relationships and Interactions
- The Game Controller (MonopolyETSE) initializes the game and invokes methods on the Juego and Tablero classes.
- Tablero uses various Casilla objects, each belonging to a different subclass or category (Acciones, Especiales, Propiedades, etc.), demonstrating a factory or polymorphic design pattern.
- The Partida module maintains player state, avatar selections, and game transactions, interacting with the game board and command interfaces.
- Interfaces (Consola/Comando) act as a bridge between user input (terminal commands) and the underlying game logic.
- The exceptions are thrown by many of these modules to enforce game rules and indicate errors.

##### Architectural Patterns and Design Principles
- Object-Oriented Design: Emphasize inheritance, encapsulation, and polymorphism used extensively in modeling board squares (casillas) and buildings.
- Separation of Concerns: Distinguish between game management (Juego, MonopolyETSE), board representation (Tablero, Casillas), session state (Partida), and UI/command handling (Interfaces).

◦ Under “Board”, create nodes for “Casillas” with branches for “Acciones”, “Especiales”, “Propiedades”, and “Impuesto”.
◦ A separate cluster for “Gameplay Session (Partida)” including sub-nodes “Jugador”, “Dado”, “Avatares”, “Tratos”, and “Cartas”.
◦ A utility cluster for “Edificios”.

##### Final Recommendations
- Be as detailed as possible: add all major classes and indicate the package structures if space allows.
- Every component node is clearly labeled and grouped by its module.
- Keep in mind the traditional object-oriented structure emphasized by the project – its use of inheritance (with casillas and buildings) and interface abstraction.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Interfaces Layer
    subgraph "Interfaces Layer"
        I1["Consola"]:::interface
        I2["Comando"]:::interface
        I3["ConsolaNormal"]:::interface
    end

    %% Game Initialization & Controller
    subgraph "Game Initialization & Controller"
        GC["Game Controller (MonopolyETSE)"]:::controller
        GL["Game Logic (Juego)"]:::logic
        BC["Board Controller (Tablero)"]:::logic
    end

    %% Board & Casillas
    subgraph "Board & Casillas"
        CB["Casilla (Base)"]:::casilla
        subgraph "Acciones"
            AC["Acciones"]:::casilla
            CM["Comunidad"]:::casilla
            SU["Suerte"]:::casilla
        end
        subgraph "Especiales"
            CA["Carcel"]:::casilla
            IC["IrCarcel"]:::casilla
            PA["Parking"]:::casilla
            SA["Salida"]:::casilla
            ES["Especial"]:::casilla
        end
        IMP["Impuesto"]:::casilla
        subgraph "Propiedades"
            PR["Propiedad"]:::casilla
            SE["Servicio"]:::casilla
            SO["Solar"]:::casilla
            TR["Transporte"]:::casilla
        end
    end

    %% Gameplay Session (Partida)
    subgraph "Gameplay Session (Partida)"
        JU["Jugador"]:::partida
        DA["Dado"]:::partida
        subgraph "Avatares"
            AV["Avatar"]:::partida
            CO["Coche"]:::partida
            EF["Esfinge"]:::partida
            PE["Pelota"]:::partida
            SM["Sombrero"]:::partida
        end
        subgraph "Tratos"
            TR0["Trato"]:::partida
            TRS["Tratos"]:::partida
        end
        subgraph "Cartas"
            BA["Baraja"]:::partida
            CA2["Carta"]:::partida
            CCC["CartaCajaComunidad"]:::partida
            CS["CartaSuerte"]:::partida
        end
    end

    %% Auxiliary Components (Edificios)
    subgraph "Auxiliary Components (Edificios)"
        ED["Edificio"]:::edificio
        CA2E["Casa"]:::edificio
        HO["Hotel"]:::edificio
        PI["Piscina"]:::edificio
        PIS["Pista"]:::edificio
    end

    %% Exception Handling
    subgraph "Exception Handling"
        EX["Exceptions"]:::exception
    end

    %% Connections for input layer to Game Controller
    I1 -->|"input"| GC
    I2 -->|"input"| GC
    I3 -->|"input"| GC

    %% Game Controller initiates game logic and board controller
    GC -->|"init"| GL
    GC -->|"init"| BC

    %% Board Controller uses board base and its components
    BC -->|"manages"| CB
    CB -->|"includes"| AC
    CB -->|"includes"| CA
    CB -->|"includes"| IMP
    CB -->|"includes"| PR

    %% Details within "Acciones"
    AC -->|"type"| CM
    AC -->|"type"| SU

    %% Details within "Especiales"
    CA -->|"specializes"| IC
    CA -->|"specializes"| PA
    CA -->|"specializes"| SA
    CA -->|"specializes"| ES

    %% Details within "Propiedades"
    PR -->|"classified_as"| SE
    PR -->|"classified_as"| SO
    PR -->|"classified_as"| TR

    %% Game Logic interacts with gameplay session
    GL -->|"updates"| JU
    GL -->|"controls"| DA
    GL -->|"triggers"| TR0
    GL -->|"manages"| BA

    %% Interaction within Gameplay Session nodes
    JU -->|"acts with"| DA
    CO -->|"represents token for"| JU

    %% Auxiliary: Edificios associated with properties
    ED -->|"linked to"| PR
    CA2E -->|"linked to"| PR

    %% Error handling: various modules report exceptions
    GC -.-> EX
    GL -.-> EX
    JU -.-> EX

    %% Additional interactions for Partida
    TR0 -->|"negotiates"| TRS
    BA -->|"deals with"| CA2

    %% Interfaces direct feedback
    I1 -->|"feedback"| GC

    %% Styles
    classDef controller fill:#a2d2ff,stroke:#000,stroke-width:1px;
    classDef logic fill:#bde0fe,stroke:#000,stroke-width:1px;
    classDef casilla fill:#ffd6a5,stroke:#000,stroke-width:1px;
    classDef partida fill:#caffbf,stroke:#000,stroke-width:1px;
    classDef edificio fill:#ffadad,stroke:#000,stroke-width:1px;
    classDef interface fill:#fdffb6,stroke:#000,stroke-width:1px;
    classDef exception fill:#ffb4a2,stroke:#000,stroke-width:1px;

    %% Click Events for Game Initialization & Controller
    click GC "https://github.com/asiercl/monopoly/blob/main/monopoly/MonopolyETSE.java"
    click GL "https://github.com/asiercl/monopoly/blob/main/monopoly/Juego.java"
    click BC "https://github.com/asiercl/monopoly/blob/main/monopoly/Tablero.java"

    %% Click Events for Board & Casillas
    click CB "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Casilla.java"
    click AC "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Acciones/Acciones.java"
    click CM "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Acciones/Comunidad.java"
    click SU "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Acciones/Suerte.java"
    click CA "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Especiales/Carcel.java"
    click IC "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Especiales/IrCarcel.java"
    click PA "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Especiales/Parking.java"
    click SA "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Especiales/Salida.java"
    click ES "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Especiales/Especial.java"
    click IMP "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Impuesto.java"
    click PR "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Propiedades/Propiedad.java"
    click SE "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Propiedades/Servicio.java"
    click SO "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Propiedades/Solar.java"
    click TR "https://github.com/asiercl/monopoly/blob/main/monopoly/casillas/Propiedades/Transporte.java"

    %% Click Events for Auxiliary Components (Edificios)
    click ED "https://github.com/asiercl/monopoly/blob/main/monopoly/edificios/Edificio.java"
    click CA2E "https://github.com/asiercl/monopoly/blob/main/monopoly/edificios/Casa.java"
    click HO "https://github.com/asiercl/monopoly/blob/main/monopoly/edificios/Hotel.java"
    click PI "https://github.com/asiercl/monopoly/blob/main/monopoly/edificios/Piscina.java"
    click PIS "https://github.com/asiercl/monopoly/blob/main/monopoly/edificios/Pista.java"

    %% Click Events for Gameplay Session (Partida)
    click JU "https://github.com/asiercl/monopoly/blob/main/partida/Jugador.java"
    click DA "https://github.com/asiercl/monopoly/blob/main/partida/Dado.java"
    click AV "https://github.com/asiercl/monopoly/blob/main/partida/avatares/Avatar.java"
    click CO "https://github.com/asiercl/monopoly/blob/main/partida/avatares/Coche.java"
    click EF "https://github.com/asiercl/monopoly/blob/main/partida/avatares/Esfinge.java"
    click PE "https://github.com/asiercl/monopoly/blob/main/partida/avatares/Pelota.java"
    click SM "https://github.com/asiercl/monopoly/blob/main/partida/avatares/Sombrero.java"
    click TR0 "https://github.com/asiercl/monopoly/blob/main/partida/Tratos/Trato.java"
    click TRS "https://github.com/asiercl/monopoly/blob/main/partida/Tratos/Tratos.java"
    click BA "https://github.com/asiercl/monopoly/blob/main/partida/cartas/Baraja.java"
    click CA2 "https://github.com/asiercl/monopoly/blob/main/partida/cartas/Carta.java"
    click CCC "https://github.com/asiercl/monopoly/blob/main/partida/cartas/CartaCajaComunidad.java"
    click CS "https://github.com/asiercl/monopoly/blob/main/partida/cartas/CartaSuerte.java"

    %% Click Events for Interfaces
    click I1 "https://github.com/asiercl/monopoly/blob/main/monopoly/interfaces/Consola.java"
    click I2 "https://github.com/asiercl/monopoly/blob/main/monopoly/interfaces/Comando.java"
    click I3 "https://github.com/asiercl/monopoly/blob/main/monopoly/interfaces/ConsolaNormal.java"

    %% Click Event for Exceptions
    click EX "https://github.com/asiercl/monopoly/tree/main/monopoly/exceptions/"
```
