# m4xxh/scheresteinpapier architecture

> Architecture diagram of the GitHub repository m4xxh/scheresteinpapier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m4xxh/scheresteinpapier
- Repository: https://github.com/m4xxh/scheresteinpapier

## Overview

##### Input/Interface Layer
- Command Line Interface (CLI)
- Argument Parser Component
- User Input Handler

##### Game Core
- Game Controller
- Rule Engine
- Score Keeper
- Game State Manager

##### Rules System
- Rule Parser
- Rule Storage
- Rule Validator

##### File System Integration
- Rules File Reader
- Custom Rules Parser

##### Use a top-down approach with these levels
- [User Interface Layer]
- ↓
- [Game Controller Layer]
- ↓
- [Rules Engine Layer]
- ↓
- [File System Layer]

##### Component Relationships
- User input → CLI Parser → Game Controller
- Game Controller ↔ Rule Engine
- Rule Engine ↔ File System (for reading rule files)
- Game Controller → Score Keeper
- Score Keeper → Game State Manager

##### Specific elements
- Input validation flow
- Rule selection logic (classic vs. extended vs. custom)
- Win condition handling
- Game state transitions

Special Considerations:

##### Flexibility of the rules system
- How custom rules can be loaded from external files
- Parsing mechanism for different rule formats

##### Three winning conditions
- Best-out-of-X
- Number of games
- Number of wins

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef game fill:#2ecc71,stroke:#27ae60,color:white
    classDef rules fill:#f1c40f,stroke:#f39c12,color:black
    classDef file fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph UI
        CLI["Command Line Interface"]:::ui
        ArgParser["Argument Parser"]:::ui
        InputHandler["User Input Handler"]:::ui
    end

    %% Game Controller Layer
    subgraph GameCore
        GameController["Game Controller"]:::game
        ScoreKeeper["Score Keeper"]:::game
        StateManager["Game State Manager"]:::game
    end

    %% Rules Engine Layer
    subgraph RulesEngine
        RuleEngine["Rule Engine"]:::rules
        RuleParser["Rule Parser"]:::rules
        RuleValidator["Rule Validator"]:::rules
    end

    %% File System Layer
    subgraph FileSystem
        RuleStorage["Rule Storage"]:::file
        ClassicRules["Classic Rules"]:::file
        ExtendedRules["Extended Rules"]:::file
        CustomRules["Custom Rules"]:::file
    end

    %% Relationships
    CLI --> ArgParser
    ArgParser --> InputHandler
    InputHandler --> GameController
    GameController <--> RuleEngine
    GameController --> ScoreKeeper
    ScoreKeeper --> StateManager
    RuleEngine <--> RuleParser
    RuleParser <--> RuleValidator
    RuleValidator <--> RuleStorage
    RuleStorage --- ClassicRules
    RuleStorage --- ExtendedRules
    RuleStorage --- CustomRules

    %% Click Events
    click CLI "https://github.com/m4xxh/SchereSteinPapier/blob/main/main.py"
    click ArgParser "https://github.com/m4xxh/SchereSteinPapier/blob/main/main.py"
    click InputHandler "https://github.com/m4xxh/SchereSteinPapier/blob/main/main.py"
    click GameController "https://github.com/m4xxh/SchereSteinPapier/blob/main/main.py"
    click RuleStorage "https://github.com/m4xxh/SchereSteinPapier/tree/main/rules/"
    click ClassicRules "https://github.com/m4xxh/SchereSteinPapier/blob/main/rules/classic.txt"
    click ExtendedRules "https://github.com/m4xxh/SchereSteinPapier/blob/main/rules/extended.txt"

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Game Components"]:::game
        L3["Rules Components"]:::rules
        L4["File System"]:::file
    end
```
