Files
HW-04-JAVA-KNIGHT/README.md
T
2026-05-15 16:47:07 +03:30

129 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Fourth Assignment - Java Knight ⚔️
A turn-based RPG with Roguelike elements which can be run in the terminal.
---
## Introduction
Welcome to the epic world of our RPG! In this role-playing adventure,
you step into the shoes of a valiant hero tasked with battling various monsters!
---
## Compile and run the project
1. **Fork** this repository and clone it to your local machine.
```bash
git clone https://git.meshcomp.ir/Fateme_Azizi/HW-04-JAVA-KNIGHT.git
```
2. **Navigate** to the project directory:
```bash
cd HW-04-JAVA-KNIGHT
```
3. **Compile** the java files
```bash
javac Main.java
```
4. **Run** the code
```bash
java Main
```
This command will run the Main class, which serves as the entry point for the application, and start the game.
---
## Classes and OOP Principles
This project has been developed adhering to Object-Oriented Programming (OOP) principles and
incorporates several key design patterns to ensure the code is clean, maintainable, and scalable.
### Core classes
* `Entity` (Abstract): The base class for all living entities in the game (both players and enemies).
It encapsulates common attributes such as name, health, and basic stats.
* `Player` (Abstract): The base class for player characters. It manages player-specific attributes like XP, mana, health, and core abilities.
* `Assassin`, `Knight`, `Wizard`: These are subclasses of `Player`, each with unique abilities, stats, and playstyles.
* `Enemy` (Abstract): The base class for all monsters. It contains the fundamental logic for combat, XP rewards, and aliveness status.
* `Dragon`, `Goblin`, `Skeleton`, `Vampire`: These are subclasses of `Enemy`, each possessing distinct behaviors, stats, and special abilities.
* `EnemyStats`, `PlayerStats`: Dedicated classes for managing and holding the data for players and enemies (e.g., attack power, defense).
This promotes separation of data from the core logic of the entity classes.
* `Location`: Represents different areas or zones within the game world. Each location contains a list of enemies.
* `Main`: The primary class of the application, acting as the program's entry point. It is responsible for the initial setup, managing the main game loop, and calls to location and combat logic.
### OOP Principles Employed:
* **Encapsulation**: Data (variables) and behaviors (methods) are bundled within classes.
Access to data is controlled through getter and setter methods, ensuring data integrity.
* **Abstraction**: Abstract classes like `Entity`, `Player`, and `Enemy` define common interfaces and behaviors without implementing all details,
allowing subclasses to provide specific implementations.
* **Inheritance**: Concrete classes (`Dragon`, `Assassin`) inherit properties and methods from their base classes (`Enemy`, `Player`),
extending or modifying them as needed.
* **Polymorphism**: Objects of different classes can be treated through a common interface. For example, calling an `attack()` method on different `Player` or `Enemy` objects will result in distinct behaviors specific to each type.
---
## Gameplay Guide
This is your guide to navigating the world, battling monsters, and becoming a legend.
### How to Play
The game is played through text commands in your computers terminal. When the game asks you to do something, just type your answer and press Enter.
* **Exploration**: Youll move between different places in the game world. Each place might have different monsters.
* **Combat**: When you meet a monster, a battle will begin. Youll need to choose your actions wisely to win.
### Understanding your stats
Heres what your heros (and the monsters) numbers mean:
* **Health Points (HP)**: This is your life bar. If your HP drops to 0, you lose the battle. Keep an eye on it!
* **Attack Power**: This number shows how much damage you deal with each normal hit or spell. Higher is better!
* **Defense**: This helps reduce the damage you take from enemy attacks. A good defense keeps you in the fight longer.
* **Mana Points (MP)**: heroes use MP to do actions (only light attack doesn't use MP).
* **Experience Points (XP)**: You earn XP by winning battles against monsters.
### Your Hero
You can choose to be one of three types of heroes.
Each has a special ability:
* `Knight⚔️`: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage.
* `Wizard🧙‍♂️`: Casts a devastating spell that damages the enemy while simultaneously replenishing some HP.
* `Assassin🗡️`: Turns invisible, dodging the next incoming attack completely and guaranteeing a Critical Hit on their next turn.
### Monsters Youll Face
The world is full of creatures youll need to defeat:
* `Goblin👹`: Small, common enemies. Good for practicing your fighting skills and earning early XP.
* `Skeleton☠️`: These reanimated bones can be tricky. Some might even get back up after you defeat them!
* `Vampire🦇`: Dangerous creatures that can drain your health. Be careful when fighting them!
* `Dragon🐉`: One of the most powerful enemies in the game. Youll need to be well-prepared and use all your skills to defeat a dragon.
### Winning the Game
To win, youll need to explore, get stronger by leveling up your chosen hero,
and use your skills effectively in combat to defeat all the challenging monsters, culminating in the defeat of the most powerful threats.
Good luck on your adventure!