⚔️ Java Knight – A Text-Based RPG
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!
🎮 Gameplay Overview
-
Turn‑based combat. Each turn you can choose one of the following actions:
- Light attack – quick, low damage.
- Heavy attack – slower but higher damage.
- Special attack – unique to your hero (see below).
- Heal – restore some HP.
- Defend – reduce incoming damage until your next turn.
- Use item – consume one of your consumable items.
-
Explore different locations, fight enemies, earn XP (to level up) and coins (to buy items).
-
Collect three keys (drop randomly from enemies) to unlock the Dragon’s castle.
-
Defeat the Dragon to save the city and win the game.
-
If your hero dies, the game resets – no second chances.
🛡️ Heroes
🗡️ Knight
- Highest base damage.
- Weapon (Sword): High base damage + bonus special damage.
- Special attack: Deals bonus sword damage and stuns the enemy (enemy loses its next turn).
- Armor (Shield): Blocks 80% of all damage – best defence.
- Low HP but very tanky.
- Lowest mana.
- Passive: Minimum damage reduction is higher than any other hero.
🔮 Wizard
- Highest HP, average mana.
- Weapon (Wooden Staff): Allows a triple attack (three strikes in one turn).
- Armor (Robe): Low defence, but reflects some attacks back to the enemy, give you some mana bunos
- Special attack (Destructive Spell): Massive damage to one enemy and heals the Wizard for a portion of that damage.
- Low base damage – relies on special and triple attack.
- Passive: Worst damage reduction – you feel every hit.
🌙 Assassin
- Highest mana.
- Weapon (Dagger): Each normal hit restores mana.
- Armor (Leather): Chance to dodge incoming attacks entirely; if not, moderate defence.
- Special attack: Dodges the enemy’s next attack and lands a guaranteed critical hit on that enemy.
- Mana sustain allows frequent special attacks.
Level cap: All heroes can level up from 1 to 5. Each level improves core stats and may unlock new bonuses.
👹 Enemies
| Enemy | Key Features |
|---|---|
| 💀 Skeleton | Revives once after death with half HP. |
| 🧛 Vampire | Life steal – each hit drains your HP and heals the Vampire. Lowest key drop chance. |
| 👺 Goblin | Low HP, high damage. Chance to land a massive critical hit. Highest key drop chance. |
| 🐉 Dragon | Final boss. Unblockable attacks – armour and shield are useless. Cannot be defeated before level 4–5. |
🧪 Consumable Items (Usable / Throwable)
| Item | Effect |
|---|---|
| Health Potion | Restores HP. |
| Mana Potion | Restores mana. |
| Elixir of Life | Fully restores HP and mana (rare). |
| Holy Water | Deals heavy damage to undead (Skeleton, Vampire). |
| Cursed Dagger | Throw at an enemy – chance to instantly kill a enemy(do not work for dragon). if it fails, deals 10 damage. |
| Goblin Gland | Throw – confuses the enemy and skip turn. |
Items can be used on yourself (e.g., potions) or thrown at enemies (e.g., Holy Water, Cursed Dagger).
🗺️ Locations
- Darkmire Hollow
- Grave of the Fallen
- Goblin Warrens
- Vampire's Embrace
- Blightmoor Cave
- Crypt of Bleeding Bones
- Cackling Caverns
Each location contains 1 – 3 enemies. You can choose which location to enter next. Defeat all enemies in a location to earn rewards and move on.
💰 Progression & Victory Conditions
- XP – Gain XP from each defeated enemy. Level up (1→5) to increase stats.
- Coins – Earn coins from battles. Spend them to buy items.
- Keys – Each enemy has a chance to drop a key. Collect three keys to unlock the Dragon’s castle.
- Dragon fight – Even with three keys, you need at least level 4 (better level 5) to survive the Dragon’s unblockable attacks.
- Win – Defeat the Dragon → you save the city → game ends.
🧱 Object‑Oriented Programming (OOP) Principles
This project is built on the four fundamental pillars of OOP: Abstraction, Encapsulation, Inheritance, and Polymorphism.
🔍 Abstraction
-
Abstract classes:
Enemy– defines the core of any hostile creature.Player– base for all playable heroes.Consumable– parent for all usable/throwable items.
-
Interfaces:
Entity– forces implementing classes to have common methods (e.g.,getName(),getHealth(),takeDamage()).ICombatAction– standardises combat actions likeattack(),defend(),specialAbility().
-
Implementation:
EnemyimplementsEntity.Playerimplements bothEntityandICombatAction.- All concrete enemies (Skeleton, Vampire, etc.) extend
Enemy. - All heroes extend
Player. - All items extend
Consumable.
🔒 Encapsulation
- All fields (attributes) in every class are declared
privateorprotected. - Public getters and setters are provided where necessary, allowing controlled access and modification.
- Internal state is hidden, reducing bugs and unintended interference.
👪 Inheritance
- Player hierarchy:
Player (abstract)
|── Knight
├── Wizard
└── Assassin
- Enemy hierarchy:
Enemy (abstract)
├── Skeleton
├── Vampire
├── Goblin
└── Dragon
- Consumable hierarchy (partial):
Consumable (abstract)
├── HealthPotion
├── ManaPotion
├── ElixirOfLife
├── HolyWater
├── CursedDagger
└── GoblinGland
🔄 Polymorphism
- Most methods are overridden in subclasses to provide specialised behaviour (e.g.,
specialAbility()behaves differently for Knight, Wizard, and Assassin). - The game logic frequently refers to
Playerreferences that actually point toKnight,Wizard, orAssassinobjects – the correct overridden method is called automatically at runtime. - Similarly,
Enemyreferences hold concrete enemy types, and polymorphic calls handle unique abilities (e.g.,Skeletonrevives,Vampiresteals life). - This design allows adding new character types or enemies without changing existing combat or turn‑management code.
📊 Class Hierarchy Diagram
Compilation & Execution
-
Using an IDE (IntelliJ IDEA, Eclipse, etc.):
Simply open the project and run theMainclass. -
Using command line: compile all files then run the Main class
javac Main.java java Main
Make sure you have Java 11 or higher installed.
This README was fully generated by DeepSeek – an AI assistant created by DeepSeek Company.
