Java-Ring is a turn-based RPG inspired by Souls-like games, designed as a console-based game in Java. The player engages in battles against enemies, each possessing unique abilities. The goal is to defeat all enemies while strategically managing health, mana, and equipment. The player can attack, use consumables, or activate their class-specific unique ability.
This project was developed as part of a university programming assignment to demonstrate an understanding of Object-Oriented Programming (OOP) principles, including inheritance, polymorphism, and interfaces. Additionally, the project implements game logic such as combat mechanics, item usage, and unique character abilities, reinforcing Java programming skills.
The game follows a turn-based combat system where the player and the enemy take turns performing actions. The player can:
- Attack using a weapon.
- Use a Flask to restore health.
- Use a unique ability (if conditions allow).
Each enemy also has distinct behaviors and abilities, affecting how combat plays out.
The player can choose one of the following three classes, each with a special ability:
- Knight - Can perform a strong kick that deals extra damage but can only be used after a certain number of rounds.
- Wizard - Can cast a special spell that both heals themselves and damages the enemy.
- Assassin - Can become invisible for three turns, making them immune to attacks while dealing increased damage.
Each class starts with specific health (HP), mana (MP), and equipment.
Each enemy has its own combat style and ability:
- Goblin - A standard enemy with no special abilities.
- Skeleton - Can resurrect once after being defeated, returning with partial health.
- Dragon - Can bypass shields, damaging players even if they are defending.
The game includes items that help the player survive combat:
- Flask - Restores a set amount of HP in the combat.
- Potion - Allowing the player to heal and restore more HP at Safe Haven.
- Armor provides damage reduction but can break over time.
- Weapons influence attack power and can also degrade after repeated use.
- Players can repair their equipment at the Safe Haven, a resting area in the game.
- Ruined Castle - Home to a single Skeleton.
- Dark Forest - Home to a single Goblin.
- Dragon’s Lair - Home to a single Dragon.
- Safe Haven - A location where the player can rest and repair their equipment.
The game utilizes OOP principles effectively:
Playeris an abstract superclass, extended byKnight,Wizard, andAssassin.Enemyis a superclass, extended byGoblin,Skeleton, andDragon.ArmorandWeaponare base classes that provide functionality for all armor and weapon types.- The
GameManagerclass controls the main game logic, including combat interactions and turn management.
Each subclass overrides methods from the parent class to define unique behaviors:
useUniqueAbility()is overridden in each player subclass to implement the class-specific ability.attack()is overridden for the Dragon, as it has a unique attack style.takeDamage()is customized for Skeleton, allowing it to revive once.
- A generic
Entityinterface is used for bothPlayerandEnemyclasses. Objectinterface is implemented by consumables, weapons, and armor to standardize their behavior.
- The game starts, and the player is placed in a location with an enemy.
- On each turn, the player chooses an action: Attack, Use Flask, or Use Unique Ability.
- The enemy retaliates if still alive.
- If the player wins, they move to a new location until all enemies are defeated.
public void attack(Entity target) {
if (random.nextInt(100) < 30) { // 30% chance to use unique ability
System.out.println("🔥 The Dragon unleashes its fiery breath, bypassing your armor!");
target.takeDamage(getDamage()); // Ignores armor
} else {
Player player = (Player) target;
if (!player.getArmor().isBroken()) {
int damageTaken = player.getArmor().reduceDamage(getDamage());
player.takeDamage(damageTaken);
} else {
player.takeDamage(getDamage());
}
}
}- Ensures only valid inputs (e.g., numbers for menu choices) are accepted.
- Prevents players from using abilities without enough mana.
- Checks if armor or weapons are broken before applying their effects.
- Implementing polymorphism correctly for player and enemy classes.
- Managing player actions dynamically based on armor state, mana, and unique abilities.
- Ensuring that the Assassin remains immune for three turns while still allowing the player to attack.
- Used casting (e.g.,
(Player) target) to differentiate between entity types in combat. - Added turn counters for time-based abilities (e.g., Assassin’s invisibility).
- Implemented durability checks for weapons and armor to ensure proper functionality.
- Implementing a graphical user interface (GUI) using JavaFX.
- Expanding the game world with more locations and enemies.
- Introducing a leveling system for player progression.
- Adding multiplayer functionality.
- Enhanced AI: Enemies could have smarter decision-making instead of random attacks.
- More Weapons & Armors: Providing different weapons with special abilities.
This project successfully implements a turn-based RPG game using Java and OOP principles. The game includes various player classes, enemies, consumables, and a structured combat system. While the project is complete, there is potential for future improvements, such as a GUI, AI enhancements, and expanded game mechanics.
Through this project, valuable lessons were learned about game development, object-oriented programming, and designing interactive systems in Java.