Java RPG Project
A small console-based Java RPG where the player selects a character class and fights a fixed sequence of enemies: Vampire, Goblin, Skeleton, and Dragon.
Gameplay
The game flow is handled in Main.java:
- The player enters a name.
- The player chooses a class:
- Knight
- Wizard
- Assassin
- The game creates four locations and enemies:
- Overworld -> Vampire
- Village -> Goblin
- Nether -> Skeleton
- End -> Dragon
- The player fights each enemy in sequence.
- If the player dies, the game ends.
- If all enemies are defeated, the player wins.
Combat System
Each battle is turn-based.
Player actions
The player can choose from:
- light attack
- normal attack
- heavy attack
- heal
- skip
Enemy actions
Enemies attack after the player’s turn. Some enemies have special behavior:
- Vampire can restore health while attacking
- Goblin can land critical hits
- Skeleton revives once after being defeated
- Dragon acts as a boss enemy with high HP
Core Interfaces and Classes
Entity
Common contract for all combatants.
It defines shared behavior such as:
attack(Entity target)heal(int health)fillMana(int mana)takeDamage(int damage)getMaxHP()getMaxMP()
Player
Abstract base class for all player characters.
It stores:
- name
- weapon
- armor
- current and maximum HP/MP
- base damage
- alive status
It also provides:
- normal attack
- heavy attack
- damage handling with armor defense
- healing
- mana restoration
Enemy
Abstract base class for enemies.
It stores:
- weapon
- HP/MP
- base damage
- alive status
It handles damage directly and leaves defeat behavior to subclasses through getKilled().
Player Classes
Knight
- HP: 100
- MP: 10
- Base damage: 10
A durable melee fighter with strong base damage.
Wizard
- HP: 150
- MP: 10
- Base damage: 4
A high-HP character using the shared Player behavior.
Assassin
- HP: 80
- MP: 20
- Base damage: 5
A lighter character with more mana than the Knight.
Enemy Classes
Vampire
- HP: 50
- MP: 50
Attacks and restores part of the damage dealt as health.
Goblin
- HP: 30
- MP: 50
Randomly performs either a normal or critical attack.
Skeleton
- HP: 50
- MP: 50
- Base damage: 10
Revives once after death, then dies permanently the second time.
Dragon
- HP: 500
- Base damage: 2
A boss-style enemy with a fire-breath themed attack and custom death handling.
Items
Weapon
Abstract item type for damage-dealing equipment.
It includes:
- damage
- mana cost
Sword
A weapon with low damage and a mana cost.
It also includes a unique ability that can damage multiple targets.
DragonBreath
A stronger weapon used for dragon-related combat behavior.
Armor
Armor
Abstract armor type with:
- defense
- maximum defense
- durability
- maximum durability
- broken state
Armor can be repaired, and when durability reaches zero, its defense drops to zero.
KnightArmor
A concrete armor type used by the player in the main game flow.
Flask
A healing item that restores a fraction of the target’s maximum HP.
Location
Location is a simple class that stores a location name and one enemy.