How zachbeta/2025_03_29_oneshot works
Project Type and Purpose
• SLOP_RUNNER is a terminal-based card game where the player acts as a “runner” hacking corporate systems.
• It focuses on turn-based gameplay, ASCII art rendering, resource management, and combat mechanics reminiscent of card games like Magic: The Gathering.
Analyzing the File Structure
• Top-level Files & Directories:
• Configuration and metadata files (e.g., package.json, tsconfig.json, jest.config.js, .gitignore).
• A saves directory containing JSON files, suggesting state persistence.
• The README, licensing, and documentation (intro.md, spec.md, todo.md) for overall project context.
• The src Directory is subdivided into:
• models: Contains core domain objects such as Card, GameState, LogEntry, UserAction, and associated tests. These represent the data model for the game.
• systems: Implements the game’s internal processing logic (ActionProcessor, CombatResolver, CorpAI, GameLoop, GameStateManager, InputHandler, PhaseManager, ProgramMechanics, SaveSystem, TurnManager, and ICEMechanics). These modules form the heart of the game engine.
• ui: Manages the rendering and user interaction components (CardRenderer, EventLogRenderer, GameBoardRenderer, HelpSystem, InteractiveGameBoard, TerminalUtils). This is the ASCII/terminal interface layer.
• utils: Provides additional helper functionality (e.g., CardFactory).
• types: Contains type definitions (e.g., terminal-kit typings), ensuring proper TypeScript support.
• A dedicated tests folder (and tests spread across directories) underlines a focus on modularity and testing.
a. Main Components to Identify:
• User Interface (UI Layer): Drawn from the ui directory handling rendering of cards, event logs, game boards, and helper systems.
• Game Engine / Core Systems: The systems directory, which includes the Game Loop, Turn Manager, Phase Manager, Input Handler, Action Processor, Combat Resolver, CorpAI, ICEMechanics, and Save System.
• Domain/Data Models: The models directory that defines Cards, GameState, LogEntry, and UserAction.
• Utility Functions: The utils (and smaller types definitions) that support the creation and management of cards, among others.
• Persistence: The saves directory represents the mechanism for state saving and retrieval.
b. Relationships/Interactions:
• The UI layer receives user input (keyboard events) and displays game states using ASCII art; it interacts primarily with the input components and rendering systems.
• The Input Handler (a system) collects and routes user actions to the Action Processor and Game State Manager.
• The Game Loop orchestrates the game phases (managed by Phase Manager and Turn Manager) and coordinates with Combat Resolver, CorpAI, and various Mechanics (ICEMechanics, ProgramMechanics) to process game logic.
• Domain models (Cards, GameState, etc.) are used across these systems to maintain state and facilitate gameplay.
• The Save System persists game state to the saves directory, enabling game session continuity.
c. Architectural Patterns/Design Principles:
• Separation of Concerns: Clear modular division between domain models, systems (logic), and UI.
• Component-Based Design: Systems encapsulate specific game functionalities (e.g., processing actions, resolving combat, handling game input).
• Test-Driven Development: Extensive tests are provided for nearly every module (as seen by *.test.ts files).
d. Relevant Technologies and Frameworks:
• Node.js and TypeScript provide the development platform.
• Terminal libraries (like terminal-kit, as indicated by type definitions) are used to manage CLI interactions.
• Testing is done using Jest, as seen in jest.config.js and the naming convention of test files.
Putting It All Together
• Present the central “Game Engine” containing the Game Loop, which orchestrates other systems like Turn Manager and Phase Manager.
• Domain models (Cards, GameState, LogEntry) to the Game Engine to show data structures that drive gameplay.
• Save System’s interaction with the Game Engine, highlighting persistence.