```markdown
# Java Knight ⚔️ – A Turn-Based Roguelike RPG

A text-based role-playing game developed in Java, focusing on **Object-Oriented Programming** principles.

---

## 📖 Game Introduction
*For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into darkness. The Dragon transformed innocent people into monsters and hid the three keys to its lair among them. You must battle these creatures, collect the keys, and defeat the Dragon to save the land.*

In **Java Knight**, you choose one of three character classes, fight cursed enemies in turn-based combat, manage mana and equipment, and progress until you can face the final boss.

---

## 🚀 How to Compile & Run

### Requirements
- Java JDK 8 or higher
- IntelliJ IDEA (or any Java IDE)

### Execution (using IntelliJ IDEA)
1. Open the project folder (`Java-Knight`) in IntelliJ IDEA.
2. Wait for the IDE to index and import the Maven project.
3. Navigate to `src/main/java/org/project/Main.java`.
4. Right-click on `Main.java` and select **Run 'Main.main()'**.

The game will start directly in the terminal window of the IDE.

---

## 🧱 Class Structure & OOP Design

The project strictly follows **Object-Oriented Programming** principles.

### Core Interfaces & Abstract Classes
- **`Entity`** – Interface for any participant in combat. Declares methods like `attack()`, `defend()`, `heal()`, `takeDamage()`, `getHp()`, `getMp()`.
- **`Item`** – Interface for all objects that can be used. Provides `use()`, `getName()`, `getPrice()`.

### Players
- **`Player`** (abstract) – Implements `Entity`. Contains all common fields (health, mana, max stats), inventory, coins, experience points, and leveling logic. Defines abstract methods for the five mandatory actions.
- **`Knight`** – High base damage, strong armor. Special ability: **Shield Bash** (stuns enemy for one turn).
- **`Wizard`** – Highest health. Special ability: **Arcane Blast** (heavy damage + self heal).
- **`Assassin`** – Highest mana. Special ability: **Shadow Cloak** (dodges next attack and guarantees a critical hit next turn).

### Enemies
- **`Enemy`** (abstract) – Implements `Entity`. Holds common properties and the stun state.
- **`Goblin`** – High critical hit chance (40%).
- **`Skeleton`** – Resurrects once per battle with 50% HP.
- **`Vampire`** – Lifesteal (30% of damage dealt).
- **`Dragon`** – Final boss, breath attack bypasses defense.

### Items (for bonuses: Merchant/Inventory)
- **`Weapon`** (abstract) – `Sword`, `Dagger`, etc.
- **`Armor`** (abstract) – `KnightArmor`, `LeatherArmor`. Has durability and can break; can be repaired.
- **`Consumable`** (abstract) – `Flask` restores 10% of max HP.

### Key OOP Concepts Used
| Concept          | Example                                                                 |
|------------------|-------------------------------------------------------------------------|
| Inheritance      | `Knight` → `Player` → `Entity`                                          |
| Interface        | `Item` implemented by `Weapon`, `Armor`, `Consumable`                   |
| Abstract classes | `Player`, `Enemy`, `Weapon`, `Armor`                                    |
| Polymorphism     | `entity.attack(target)` works on any `Entity` subclass                  |
| Encapsulation    | All fields are private; access only via getters/setters                 |
| Method overriding| `specialAbility()`, `attack()`, `takeDamage()` overridden in subclasses |


---

## 🎮 How to Play

### Starting the Game
- Run the program. You will be asked to **choose a class**:
  - `1` – Knight (high damage)
  - `2` – Wizard (high HP)
  - `3` – Assassin (high mana)
- A random location is selected, and an enemy appears.

### Main Menu
After each encounter, you can:
1. **Hunt for enemies** – Fight a random enemy in the current area.
2. **Travel to another place** – Move to a different location and encounter a new enemy.
3. **Visit Merchant** – Buy weapons, armor, or flasks using collected gold.
4. **Use a Flask from bag** – Consume a healing item from your inventory (if you have any).
5. **Quit game**

### Combat (Turn-Based)
Each turn, you can choose one of **six actions**:
1. **Light Attack** – Free, moderate damage.
2. **Heavy Attack** – Costs 10 Mana, high damage.
3. **Guard** – Costs 5 Mana, completely blocks the next enemy attack.
4. **Heal** – Costs 15 Mana, restores 20 HP.
5. **Special Ability** – Costs 20 Mana, unique effect per class.
6. **Drink a Flask** – Use a healing item from inventory (if purchased from merchant).

After your action, if the enemy is alive, it attacks you (unless stunned by Knight's Shield Bash).

### Progression
- Defeating enemies earns **XP** and **gold**.
- When XP reaches a threshold (Level × 50), you **level up**, increasing Max HP and Max Mana.
- After every victorious battle, HP and Mana are fully restored.
- Each enemy type has a **20% chance** to drop its unique key. Once a key is obtained, that enemy type will never drop another key.
- **Collect all three keys** (Goblin, Skeleton, Vampire) to unlock the option to enter the Dragon's Castle.
- Defeat the Dragon to **win the game**. Dying at any point results in **Game Over**.

### Merchant & Inventory (Bonus Features)
- Gold earned from enemies can be spent at the **Merchant** (option 3 in main menu).
- You can purchase:
  - **Iron Sword** (30 gold)
  - **Knight's Armor** (50 gold)
  - **Healing Flask** (20 gold)
- Items go into your **inventory** and can be used in or out of combat.
- Flasks are consumed upon use.

---

## 🎨 Console Output & Colors
The game uses **ANSI escape codes** for colorful messages:
- 🔴 **Red** – damage taken
- 🟢 **Green** – healing
- 🟡 **Yellow** – warnings (low mana, level up)
- 🟣 **Purple** – special events (key drops)

---

## 🌟 Bonus Implemented Features
- Dynamic economy with **merchant system** and **gold**
- **Inventory** management (buy, store, and use items)
- Three distinct character classes with unique abilities
- Advanced combat mechanics (armor breaking, enemy resurrection, lifesteal, stun)
- Full turn-based game loop with enemy spawn, key collection, and final boss
```
