306 lines
4.5 KiB
Markdown
306 lines
4.5 KiB
Markdown
# Fourth Assignment - Java Knight ⚔️
|
|
# Java Knight ⚔️
|
|
|
|
A turn-based RPG game written in Java using Object-Oriented Programming (OOP) principles.
|
|
|
|
---
|
|
|
|
# 📖 Story
|
|
|
|
For centuries, the land of **Javanest** lived peacefully until a powerful Dragon attacked the kingdom and cursed its people.
|
|
|
|
The curse transformed innocent humans into terrifying monsters such as:
|
|
|
|
- Skeletons ☠️
|
|
- Goblins 👹
|
|
- Vampires 🧛
|
|
|
|
The Dragon hid inside its Castle and divided the three magical keys among the monsters.
|
|
|
|
Your mission is to:
|
|
|
|
- Defeat enemies
|
|
- Collect all three keys
|
|
- Become stronger through battles
|
|
- Enter the Castle
|
|
- Defeat the Dragon and save Javanest
|
|
|
|
---
|
|
|
|
# 🎮 Game Features
|
|
|
|
- Turn-based combat system
|
|
- Different player classes
|
|
- Enemy special abilities
|
|
- Mana/Stamina system
|
|
- Weapons and armors
|
|
- Healing system
|
|
- RPG progression mechanics
|
|
- Object-Oriented design
|
|
|
|
---
|
|
|
|
# 🧱 Project Structure
|
|
|
|
```text
|
|
src/
|
|
└── org.project
|
|
├── entity
|
|
│ ├── Entity.java
|
|
│ ├── enemies
|
|
│ │ ├── Enemy.java
|
|
│ │ └── Skeleton.java
|
|
│ └── players
|
|
│ ├── Player.java
|
|
│ └── Knight.java
|
|
│
|
|
├── item
|
|
│ ├── Item.java
|
|
│ ├── armors
|
|
│ │ ├── Armor.java
|
|
│ │ └── KnightArmor.java
|
|
│ ├── weapons
|
|
│ │ ├── Weapon.java
|
|
│ │ └── Sword.java
|
|
│ └── consumables
|
|
│ ├── Consumable.java
|
|
│ └── Flask.java
|
|
│
|
|
├── location
|
|
│ └── Location.java
|
|
│
|
|
└── Main.java
|
|
```
|
|
|
|
---
|
|
|
|
# 🧠 OOP Concepts Used
|
|
|
|
This project was designed using multiple OOP principles.
|
|
|
|
---
|
|
|
|
## ✅ Inheritance
|
|
|
|
- `Knight extends Player`
|
|
- `Skeleton extends Enemy`
|
|
- `Sword extends Weapon`
|
|
- `KnightArmor extends Armor`
|
|
|
|
---
|
|
|
|
## ✅ Abstract Classes
|
|
|
|
Used to avoid duplicated code:
|
|
|
|
- `Entity`
|
|
- `Player`
|
|
- `Enemy`
|
|
- `Weapon`
|
|
- `Armor`
|
|
- `Consumable`
|
|
|
|
---
|
|
|
|
## ✅ Interfaces
|
|
|
|
The `Item` interface is implemented by:
|
|
|
|
- `Weapon`
|
|
- `Armor`
|
|
- `Consumable`
|
|
|
|
---
|
|
|
|
## ✅ Encapsulation
|
|
|
|
Important fields such as:
|
|
|
|
- HP
|
|
- Mana
|
|
- Defense
|
|
- Durability
|
|
|
|
are protected/private and accessed using getters.
|
|
|
|
---
|
|
|
|
## ✅ Polymorphism
|
|
|
|
Methods like:
|
|
|
|
- `attack()`
|
|
- `use()`
|
|
- `takeDamage()`
|
|
|
|
behave differently depending on the object type.
|
|
|
|
---
|
|
|
|
## ✅ Method Overriding
|
|
|
|
Examples:
|
|
|
|
- `attack()`
|
|
- `takeDamage()`
|
|
- `uniqueAbility()`
|
|
|
|
are overridden in subclasses.
|
|
|
|
---
|
|
|
|
# ⚔️ Player Class
|
|
|
|
## Knight
|
|
|
|
The Knight is a powerful melee fighter with:
|
|
|
|
- High damage
|
|
- Strong defense
|
|
- Heavy attacks
|
|
- Shield abilities
|
|
|
|
### Knight Abilities
|
|
|
|
- Light Attack
|
|
- Heavy Attack
|
|
- Defend
|
|
- Heal
|
|
- Special Ability (Shield Bash)
|
|
|
|
---
|
|
|
|
# 👹 Enemies
|
|
|
|
## Skeleton ☠️
|
|
|
|
### Special Ability
|
|
|
|
Can revive once with 50% HP after dying.
|
|
|
|
---
|
|
|
|
# 🛡️ Items
|
|
|
|
## Weapons
|
|
|
|
### Sword ⚔️
|
|
|
|
- Deals damage to enemies
|
|
- Has a special ability attacking multiple targets
|
|
|
|
---
|
|
|
|
## Armors
|
|
|
|
### KnightArmor 🛡️
|
|
|
|
- Reduces incoming damage
|
|
- Has durability system
|
|
|
|
---
|
|
|
|
## Consumables
|
|
|
|
### Flask 🧪
|
|
|
|
- Restores player health
|
|
|
|
---
|
|
|
|
# ❤️ Combat System
|
|
|
|
The game uses a turn-based combat system.
|
|
|
|
Example combat loop:
|
|
|
|
```java
|
|
while (player.isAlive() && enemy.isAlive()) {
|
|
|
|
player.attack(enemy);
|
|
|
|
if (enemy.isAlive()) {
|
|
|
|
enemy.attack(player);
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
# ▶️ How to Run
|
|
|
|
## Compile
|
|
|
|
```bash
|
|
javac src/org/project/Main.java
|
|
```
|
|
|
|
## Run
|
|
|
|
```bash
|
|
java org.project.Main
|
|
```
|
|
|
|
---
|
|
|
|
# ☕ Requirements
|
|
|
|
- Java JDK 21 or newer
|
|
- IntelliJ IDEA or any Java IDE
|
|
|
|
---
|
|
|
|
# 🎨 Console Output
|
|
|
|
The game uses terminal messages to display:
|
|
|
|
- Attacks
|
|
- Damage
|
|
- Healing
|
|
- Mana usage
|
|
- Enemy actions
|
|
|
|
Example:
|
|
|
|
```text
|
|
⚔️ Knight used Heavy Attack!
|
|
💀 Skeleton revived with 50% HP!
|
|
🧪 Flask healed the player!
|
|
```
|
|
|
|
---
|
|
|
|
# 🚀 Future Improvements
|
|
|
|
Possible future features:
|
|
|
|
- Goblin enemy
|
|
- Vampire enemy
|
|
- Dragon boss
|
|
- XP and Level system
|
|
- Inventory system
|
|
- Merchant/shop system
|
|
- Multiplayer mode
|
|
- PvP mode
|
|
- ANSI colored terminal output
|
|
|
|
---
|
|
|
|
# 👨💻 Developer Notes
|
|
|
|
This project was developed as the Fourth Assignment for Advanced Programming.
|
|
|
|
The main goal of the project is practicing:
|
|
|
|
- Clean architecture
|
|
- OOP design
|
|
- Java inheritance hierarchy
|
|
- Combat system implementation
|
|
|
|
---
|
|
|
|
# 🏆 Final Goal
|
|
|
|
Collect all three keys, enter the Castle, defeat the Dragon, and save the land of Javanest.
|
|
###### - Born of God and Void. You shall seal the blinding light that plagues their dreams. You are the Vessel. You are the Java Knight. |