# team_project **Repository Path**: abrgrar/team_project ## Basic Information - **Project Name**: team_project - **Description**: No description available - **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**: 2026-01-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### teammates: Liu Yunfei 柳云飞 20239053241 Neil 郭书豪 2023905316 Dniel 耿明赫 2023902045 # Gameplay ### **Hero Choice** You can choose four of the eight heroes to fight when entering the game. ### **Battle Settings** During the battle, we will rank each character based on their speed to determine who acts first. (Note that this is a matter of probability. Only when your speed is six points greater than the opponent's can you act absolutely ahead of them.) ### **Pressure determination** When a hero's stress reaches 150 points, a judgment will be made. There is a 25% probability that it is virtue (physical strength will be fully restored and stress will drop to 10), and a 75% probability that it is punishment (physical strength will drop to 10% of the maximum health and stress will drop to 10).So try to keep the pressure on your hero from being too high! ## Table of Contents (目录) - [Aenemy](#aenemy) - [Ahero](#ahero) - [Enemys (敌人子类)](#enemy-subclasses-敌人子类) - [Rooms](rooms) - [RandomFunc](RandomFunc) - [GameFunction](gameFunction) - [Heros](heros) - [IO](IO) - [Item](item) - [Hero_settings](hero_settings) - [enemy_settings](enemy_setting) - [ICharacter](ICharavter) - [IRoom](IRoom) --- ## `Aenemy` (抽象敌人基类) - **Inherits**: `ICharacter` - **Description**: Abstract base class for all enemy types. Not instantiated directly. (所有敌人类型的抽象基类,不直接实例化。) ### Attributes (属性) | Name | Type | Description | |--------------------|--------------------|--------------------------------------| | `skill1_targets` | `vector` | Valid target positions for Skill 1. (技能1的目标位置) | | `skill2_targets` | `vector` | Valid target positions for Skill 2. (技能2的目标位置) | | `name` | `string` | Enemy name. (敌人名称) | | `description` | `string` | Enemy description. (敌人描述) | | `is_dead` | `bool` | Whether the enemy is dead. (是否死亡) | | `maxHealth` | `unsigned` | Maximum health. (最大生命值) | | `health` | `unsigned` | Current health. (当前生命值) | | `speed` | `int` | Base speed. (基础速度) | | `round_speed` | `int` | Adjusted speed for the round. (回合速度) | | `position_inteam` | `unsigned` | Position in the enemy team. (队伍中的位置) | | `skill1_name` | `string` | Name of Skill 1. (技能1名称) | | `skill2_name` | `string` | Name of Skill 2. (技能2名称) | | `blight` | `unsigned` | Blight resistance (%). (毒抗百分比) | | `bleed` | `unsigned` | Bleed resistance (%). (流血抗性百分比) | | `stun` | `unsigned` | Stun resistance (%). (眩晕抗性百分比) | | `dodge` | `unsigned` | Dodge chance (%). (闪避概率百分比) | | `prot` | `double` | Damage reduction (0-1). (伤害减免比例) | ### Methods (方法) | Method | Description | |----------------------------|-----------------------------------------------------------------------------| | `takeDamage(unsigned)` | Reduces health by `damage * (1 - prot)`. Sets `is_dead` if health ≤ 0. | | `healing(unsigned)` | Restores health, capped at `maxHealth`. | | `modifyRoundSpeed(int)` | Updates `round_speed`. | | `getSkillName()` | Randomly returns `1` or `2` to choose a skill. | | `getskill1Target()` | Randomly selects a target position for Skill 1. | | `skill1()` / `skill2()` | **Pure virtual**. Implemented in subclasses to define skill behavior. | --- ## `Ahero` (抽象英雄基类) - **Inherits**: `ICharacter` - **Description**: Abstract base class for hero characters. (英雄角色的抽象基类。) ### Attributes (属性) | Name | Type | Description | |------------------------|--------------------|------------------------------------------| | `stress` | `unsigned` | Stress level (0-150). (压力值,上限150) | | `min_attack` / `max_attack` | `unsigned` | Damage range for attacks. (攻击伤害范围) | | `crit` | `unsigned` | Critical hit chance (%). (暴击率百分比) | | `deathBlow` | `unsigned` | Death blow resistance (%). (死亡抗性百分比) | | `trap` | `unsigned` | Trap disarming chance (%). (陷阱解除概率) | ### Methods (方法) | Method | Description | |----------------------------|-----------------------------------------------------------------------------| | `takeStress(unsigned)` | Increases stress. Triggers affliction/virtue if >150. | | `stressHealing(unsigned)` | Reduces stress. | | `getSkillName()` | Prompts user to choose a skill (1 or 2). | | `getskill1Target()` | Prompts user to select a target for Skill 1. | --- ## `Enemys` (enemy-subclasses) (敌人子类) All subclasses inherit from `Aenemy` and implement `skill1()` and `skill2()`. (所有子类继承自`Aenemy`并实现`skill1()`和`skill2()`。) ### Common Attributes (共有属性) - `skillX_min_attack` / `skillX_max_attack`: Damage range for the skill. (技能的最小/最大伤害) - `skillX_crit`: Critical hit chance for the skill (%). (技能的暴击率百分比) ### Example Subclasses (示例子类) #### `Cultist_Brawler` (邪教徒格斗者) - **Skills**: - `Rend_for_the_Old_Gods`: Deals damage and may apply stress. (造成伤害并可能施加压力) - `Stumbling_Scratch`: Deals damage with a chance to crit. (造成伤害并有暴击概率) #### `Pelagic_Grouper` (远洋石斑鱼) - **Skills**: - `Seaward_Slash`: Single-target attack with stress effects. (单体攻击,附带压力效果) - `Spearfishing`: High-damage skill with crit chance. (高伤害技能,有暴击概率) #### `Swine_Drummer` (猪鼓手) - **Skills**: - `Drum_of_Doom`: AoE damage and stress to all heroes. (群体伤害并对所有英雄施加压力) - `Drum_of_Debilitation`: Single-target damage and stress. (单体伤害并施加压力) --- ## Rooms ### Overview This module implements different types of rooms for a game environment, following the interface defined in `Iroom.hh`. Each room type provides unique gameplay interactions when players enter them. ### Room Types #### Spring Room - **Purpose**: A restorative room that likely provides healing or recovery benefits - **Features**: - Inherits from `Iroom` base class - Implements the `event()` function for team interactions - Contains type identifier string #### Fight Room - **Purpose**: A combat encounter room - **Features**: - Inherits from `Iroom` base class - Implements battle-related events through `event()` - Contains type identifier string #### Empty Room - **Purpose**: A neutral room with no special events - **Features**: - Inherits from `Iroom` base class - Provides basic room implementation - Contains type identifier string ## Dependencies - Iroom.hh (base interface) - gameFunction.hh (game mechanics) - IO.hh (input/output handling) ## Usage All rooms are implemented in the `rooms` namespace and can be instantiated to create varied gameplay experiences. Each room's `event()` method triggers when a player team enters the room. --- ## RandomFunc ### Overview This module provides essential game utility functions focused on random number generation and probability-based decisions. It leverages modern C++ random number generation capabilities to ensure high-quality randomness suitable for game development scenarios. ### Core Features 1. **Advanced Random Number Generation** - Implements Mersenne Twister engine for better randomness distribution - Uses `std::random_device` for true random seed initialization - Provides range-specified integer generation 2. **Probability Evaluation** - Percentage-based boolean return mechanism - Converts probability percentage to success/failure outcomes - Utilizes uniform distribution for fair probability calculation ### Code Structure ```cpp namespace gameFunction { // Generates random integer within [smallest_num, biggest_num] range int get_Random_Num(int smallest_num, int biggest_num); // Returns true with specified percentage probability bool get_persent_bool(unsigned int persent); } ``` - - - ## GameFunction ### Features - **Hero & Enemy Classes**: Multiple hero classes (Highwayman, Jester, Crusader, etc.) and enemy types (Pelagic Grouper, Bone Defender, Cultist Brawler, etc.) with unique skills and attributes. - **Combat System**: - Turn order determined by randomized speed values (`getFightVec`). - Skill targeting based on dynamic casting (`Ahero`/`Aenemy`). - Real-time team status display during rounds. - Automatic cleanup of defeated units. - **Randomized Encounters**: Generate enemy teams dynamically using `get_random_fight()`, which selects from 10 predefined configurations. - **Special Events**: Interactive events like the `hot_spring`, offering risk-reward mechanics for stress healing or damage. - **Team Management**: - Select and customize a team of 4 heroes (`selectHeroes`). - Track health, stress, and skill cooldowns. ### Code Structure - **Core Mechanics**: - `getFightVec`: Calculates turn order using speed modifiers. - `fight_round`: Handles skill execution, targeting, and post-round cleanup. - `hole_fight`: Manages the full combat loop until victory or defeat. - **Predefined Enemy Teams**: Configurations range from simple groups (e.g., `enemy_team_1` with 4 Pelagic Groupers) to mixed squads (e.g., `enemy_team_7` with Cultists and Madmen). - **Utility Modules**: - `IO`: Handles terminal I/O for team displays and user input. - `randomFunc`: Provides randomization for combat speed, events, and encounters. ### Example Usage ```cpp // Initialize teams auto heroes = gamefunction::selectHeroes(); auto enemies = gamefunction::get_random_fight(); // Start combat gamefunction::hole_fight(heroes, enemies); ``` - - - ## Heros ### Key Features - **8 Playable Hero Classes**: - **Highwayman**: Offensive skills (`Wicked Slice`, `Point Blank Shot`) with crit-focused damage. - **Jester**: Stress healing (`Inspiring Tune`) and melee attacks (`Dirk Stab`). - **Crusader**: Team support (`Inspiring Cry`) and heavy strikes (`Smite`). - **Houndmaster**: AoE stress reduction (`Cry Havoc`) and targeted attacks (`Hound Rush`). - **Bounty Hunter**: Multi-target damage (`Finish Him`) and precision strikes (`Collect Bounty`). - **Leper**: Self-healing (`Solemnity`) and high-damage chops (`Chop`). - **Vestal**: Direct healing (`Divine Grace`) and hybrid damage/heal (`Judgement`). - **Plague Doctor**: Team healing (`Battlefield Medicine`) and surgical strikes (`Surgery`). - **Skill Mechanics**: - **Dynamic Damage Calculation**: Randomized damage ranges with crit modifiers (e.g., `randomFunc::get_Random_Num`). - **Stress Management**: `stressHealing()` method for reducing mental strain during combat. - **Target Validation**: Position checks and dodge probability (`getDodge()`) for attack accuracy. - **Class Attributes**: - Configurable stats: `maxHealth`, `min/max_attack`, `speed`, `crit`, `dodge`, etc. - Skill descriptions and targeting logic stored in `hero_settings` namespace. ### Code Structure - **Base Class**: `Ahero` (inherits from `ICharacter`) provides shared properties and virtual skill methods. - **Hero Implementations**: - Each hero (e.g., `heros::highwayman`) overrides `skill1()` and `skill2()`. - Constructors load settings from `hero_settings::[ClassName]` for modular configuration. - **Combat Flow**: - Skills interact with `std::vector` teams (allies/enemies). - Dynamic casting (`dynamic_cast`) for team-specific interactions. ### Example Usage ```cpp // Create a Highwayman hero heros::highwayman* hero = new heros::highwayman("Dismas", 0); // Use skill1 on enemy team hero->skill1(enemy_team, ally_team, target_position); ``` - - - ## Input/Output (IO) ### Key Features - **Input Validation**: - `getString()`: Safely read string input from the user. - `getUnsignedInt()`: Force numeric input within specified bounds with error recovery. - `getFloat()`: Ensure valid positive float input. - **Terminal Control**: - `clearTerminal()`: Clear screen using ANSI escape codes (`\033[2J`). - **Team Display**: - `display_teams_massage()`: Show side-by-side status of hero and enemy teams using `ICharacter::toString()`. - `display_hero_teams_massage()`: Display hero team status only. ### Code Structure - **Validation Logic**: - Input loops with `std::cin` error clearing (`clear()`, `ignore()`) for invalid entries. - Type-safe returns using `static_cast`. - **Display Format**: - Team statuses wrapped in separator lines (`----------------------------------`). - Hero team displayed in reverse order (position 4 → 1). ### Example Usage ```cpp // Get valid position choice unsigned pos = IO::getUnsignedInt(1, 4, "Select target position:"); // Clear screen and display teams IO::clearTerminal(); IO::display_teams_massage(heroes, enemies); // Get player name std::string name = IO::getString("Enter your hero's name:"); ``` - - - ## Item ### Key Features - **4 Predefined Items**: - **Healing Potion**: Restores 50% of hero's max health. - **Calming Incense**: Reduces stress by 30 points. - **Swift Boots**: Permanently increases speed by 2. - **Strength Elixir**: Boosts attack by 10% while reducing speed by 1. - **Effect System**: - Lambda-based effects stored in `std::function`. - Operator overload: `+=` applies item effects directly to heroes (e.g., `item += hero`). - **Extensible Structure**: - Add new items by defining `Item` struct instances with custom effects. - Effects can modify multiple stats simultaneously (see `AttackBoost`). ### Code Structure - **Item Definition**: `struct Item { std::string name; std::string description; std::function effect; };` - - - ## Notes (备注) - **Skill Mechanics**: Most skills check for `dodge` chance and apply `crit` effects. (技能机制:大多数技能会检查闪避概率并应用暴击效果) - **Stress System**: Heroes may gain "Affliction" or "Virtue" when stress exceeds 150. (压力系统:英雄压力超过150时可能获得负面或正面效果) - **Operator Overloads**: `-=` for damage, `+=` for healing. (运算符重载:`-=`用于受伤,`+=`用于治疗)