# tyloo **Repository Path**: xtab1788/tyloo ## Basic Information - **Project Name**: tyloo - **Description**: No description available - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-08 - **Last Updated**: 2025-04-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Groupname:tyloo Group members: 1.Rick(叶子豪) id:2023901697 2.Tom1(徐曈) id:2023901699 3.Ikun Hututu(张李凡) id:2023900900 Game Description: 1. background A brave warrior stands at the gate of hell. His goal is to enter hell, defeat the final BOSS, and uncover the secrets of hell. However, on his journey, he will encounter various monsters and need to make choices in different rooms and win battles. The Enemy he faces includes: Lava Hound, Bone King, and Troll. Troll is the boss enemy, and he needs to defeat it to win the game. 2. Winning Conditions Kill the boss 3. Special Features (1) Clear screen, making the code more readable (2) Randomly refresh treasures on the path of Hell, which can be acquired (3) Each enemy has a special attack, with different attack effects (4) Can freely navigate between different rooms, using map type data (5) Clear inheritance relationship between parent and child classes 4. Compilation and Play Instructions Compilation: Create a .vscode folder, create a tasks.json file, configure the compilation command in the tasks.json file, and save it. Play Instructions: Start the game, enter your target options, follow the prompts to operate, choose different options until you successfully enter the BOSS room and defeat the Troll.if you do not want to play, you can exit the game. Class Structure: 1. Class ICharacter: - This class is the base class for all characters in the game. It contains the basic attributes and methods that all characters have. - Methods: // Virtual destructor to ensure proper memory release for derived classes virtual ~ICharacter() = default; // Methods that must be implemented virtual bool isAlive() const = 0; // Check if the character is alive virtual bool takeDamage(unsigned damage) = 0; // Take damage virtual bool attack(ICharacter& target) = 0; // Attack the target // Getter methods virtual std::string getName() const = 0; // Get character name virtual std::string getDescription() const = 0; // Get character description virtual unsigned getHealth() const = 0; // Get current health points virtual unsigned getAttack() const = 0; // Get attack power virtual unsigned getDefense() const = 0; // Get defense power virtual std::string toString() const = 0; // Convert character information to a string // Inventory management virtual void addToInventory(Item* item) = 0; // Add item to inventory virtual void displayInventory() const = 0; // Display inventory // Display character information virtual void display() const = 0; 2. Class Character: - This class is a derived class of ICharacter and represents a generic character in the game. It contains the attributes and methods that all characters have in the game. - Attributes: std::string name; // Character name std::string description; // Character description unsigned health; // Current health points unsigned maxHealth; // Maximum health points unsigned attackPower; // Attack, to distinguish from funtion attack() unsigned defense; // Defense power std::vector inventory;// Dynamically managed inventory, storing pointers to Item* - Methods: // Constructor Character(const std::string& name, const std::string& description, unsigned health, unsigned attack, unsigned defense); // Destructor, releases inventory memory virtual ~Character(); // Implement methods of the ICharacter interface bool isAlive() const override; bool takeDamage(unsigned damage) override; bool attack(ICharacter& target) override; std::string getName() const override; std::string getDescription() const override; unsigned getHealth() const override; unsigned getAttack() const override; unsigned getDefense() const override; std::string toString() const override; void addToInventory(Item* item) override; void displayInventory() const override; void display() const override; // Operator overloading, allows adding items to the inventory using "+=" Character& operator+=(Item* item); // Operator overloading: uses "-" as an attack operation, calls the attack method bool operator-(ICharacter& target); 3. Class Enemy: - This class is a base enemy class, inheriting from Character class. - Methods: // Constructor calls the parent class constructor Enemy(const std::string& name, const std::string& description, unsigned health, unsigned attack, unsigned defense); virtual ~Enemy() = default; // Must implement special attack method, used for enemy special attacks virtual void specialAttack(ICharacter& target) = 0; 4. Class Lava_Hound: - This class is a derived class of Enemy, representing a lava hound enemy in the game. - Methods: // Constructor calls the parent class constructor Lava_Hound(); // Implement special attack method void specialAttack(ICharacter& target) override; 5. Class Bone_King: - This class is a derived class of Enemy, representing a bone king enemy in the game. - Methods: // Constructor calls the parent class constructor Bone_King(); // Implement special attack method void specialAttack(ICharacter& target) override; 6. Class Troll: - This class is a derived class of Enemy, representing a troll enemy in the game. - Methods: // Constructor calls the parent class constructor Troll(); // Implement special attack method void specialAttack(ICharacter& target) override; 7. struct Item - Description: Represents collectible items in the game, providing attribute bonuses. - Attributes: std::string name (Item name). std::string description (Item description). unsigned bonusAttack (Attack bonus). unsigned bonusDefense (Defense bonus). unsigned bonusHealth (Health bonus). - Methods: constructor Item(const std::string& name, const std::string& description, unsigned bonusAttack, unsigned bonusDefense, unsigned bonusHealth) toString() std::string toString() const 8. Class Room - Description: Represents game locations with exits, items, and enemies. - Attributes: std::string name (Room name). std::string description (Room description). std::map exits (Direction-to-neighbor room mappings). std::vector items (Items in the room) std::vector enemies (Enemies in the room). - Methods: - constructor Room(const std::string& name, const std::string& description) Destructor: ~Room() - Exit Management: void setExit(std::string direction, Room* neighbor) (Links a direction to a neighboring room). Room* getExit(std::string direction) const (Returns the neighbor room in a direction). std::string getExitsString() const (Lists all exit directions as a string). - Enemy Management: void addEnemy(ICharacter* enemy) (Adds an enemy to the room). ICharacter* getEnemy(std::string enemyName) (Retrieves an enemy by name). std::string getEnemiesString() const (Lists enemies with health status). void removeEnemy(ICharacter* enemy) (Removes an enemy from the room). - Display: void display() const (Prints room details: name, description, items, enemies, exits). std::string getName() const (Returns the room name). - Operator Overloading: Room* operator[](const std::string& direction);