How faulknerpearce/terminal_game works
Project Type and Purpose
• This is a CLI (command-line interface) Python game—a single-process, text-based combat engine.
• Purpose: orchestrate a turn-based fight between a player and a goblin, handling attacks, defense maneuvers, and leveling.
File Structure
• Top-level modules:
• game_classes.py – Domain models (Weapon, Character).
• game_data_functions.py – Data helpers (e.g., converters, random attack generator).
• game_functions.py – Core combat logic (attack resolution, block/parry handlers).
• game_levels.py – Level-up logic for weapons/characters.
• main.py – Orchestrates setup, game loop, and I/O.
• No external services or database—pure in-memory objects and console I/O.
README Insights
• Two main classes: Weapon and Character, each with clear responsibilities.
• A set of standalone functions for combat flow and output.
• The game loop ties everything together at the end of main.py.
Main Components
a. CLI Interface (UI Layer)
• Reads player input (attack choice).
• Prints combat results and status updates.
b. Game Loop (Controller)
• Located in main.py: instantiates characters, iterates turns, terminates on health ≤ 0.
c. Domain Model Layer
• Character Class (attributes: name, health, level, weapon).
• Weapon Class (attributes: damage values, XP, level).
d. Combat Engine (Business Logic)
• game_functions.py: character_combat, block, parry.
• game_data_functions.py: enemy_random_attack, convert_int_to_word.
e. Leveling Subsystem
• game_levels.py: level_up triggers for weapons and characters.
f. Data Flow & Interactions
• UI → Game Loop → Combat Engine → Domain Model → Leveling Subsystem → back to UI.
Relationships & Patterns
• Controller-Model separation: main.py orchestrates, domain classes hold state.
• Single Responsibility: each module handles one concern (e.g., data conversion, combat logic).
• No external dependencies—pure functions and classes.