# CppKING **Repository Path**: zksuj/cpp-king ## Basic Information - **Project Name**: CppKING - **Description**: iiiiiiiintroduction - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-08 - **Last Updated**: 2025-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## students' name - Charles 陈韬宇 - Theodore 郑宇翔 - Alan 喻思翔 --- # CHU-Rogue **CHU-Rogue** is a text-based RPG game implemented in C++. Players engage in text-based interactions to explore maps, combat enemies, manage inventory, and experience the complete gameplay loop. ## Project Structure ``` . ├── main.cpp # Entry point, initiates the game ├── Game.cpp # Main game controller, manages overall game state ├── MainMenu.cpp # Game main menu, initial selection interface ├── MainInterface.cpp # Main game loop interface, primary player interaction ├── Player.cpp # Player class, manages character data and status ├── Enemy.cpp # Enemy class, disposable battle entities ├── Fight.cpp # Combat system, handles player-enemy interactions ├── Inventory.cpp # Inventory system, manages player items ├── Item.cpp # Item class, disposable entities placed within rooms ├── Room.cpp # Room class, provides diverse interactive environments ├── Level.cpp # Map control class, manages map structure and room objects ├── DataManager.cpp # Data manager, responsible for loading and managing static JSON data └── SBCPP.cpp # Supporting game logic and utility implementations ``` ## Game Architecture ### Gameplay Loop The game's architecture depends on two critical loops: - **Game Loop (Main Control)**: The game starts from `main.cpp`, initializing the `Game` object, which manages the game's basic flow including accessing the main menu (`MainMenu`), creating a character (`Player`), and initializing the map (`Level`). - **Main Interface Loop**: After data loading and initialization, the `MainInterface` class takes over, providing continuous player interaction including movement, battles, item interactions, and game-saving. ### Object Design - **Player** A critical, singular instance object. Passed by pointer into dynamic scenarios like battles to modify attributes (e.g., health, attack). - **Enemy and Item** Disposable entities instantiated from static JSON data for single interactions within rooms. - **Inventory** Closely coupled with the Player object, managed exclusively through the `Inventory` class for item storage. - **Level (Map Control)** Manages map structure and interactions. Uses a two-dimensional `vector` to define map layouts, with static IDs linked to specific room instances. - **Room** Provides interactive environments. Each room is instantiated according to static definitions and may contain enemies or items. - **DataManager** Loads and provides access to all static JSON data (items, enemies, room templates), facilitating object instantiation for other modules. ### Saving and Loading The saving and loading system relies on data transfer between `Game` and `MainInterface`: - **Saving**: Managed by `MainInterface`, capturing key states of `Player` and `Level` objects and storing them as JSON. - **Loading**: Managed by `Game`, reading saved JSON data to reinstantiate `Player` and `Level` objects, maintaining previously stored attributes, then transferring them back to `MainInterface`. ### Known Limitations - **Inventory and Room states** are not persisted between sessions. Loading a game resets inventory contents and room states to initial conditions, treated as a feature of the current game version. - **DO NOT use namespace** ,In the future maybe lead to **Name Collision**,when the project becomes bigger. - **blank definition of Copy Constructor/Copy Assignment Operator/Destructor** ,Failed to use them correctly. ## Compilation and Execution This project uses standard C++ and recommends building via CMake: ```bash # Example build commands: mkdir build/build_mac && cd build cmake .. cmake --build 。 # Run the game: ./program ``` ## Dependencies - C++ Standard Library (C++17 or newer) - nlohmann/json library (for JSON data management) Ensure your build environment supports these libraries and paths are configured correctly. --- For additional assistance or contributions, please contact the author or open an issue for feedback.