From cc237f6b317a031122d452c60a4ac15c3c33468f Mon Sep 17 00:00:00 2001 From: Sadra3st Date: Wed, 29 Apr 2026 22:44:56 +0330 Subject: [PATCH] README update --- .idea/.gitignore | 10 +++ .idea/HW-04-JAVA-KNIGHT.iml | 9 +++ .idea/markdown.xml | 6 ++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ README.md | 146 ++++++++++++++++++++++++++---------- 7 files changed, 152 insertions(+), 39 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/HW-04-JAVA-KNIGHT.iml create mode 100644 .idea/markdown.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/HW-04-JAVA-KNIGHT.iml b/.idea/HW-04-JAVA-KNIGHT.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/HW-04-JAVA-KNIGHT.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/markdown.xml b/.idea/markdown.xml new file mode 100644 index 0000000..f6d2542 --- /dev/null +++ b/.idea/markdown.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a20905f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..00e0d01 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index a370775..e006786 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,25 @@ -# Fourth Assignment - Java Knight ๐ŸŽฎ -A turn-based RPG inspired by Souls-like games which can be run in the terminal. +# Fourth Assignment - Java Knight โš”๏ธ +A turn-based RPG with Roguelike elements which can be run in the terminal. ### **Prologue: The Legend of Javanest** *For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!* ### **Introduction** -Welcome to **Java knight**, a turn-based RPG inspired by Souls-like games! In this assignment, you will develop a **text-based role-playing game (RPG)**. This project is designed to rigorously test your understanding of **Object-Oriented Programming (OOP) principles**. +Welcome to **Java knight**, a turn-based RPG inspired by Roguelike games! In this assignment, you will develop a **text-based role-playing game (RPG)**. This project is designed to rigorously test your understanding of **Object-Oriented Programming (OOP) principles**. -โš ๏ธ **MANDATORY REQUIREMENT:** You **must** utilize all the OOP concepts you have learned so farโ€”including *Inheritance, Interfaces, Abstract Classes, Encapsulation, and Polymorphism*. Your design and architecture will be heavily graded based on how well you apply these principles to avoid code duplication and maintain a clean structure. +โš ๏ธ **MANDATORY REQUIREMENT:** You **must** utilize all the OOP concepts you have learned so farโ€”including *Inheritance, Interfaces, Abstract Classes, Encapsulation, Polymorphism, Overloading, and Overriding*. It is extremely important that you use everything in its right place. Your design and architecture will be heavily graded based on how well you apply these principles to avoid code duplication and maintain a clean structure. + +๐ŸŽฏ **Your goal is not just to complete the assignment but to learn and apply OOP effectively!** ### **What is a Turn-Based Game?** -In this combat system, two sides - which are usually the player's side and the enemy's side - attack each other in turns. The side which is not attacking can perform actions to avoid or deflect the enemy's attack +In this combat system, two sides - which are usually the player's side and the enemy's side - attack each other in turns. The side which is not attacking can perform actions to avoid or deflect the enemy's attack. ### **Core Mechanics:** - **Turn-based combat** โ€“ Players and monsters take turns attacking each other. -- **Character classes** โ€“ Players can choose from archetypes like **Knight, Assassin, or Wizard**, each with unique stats. -- **Unified Mana/Stamina System** โ€“ All player classes use a unified resource (Mana/Stamina) to perform *any* action. +- **Character classes with Unique Traits** โ€“ Players can choose from archetypes like **Knight, Assassin, or Wizard**, each starting with distinctly different base stats. +- **Unified Mana/Stamina System** โ€“ All player classes use a unified resource (Mana/Stamina) to perform actions. - **Standardized Action Set** โ€“ Every player character has exactly 5 specific actions available during their turn. -- **Dynamic Economy & Upgrades** โ€“ Earn coins based on enemy strength to buy weapons, abilities, or stat upgrades. +- **Experience & Leveling System** โ€“ Earn XP based on enemy strength to automatically level up and increase your base stats. - **Progression System** โ€“ You cannot fight the Dragon immediately. You must farm enemies for a chance to drop their specific key, collect all three, and grow stronger first. --- @@ -26,28 +28,39 @@ In this combat system, two sides - which are usually the player's side and the e ### 1๏ธโƒฃ Step 1: Fork & Setup ๐Ÿด 1. **Fork** this repository and clone it to your local machine. +```bash +git clone https://git.meshcomp.ir/AdvancedProgramming1404/HW-04-JAVA-KNIGHT.git +``` 2. Create a new branch named `develop` and switch to it. - +```bash +git checkout -b develop +``` ### 2๏ธโƒฃ Step 2: Implement the Class Hierarchy ๐ŸŒฒ +A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing shared logic in abstract classes. + - **Entities & Locations:** You have `Entity`, `Object`, and `Location`. - **Players:** `Player` is an abstract class implementing `Entity`. Subclasses: `Wizard`, `Knight`, `Assassin`. -- **Enemies:** `Enemy` is an abstract class implementing `Entity`. Subclasses: `Skeleton`, `Goblin`, `Vampire`. -- **The Boss:** `Dragon` extends `Enemy` (or is a distinct Boss interface/class), acting solely as the final boss. -- **Objects:** `Consumable`, `Armor`, `Weapon` are abstract classes implementing `Object`. Subclasses: `Flask`, `KnightArmor`, `Sword`, etc. + - **Base Stat Differences:** Each class must have distinct starting stats. For example: + - **Knight:** Highest Base Damage. + - **Wizard:** Highest Max Health (HP). + - **Assassin:** Highest Max Stamina/Mana. +- **Enemies:** `Enemy` is an abstract class implementing `Entity`. Subclasses: `Skeleton`, `Goblin`, `Vampire`, and **`Dragon`**. + - **The Boss:** Even though `Dragon` is the final boss, it **must** be a subclass of `Enemy` to inherit common combat properties, while possessing extremely high stats and unique mechanics. +- **Objects:** `Consumable`, `Armor`, `Weapon` are abstract classes implementing `Object`. ### 3๏ธโƒฃ Step 3: Implement Player & Monster Methods ๐Ÿน **Player Actions (The Rule of Five):** -Every player class **must** implement exactly the following 5 actions. Every action consumes a specific amount of Mana/Stamina. The **Special Ability** must consume the *highest* amount of Mana compared to the others. -1. **Light Attack:** Deals moderate damage, low Mana cost. +Every player class **must** implement exactly the following 5 actions (You can use an interface like `ICombatActions`). Every action (except Light Attack) consumes a specific amount of Mana/Stamina. The **Special Ability** must consume the *highest* amount of Mana compared to the others. +1. **Light Attack:** Deals moderate damage and costs **NO Mana**. *Note: If the player runs out of Mana/Stamina, this is the ONLY action they can perform.* 2. **Heavy Attack:** Deals high damage, medium Mana cost. 3. **Defend:** Completely blocks or significantly reduces the damage of the enemy's *next* strike. Medium Mana cost. 4. **Heal:** Restores a portion of the player's HP. Medium-high Mana cost. 5. **Special Ability:** A unique class-based ultimate move (Highest Mana cost): - - **Wizard** ๐Ÿง™โ€โ™‚๏ธ: Casts a devastating spell that damages the enemy while simultaneously replenishing some HP. - - **Assassin** ๐Ÿ—ก๏ธ: Turns invisible, dodging the next incoming attack completely and guaranteeing a *Critical Hit* on their next turn. - - **Knight** โš”๏ธ: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage. + - **Wizard** ๐Ÿง™โ€โ™‚๏ธ: Casts a devastating spell that damages the enemy while simultaneously replenishing some HP. + - **Assassin** ๐Ÿ—ก๏ธ: Turns invisible, dodging the next incoming attack completely and guaranteeing a *Critical Hit* on their next turn. + - **Knight** โš”๏ธ: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage. **Monster Abilities:** - **Goblin** ๐Ÿ‘น: High critical hit chance but low health. @@ -55,33 +68,79 @@ Every player class **must** implement exactly the following 5 actions. Every act - **Vampire** ๐Ÿฆ‡: Lifesteal ability โ€“ a portion of the damage it deals to the player is added back to its own health. - **Dragon (Final Boss)** ๐Ÿ‰: Immune to normal defense. Its fiery breath bypasses shields and deals massive damage. +๐Ÿ”น Make sure each entity **prints messages** when performing actions. example output (while in combat) : + +```bash +You chose to FIGHT! + +[Ser Duncan - 45/45 HP | 40/40 Mana] +[Goblin - 30/30 HP] + +--- + +Your Turn: +1. Light Attack | 2. Heavy Attack (-8 Mana) | 3. Defend (-6 Mana) | 4. Heal (-12 Mana) | 5. Shield Bash (-15 Mana) +``` + +```bash +โ†’ Chose: Light Attack +โš”๏ธ Ser Duncan (Knight) used Light Attack! (0 Mana) +Goblin took 10 damage! +Goblin has 20/30 HP remaining. +Ser Duncan Mana: 40/40 +``` +``` +Goblin's Turn : +๐Ÿ‘น Goblin used Critical Strike! +๐Ÿ’ฅ Critical hit! Sir Duncan took 20 damage! +Sir Duncan has 25/45 HP remaining. +``` ๐Ÿ”น *Narrative Console:* Use ANSI escape codes to print colorful narrative logs (e.g., Red for damage, Blue for Mana usage, Green for healing). -### 4๏ธโƒฃ Step 4: Implement the Game Loop, Progression & Economy ๐ŸŽฎ -1. **The Core Loop:** The game starts with the player entering a location. Immediately, a random standard enemy (`Goblin`, `Skeleton`, or `Vampire`) spawns. +### 4๏ธโƒฃ Step 4: Implement the Game Loop & Progression ๐ŸŽฎ + +1. **The Core Loop:** The game starts with the player entering a location. A random standard enemy (`Goblin`, `Skeleton`, or `Vampire`) spawns immediately. 2. **Player Choices:** Before engaging, the player is presented with the following options: - - **1. Fight the enemy:** Enter the turn-based combat sequence. - - **2. Move to another location:** Skip the current enemy and spawn a new random one. - - **3. Visit the Merchant:** Go to the shop to spend coins on items or upgrades. - - **4. Go to the Castle to fight the Dragon:** *(Note: This option must remain hidden or locked until the player has successfully collected all 3 keys).* + - **1. Fight the enemy:** Enter the turn-based combat sequence. + - **2. Move to another location:** Skip the current enemy and spawn a new random one. + - **3. Go to the Castle to fight the Dragon:** *(Note: This option must remain strictly hidden or locked until the player has successfully collected all 3 keys).* 3. **The Key Drop Logic (RNG Gatekeeping):** - - When the player defeats an enemy, there is a **specific percentage chance (e.g., 20%)** that it will drop the unique key associated with its species (Goblin Key, Skeleton Key, Vampire Key). - - **One Key Per Species:** Once a player obtains a specific key (e.g., Goblin Key), subsequent enemies of that same type (other Goblins) will **never** drop a key again. - - The player **must collect all 3 distinct keys** to unlock Option 4 and enter the Castle. -4. **Dynamic Economy & Upgrades:** - - When an enemy is defeated, the player receives Coins. **The number of coins must scale with the enemy's power level/stats** (stronger enemies drop more coins). - - At the **Merchant**, players can buy: - - **Weapons/Armor:** Increases base damage and defense. - - **Consumables:** Health and Mana flasks. - - **Stat Upgrades:** Permanently increases the **Max HP Bar** or **Max Mana Bar** (Crucial for surviving the Dragon). -5. **Final Boss Fight:** Once the 3 Keys are obtained and the player chooses Option 4, they enter the Castle. Defeating the Dragon breaks the curse, resulting in **Victory**. Dying at any point results in **Game Over**. + - When the player defeats an enemy, there is a **specific percentage chance (e.g., 20%)** that it will drop the unique key associated with its species (Goblin Key, Skeleton Key, Vampire Key). + - **One Key Per Species:** Once a player obtains a specific key (e.g., Goblin Key), subsequent enemies of that same type (other Goblins) will **never** drop a key again. + - The player **must collect all 3 distinct keys** to unlock Option 3 and enter the Castle. +4. **Post-Combat Recovery:** After each successful battle, the player's HP and Mana bars must automatically replenish (either fully or partially) to their base amounts so they are ready for the next encounter. +5. **Experience & Leveling System:** + - Defeating an enemy grants **XP**. The amount of XP must scale proportionally to the enemy's power level. + - Upon reaching an XP threshold, the player levels up. **Leveling up must automatically increase the player's Max HP and Max Stamina/Mana**, making them strong enough to eventually face the Dragon. +6. **Final Boss Fight:** Once the 3 Keys are obtained and the player chooses to go to the Castle, they will face the Dragon. Defeating the Dragon breaks the curse, resulting in **Victory**. Dying at any point results in **Game Over**. + +๐Ÿ”น Example game loop structure: + +```java +while (player.isAlive() && enemy.isAlive()) + player.attack(enemy); + if (enemy.isAlive()) { + enemy.attack(player); + } +} +``` + ### 5๏ธโƒฃ Step 5: Extra Features & Bonus Tasks โญ *(Optional for extra credit)* + +โœ… **Dynamic Economy & Merchant System:** Implement coins that drop from enemies. Add a "Visit Merchant" option to the main loop where players can spend coins to buy specific weapons, armors, or potions. โœ… **Multiple Weapons & Inventory:** Players can buy, store, and swap between multiple weapons mid-combat. -โœ… **Leveling System (XP):** Alongside coins, players gain XP. Leveling up automatically restores HP/Mana and slightly buffs base stats. -โœ… **Multiplayer/Party Mode:** Allow multiple players to team up. The Dragon's breath attack will damage the entire party simultaneously. +โœ… **Multiplayer/Party Mode:** Allow multiple players to team up. The Dragon's breath attack will damage the entire party simultaneously. +โœ… **(Bonus) PvP Mode:** Implement a **Player vs. Player** combat system. + +### 6๏ธโƒฃ Step 6: Write a Comprehensive README ๐Ÿ“„ +As the final mandatory step of your development, you must replace the default `README.md` with your own comprehensive documentation. Your README should include: +- A brief introduction to the game. +- How to compile and run your project from the terminal. +- An explanation of the classes, design patterns, and OOP principles you used. +- A brief guide on how to play (controls, stats, classes). --- @@ -90,12 +149,21 @@ Every player class **must** implement exactly the following 5 actions. Every act | **Criteria** | **Points** | |------------------------|------------| | **Strict application of all OOP principles (Mandatory)** | **40** | -| Correct class hierarchy & standard 5-action system | **20** | -| Working combat mechanics, Mana system & Enemy abilities | **20** | -| Game Loop (Merchant Shop, Scaling Coins, 4 Choices & RNG Keys) | **20** | +| Correct class hierarchy, Base stats & standard 5-action system | **20** | +| Working combat mechanics, Leveling System & Enemy abilities | **20** | +| Game Loop (3 Choices, Scaling XP & RNG Keys) | **10** | | Meaningful, interactive, & colored console outputs | **10** | +| Clear and Comprehensive `README.md` | **10** | | **Total Score** | **110** | +## Tips ๐Ÿš€ +- **Follow OOP principles**: Avoid redundant code by using inheritance properly. Think carefully about what belongs in an abstract class vs. a specific subclass. Make sure you use overriding and overloading correctly. +- **Test your code**: Run different scenarios (fighting, running out of mana, leveling up, dying) to ensure everything works as expected. +- **Ask for help**: If you're stuck, reach out to your classmates or mentors. + ## Submission โŒ› - **Deadline**: Submit your assignment before **May 9th, 2026**. -- **Submission Format**: Push your code to your forked repository, create a PR, and include a clear `README.md`. \ No newline at end of file +- **Submission Format**: Push your code to your forked repository, create a PR, and ensure your comprehensive `README.md` is included in the root directory. + +--- +###### Born of God and Void. You shall seal the blinding light that plagues their dreams. You are the Vessel. You are the Java Knight. \ No newline at end of file