# i3thcookie/cardgame architecture

> Architecture diagram of the GitHub repository i3thcookie/cardgame, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/i3thcookie/cardgame
- Repository: https://github.com/i3thcookie/cardgame

## Overview

CardGame is a turn-based terminal game where players manage cards, attack opponents, defend, and alter their movement and speed; the last surviving player wins. `main.py` creates players and starts the game loop, which dispatches player choices to combat, card, and movement actions and updates turn state. Player hands and decks hold the game’s card state, while movement techniques can influence combat and speed. The README also documents balancing these mechanics through constants. The graph reflects sampled source and documented capabilities; unsampled action details are grouped under their existing module path.

Main entry points: [`code/gameloop_actions.py`](https://github.com/i3thcookie/cardgame/blob/main/code/gameloop_actions.py) (Action handlers), [`code/player_class.py`](https://github.com/i3thcookie/cardgame/blob/main/code/player_class.py) (Player state), [`code/attack_func.py`](https://github.com/i3thcookie/cardgame/blob/main/code/attack_func.py) (Combat resolution), [`code/movement_func.py`](https://github.com/i3thcookie/cardgame/blob/main/code/movement_func.py) (Movement evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game flow"]
  node_main["Game entry<br/>[main.py]"]
  node_loop["Turn loop<br/>[gameloop_class.py]"]
end

subgraph group_actions["Player actions"]
  node_action_handlers["Action handlers"]
end

subgraph group_domain["Game state"]
  node_player_state["Player state<br/>[player_class.py]"]
  node_deck["Deck<br/>[deck_class.py]"]
  node_card["Card<br/>[card_class.py]"]
  node_constants["Game rules"]
end

subgraph group_mechanics["Combat and movement"]
  node_combat["Combat resolution<br/>[attack_func.py]"]
  node_movement["Movement evaluation<br/>[movement_func.py]"]
  node_tech_actions["Tech effects<br/>[tech_func.py]"]
  node_move_tech["Move techniques<br/>[move_tech_class.py]"]
  node_vectors["Vector operations<br/>[vector2_func.py]"]
end

subgraph group_presentation["Terminal UI"]
  node_printing["Game display<br/>[printing_func.py]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_main
node_main -->|"starts loop"| node_loop
node_main -->|"creates players"| node_player_state
node_loop -->|"dispatches choices"| node_action_handlers
node_loop -->|"updates turns"| node_player_state
node_loop -->|"displays state"| node_printing
node_loop -->|"decays speed"| node_vectors
node_action_handlers -->|"resolves attacks"| node_combat
node_action_handlers -->|"evaluates moves"| node_movement
node_action_handlers -->|"applies active tech"| node_tech_actions
node_action_handlers -->|"changes player state"| node_player_state
node_action_handlers -->|"draws and returns cards"| node_deck
node_action_handlers -->|"creates modified cards"| node_card
node_action_handlers -->|"shows choices"| node_printing
node_combat -->|"checks passive tech"| node_movement
node_combat -->|"applies combat effects"| node_tech_actions
node_combat -->|"changes speed"| node_vectors
node_combat -->|"changes combat state"| node_player_state
node_movement -->|"creates techniques"| node_move_tech
node_movement -->|"changes speed and tech"| node_player_state
node_movement -->|"updates vectors"| node_vectors
node_tech_actions -->|"updates tech and speed"| node_player_state
node_tech_actions -->|"changes vectors"| node_vectors
node_player_state -->|"owns deck"| node_deck
node_player_state -->|"holds cards"| node_card
node_deck -->|"generates cards"| node_card
node_deck -->|"uses card rules"| node_constants
node_combat -->|"uses combat rules"| node_constants
node_movement -->|"uses movement rules"| node_constants
node_tech_actions -->|"uses tech rules"| node_constants
node_printing -->|"formats game data"| node_constants

click node_main "https://github.com/i3thcookie/cardgame/blob/main/code/main.py"
click node_loop "https://github.com/i3thcookie/cardgame/blob/main/code/gameloop_class.py"
click node_action_handlers "https://github.com/i3thcookie/cardgame/blob/main/code/gameloop_actions.py"
click node_player_state "https://github.com/i3thcookie/cardgame/blob/main/code/player_class.py"
click node_deck "https://github.com/i3thcookie/cardgame/blob/main/code/deck_class.py"
click node_card "https://github.com/i3thcookie/cardgame/blob/main/code/card_class.py"
click node_constants "https://github.com/i3thcookie/cardgame/blob/main/code/constants_libraries.py"
click node_combat "https://github.com/i3thcookie/cardgame/blob/main/code/attack_func.py"
click node_movement "https://github.com/i3thcookie/cardgame/blob/main/code/movement_func.py"
click node_tech_actions "https://github.com/i3thcookie/cardgame/blob/main/code/tech_func.py"
click node_move_tech "https://github.com/i3thcookie/cardgame/blob/main/code/move_tech_class.py"
click node_vectors "https://github.com/i3thcookie/cardgame/blob/main/code/vector2_func.py"
click node_printing "https://github.com/i3thcookie/cardgame/blob/main/code/printing_func.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_loop toneBlue
class node_action_handlers toneAmber
class node_player_state,node_deck,node_card,node_constants toneMint
class node_combat,node_movement,node_tech_actions,node_move_tech,node_vectors toneRose
class node_printing,node_player toneIndigo
```

## Components

### Game flow

- [Game entry](https://github.com/i3thcookie/cardgame/blob/main/code/main.py): `code/main.py`
- [Turn loop](https://github.com/i3thcookie/cardgame/blob/main/code/gameloop_class.py): `code/gameloop_class.py`

### Player actions

- [Action handlers](https://github.com/i3thcookie/cardgame/blob/main/code/gameloop_actions.py): `code/gameloop_actions.py`

### Game state

- [Player state](https://github.com/i3thcookie/cardgame/blob/main/code/player_class.py): `code/player_class.py`
- [Deck](https://github.com/i3thcookie/cardgame/blob/main/code/deck_class.py): `code/deck_class.py`
- [Card](https://github.com/i3thcookie/cardgame/blob/main/code/card_class.py): `code/card_class.py`
- [Game rules](https://github.com/i3thcookie/cardgame/blob/main/code/constants_libraries.py): `code/constants_libraries.py`

### Combat and movement

- [Combat resolution](https://github.com/i3thcookie/cardgame/blob/main/code/attack_func.py): `code/attack_func.py`
- [Movement evaluation](https://github.com/i3thcookie/cardgame/blob/main/code/movement_func.py): `code/movement_func.py`
- [Tech effects](https://github.com/i3thcookie/cardgame/blob/main/code/tech_func.py): `code/tech_func.py`
- [Move techniques](https://github.com/i3thcookie/cardgame/blob/main/code/move_tech_class.py): `code/move_tech_class.py`
- [Vector operations](https://github.com/i3thcookie/cardgame/blob/main/code/vector2_func.py): `code/vector2_func.py`

### Terminal UI

- [Game display](https://github.com/i3thcookie/cardgame/blob/main/code/printing_func.py): `code/printing_func.py`

### Other components

- **Player**

## Connections

- Player → Game entry: starts game
- Game entry → Turn loop: starts loop
- Game entry → Player state: creates players
- Turn loop → Action handlers: dispatches choices
- Turn loop → Player state: updates turns
- Turn loop → Game display: displays state
- Turn loop → Vector operations: decays speed
- Action handlers → Combat resolution: resolves attacks
- Action handlers → Movement evaluation: evaluates moves
- Action handlers → Tech effects: applies active tech
- Action handlers → Player state: changes player state
- Action handlers → Deck: draws and returns cards
- Action handlers → Card: creates modified cards
- Action handlers → Game display: shows choices
- Combat resolution → Movement evaluation: checks passive tech
- Combat resolution → Tech effects: applies combat effects
- Combat resolution → Vector operations: changes speed
- Combat resolution → Player state: changes combat state
- Movement evaluation → Move techniques: creates techniques
- Movement evaluation → Player state: changes speed and tech
- Movement evaluation → Vector operations: updates vectors
- Tech effects → Player state: updates tech and speed
- Tech effects → Vector operations: changes vectors
- Player state → Deck: owns deck
- Player state → Card: holds cards
- Deck → Card: generates cards
- Deck → Game rules: uses card rules
- Combat resolution → Game rules: uses combat rules
- Movement evaluation → Game rules: uses movement rules
- Tech effects → Game rules: uses tech rules
- Game display → Game rules: formats game data
