# Naraka **Repository Path**: byt6662/naraka ## Basic Information - **Project Name**: Naraka - **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 # Naraka Adventure RPG Documentation ## Author 池泠澈(Lingchechi) , 巴奕天(Baron) , 陈子晗(Chenzihan) ## Overview Naraka Adventure RPG is a text-based role-playing game developed in C++. Players assume the role of a brave adventurer navigating a dungeon filled with enemies, items, and challenges. The game features a rich world with interconnected rooms, combat mechanics, inventory management, and character progression through experience and leveling. ## Classes Description ### Character **Base class for Player and Enemy entities.** - **Attributes**: - `name`: String, character's name. - `description`: String, character's description. - `maxHealth`: Unsigned, maximum health points. - `currentHealth`: Unsigned, current health points. - `baseAttack`: Unsigned, base attack strength. - `baseDefense`: Unsigned, base defense strength. - `inventory`: Vector of `Item*`, items carried by the character. - **Methods**: - `Character(name, description, health, attack, defense)`: Constructor. - `~Character()`: Destructor, cleans up inventory. - `isAlive()`: Returns true if health > 0. - `takeDamage(damage)`: Applies damage, returns true if defeated. - `attack(target)`: Attacks another character. - `getName()`, `getDescription()`, `getHealth()`, `getMaxHealth()`: Getters for respective attributes. - `getAttack()`, `getDefense()`: Returns total attack/defense including item bonuses. - `toString()`: Returns string representation of stats. - `addToInventory(item)`: Adds item to inventory, applies effects. - `displayInventory()`: Displays inventory contents. - `display()`: Displays character info. - `getInventorySize()`, `getInventoryItem(index)`: Inventory accessors. - `heal(amount)`: Heals up to max health. - `setHealth(health)`: Sets health, capped at max. ### Enemy **Base class for enemies, inherits from Character.** - **Attributes**: - `experienceReward`: Unsigned, experience points awarded upon defeat. - **Methods**: - `Enemy(name, description, health, attack, defense, expReward)`: Constructor. - `getExperienceReward()`: Returns experience reward. - `specialAction()`: Virtual, for enemy-specific abilities (default empty). #### Derived Enemy Classes - **Goblin**: Weak enemy (20 HP, 4 ATK, 1 DEF, 10 EXP). - **Skeleton**: Medium enemy (40 HP, 8 ATK, 6 DEF, 15 EXP). - **Dragon**: Strong enemy (300 HP, 80 ATK, 70 DEF, 100 EXP). - `attack(target)`: 30% chance for triple-damage fire breath. - **CII**: Special enemy (300 HP, 100 ATK, 80 DEF, 150 EXP). - `attack(target)`: 20% chance for double-damage critical hit. - `specialAction()`: 20% chance to heal 20% of max health. ### Player **Inherits from Character, represents the player.** - **Attributes**: - `maxStamina`: Unsigned, maximum stamina (default 100). - `currentStamina`: Unsigned, current stamina. - `experiencePoints`: Unsigned, total experience. - `level`: Unsigned, current level (starts at 1). - **Methods**: - `Player(name)`: Constructor, initializes with 20 HP, 3 ATK, 1 DEF, 10 stamina. - `rest()`: Recovers 30% max health and all stamina. - `specialAttack(target)`: Deals double damage, costs 5 stamina. - `tryToFlee()`: 40% chance to escape battle. - `getStamina()`, `resetStamina()`, `regenerateStamina(amount)`: Stamina management. - `toString()`: Includes stamina in output. - `getLevel()`, `getExperience()`, `getNextLevelExperience()`: Level and experience accessors. - `addExperience(exp)`: Adds experience, handles leveling (40 EXP per level). - `useHealthPotion()`: Uses a health potion from inventory. - `takeDamage(damage)`: Overrides to check for Resurrection Stone (revives with 20% health). ### Item **Represents collectible items.** - **Attributes**: - `name`: String, item name. - `description`: String, item description. - `attackBoost`: Unsigned, attack increase. - `defenseBoost`: Unsigned, defense increase. - `healthBoost`: Unsigned, health increase. - **Methods**: - `Item(name, description, attackBoost, defenseBoost, healthBoost)`: Constructor. - `toString()`: Returns string with boosts (e.g., "Rusty Sword (+3 Attack)"). ### Room **Represents a dungeon room.** - **Attributes**: - `name`: String, room name. - `description`: String, room description. - `northRoom`, `eastRoom`, `southRoom`, `westRoom`: `Room*`, connections to other rooms. - `items`: Vector of `Item*`, items in the room. - `enemies`: Vector of `Enemy*`, enemies in the room. - **Methods**: - `Room(name, description)`: Constructor. - `~Room()`: Destructor, cleans up items and enemies. - `getName()`, `getDescription()`: Getters. - `addItem(item)`, `removeItem(index)`: Item management. - `getItems()`: Returns items vector. - `addEnemy(enemy)`, `removeEnemy(index)`: Enemy management. - `getEnemies()`: Returns enemies vector. - `setNorthRoom(room)`, `setEastRoom(room)`, `setSouthRoom(room)`, `setWestRoom(room)`: Set connections. - `getNorthRoom()`, `getEastRoom()`, `getSouthRoom()`, `getWestRoom()`: Get connections. - `display()`: Displays room contents. ### Game **Manages game state and logic.** - **Attributes**: - `player`: `unique_ptr`, the player. - `rooms`: Vector of `Room*`, all rooms. - `currentRoom`, `lastRoom`: `Room*`, current and previous rooms. - `gameOver`, `gameWon`: Booleans, game state flags. - `inBattle`: Boolean, whether in combat. - `currentEnemyIndex`: Int, index of enemy in battle. - `isChallengeRoom`: Boolean, whether in Challenge Room. - `lastSearchTime`: Unsigned, search cooldown. - `ciiDefeated`: Boolean, tracks CII defeat. - `UI_WIDTH`, `horizontalLine`, `emptyLine`: UI constants. - **Methods**: - `Game(playerName)`: Constructor, initializes game world. - `~Game()`: Destructor, cleans up rooms. - `run()`: Main game loop. - `createRooms()`: Sets up rooms, items, and enemies. - `updateGameState()`: Updates timers, stamina. - `checkWinCondition()`: Checks for dragon defeat in Throne Room. - `attackEnemy(index)`, `specialAttackEnemy(index)`: Combat actions. - `tryToFlee()`: Attempts to flee (not allowed in Challenge Room). - `restPlayer()`: Recovers health/stamina if no enemies. - `takeItem(index)`: Picks up item. - `searchRoom()`: Finds hidden items with cooldown. - `useItem(index)`: Placeholder for item use. - `movePlayer(nextRoom)`: Moves to new room. - `teleportToChallenge()`, `returnFromChallenge()`: Portal mechanics. - `displayMenu()`: Shows action menu. - `processBattleInput(choice)`, `processNormalInput(choice)`: Handle inputs. - `clearScreen()`, `waitForEnter()`: UI utilities. - `displayTitle(title)`, `displayRoomHeader()`, `displayPlayerStatus()`, `displayRoomContents()`: UI displays. - `formatTextForBox(text, maxLength)`: Formats UI text. - `getValidPlayerName()`: Validates player name input. ## Game Explanation ### Story In Naraka Adventure RPG, you are a brave adventurer named by the player, tasked with defeating a fearsome dragon residing in the Throne Room of a mysterious dungeon. You explore interconnected rooms, battle enemies like Goblins, Skeletons, and the powerful CII, and collect items to enhance your abilities. The dungeon includes a special Portal Room leading to a Challenge Room with the CII, offering high rewards but requiring victory to escape. ### Win Condition - **Primary Goal**: Defeat the Dragon in the Throne Room, clearing all enemies in that room. - **Game Over**: Player dies (unless saved by the Resurrection Stone) or attempts to leave the Challenge Room without defeating the CII. ### Special Features - **Leveling System**: Gain experience from defeating enemies; every 40 EXP increases level, boosting health, attack, defense, and stamina. - **Inventory Management**: Collect items with attack, defense, or health boosts. Health potions restore health, and the Resurrection Stone revives the player once. - **Combat Mechanics**: Normal and special attacks (costs stamina), fleeing (40% success, not in Challenge Room), and enemy-specific abilities (e.g., Dragon's fire breath, CII's critical hits and healing). - **Challenge Room**: Accessible via Portal Room, locks player in until CII is defeated, with high-risk, high-reward items. - **Search Mechanic**: Search rooms for hidden items with a level-based success chance and cooldown. - **UI**: Clean, formatted text interface with boxed displays for rooms, status, and menus. ## Compilation and Play Instructions ### Prerequisites - C++ compiler (e.g., g++ with C++11 or later). - Standard C++ libraries (`iostream`, `vector`, `string`, etc.). - Operating system: Windows, Linux, or macOS. ### File Structure Ensure all source files are in the same directory: - `main.cpp` - `Character.cpp`, `Character.hh` - `Enemy.cpp`, `Enemy.hh` - `Player.cpp`, `Player.hh` - `Item.cpp`, `Item.hh` - `Room.cpp`, `Room.hh` - `Game.cpp`, `Game.hh` - `GameCombat.cpp`, `GameItems.cpp`, `GameMenu.cpp`, `GameMovement.cpp`, `GameUI.cpp`, `GameWorld.cpp` ### Compilation 1. Open a terminal in the project directory. 2. Compile using g++ (example command): ```bash g++ -std=c++11 main.cpp Character.cpp Enemy.cpp Player.cpp Item.cpp Room.cpp Game.cpp GameCombat.cpp GameItems.cpp GameMenu.cpp GameMovement.cpp GameUI.cpp GameWorld.cpp -o NarakaAdventure