diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 4158879..4e0bf3c 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -16,5 +16,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown.xml b/.idea/markdown.xml
index f6d2542..41485b3 100644
--- a/.idea/markdown.xml
+++ b/.idea/markdown.xml
@@ -1,6 +1,9 @@
+
\ No newline at end of file
diff --git a/Java-Knight/src/main/java/org/project/GameEngine.java b/Java-Knight/src/main/java/org/project/GameEngine.java
new file mode 100644
index 0000000..aa3fb6a
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/GameEngine.java
@@ -0,0 +1,274 @@
+package org.project;
+
+import org.project.entity.players.Player;
+import org.project.entity.players.Knight;
+import org.project.entity.players.Wizard;
+import org.project.entity.players.Assassin;
+
+import org.project.entity.enemies.Enemy;
+import org.project.entity.enemies.Goblin;
+import org.project.entity.enemies.Skeleton;
+import org.project.entity.enemies.Vampire;
+import org.project.entity.enemies.Dragon;
+
+import org.project.item.Item;
+
+import org.project.location.Location;
+
+import java.util.*;
+
+public class GameEngine {
+
+ private Player player;
+ private Location currentLocation;
+ private Location castle;
+
+ private Scanner scanner;
+
+ private Map possibleEnemiesMap = new HashMap<>();
+
+ private Enemy currentEnemy;
+
+ public GameEngine() {
+ scanner = new Scanner(System.in);
+ setupGame();
+ }
+
+ private void setupGame() {
+
+ System.out.println("Choose your class:");
+ System.out.println("1. Knight");
+ System.out.println("2. Mage");
+ System.out.println("3. Assassin");
+
+ int choice = scanner.nextInt();
+ scanner.nextLine();
+
+ switch (choice) {
+ case 1:
+ player = new Knight("Hero");
+ break;
+ case 2:
+ player = new Wizard("Hero");
+ break;
+ case 3:
+ player = new Assassin("Hero");
+ break;
+ default:
+ System.out.println("Invalid choice, defaulting to Knight.");
+ player = new Knight("Hero");
+ }
+
+ Location village = new Location("Village");
+ Location forest = new Location("Forest");
+ Location dungeon = new Location("Dungeon");
+ Location graveyard = new Location("Graveyard");
+
+ castle = new Location("Castle");
+
+ village.connectLocation(forest);
+ forest.connectLocation(village);
+
+ forest.connectLocation(dungeon);
+ dungeon.connectLocation(forest);
+
+ forest.connectLocation(graveyard);
+ graveyard.connectLocation(forest);
+
+ village.connectLocation(castle);
+ castle.connectLocation(village);
+
+ currentLocation = village;
+
+ possibleEnemiesMap.put(forest, new Enemy[] { new Goblin() });
+ possibleEnemiesMap.put(dungeon, new Enemy[] { new Skeleton(), new Vampire() });
+ possibleEnemiesMap.put(graveyard, new Enemy[] { new Skeleton(), new Vampire() });
+ possibleEnemiesMap.put(castle, new Enemy[] { new Dragon() });
+
+ spawnEnemyForLocation(currentLocation);
+ }
+
+ private void spawnEnemyForLocation(Location loc) {
+ Enemy[] possibilities = possibleEnemiesMap.get(loc);
+ if (possibilities == null || possibilities.length == 0) {
+ currentEnemy = null;
+ return;
+ }
+
+ Random rand = new Random();
+ Enemy template = possibilities[rand.nextInt(possibilities.length)];
+ currentEnemy = createEnemyInstance(template);
+ }
+
+ private Enemy createEnemyInstance(Enemy e) {
+ if (e instanceof Goblin) return new Goblin();
+ if (e instanceof Skeleton) return new Skeleton();
+ if (e instanceof Vampire) return new Vampire();
+ if (e instanceof Dragon) return new Dragon();
+ return null;
+ }
+
+ public void startGame() {
+
+ System.out.println("=== RPG Game Started ===");
+
+ boolean running = true;
+
+ while (running) {
+
+ System.out.println("\n===== MENU =====");
+
+ System.out.println("Location: " + currentLocation.getName());
+ System.out.println("HP: " + player.getHp());
+ System.out.println("Mana: " + player.getMana());
+ System.out.println("Level: " + player.getLevel());
+ System.out.println("XP: " + player.getXp());
+ System.out.println("Keys: " + player.getKeyCount());
+
+ System.out.println("\n1. Move");
+ System.out.println("2. Fight");
+ System.out.println("3. Show Inventory");
+ System.out.println("4. Exit");
+
+ int choice = scanner.nextInt();
+ scanner.nextLine();
+
+ switch (choice) {
+ case 1:
+ move();
+ break;
+ case 2:
+ fight();
+ break;
+ case 3:
+ player.getInventory().showInventory();
+ break;
+ case 4:
+ running = false;
+ System.out.println("Game Over.");
+ break;
+ default:
+ System.out.println("Invalid choice.");
+ }
+
+ if (!player.isAlive()) {
+ System.out.println("\nYou died. Game Over.");
+ running = false;
+ }
+ }
+ }
+
+ private void move() {
+ if (currentLocation.getConnectedLocations().isEmpty()) {
+ System.out.println("No connected locations.");
+ return;
+ }
+
+ System.out.println("\nWhere do you want to go?");
+
+ for (int i = 0; i < currentLocation.getConnectedLocations().size(); i++) {
+ System.out.println((i + 1) + ". " + currentLocation.getConnectedLocations().get(i).getName());
+ }
+
+ int choice = scanner.nextInt();
+
+ if (choice < 1 || choice > currentLocation.getConnectedLocations().size()) {
+ System.out.println("Invalid choice.");
+ return;
+ }
+
+ Location nextLocation = currentLocation.getConnectedLocations().get(choice - 1);
+
+ if (nextLocation == castle && player.getKeyCount() < 3) {
+ System.out.println("\nThe castle gate is locked!");
+ System.out.println("You need 3 keys.");
+ return;
+ }
+
+ currentLocation = nextLocation;
+
+ spawnEnemyForLocation(currentLocation);
+
+ System.out.println("\nYou moved to " + currentLocation.getName());
+
+ if (currentLocation == castle) {
+ System.out.println("\nThe final battle awaits...");
+ }
+ }
+
+ private void fight() {
+ if (currentEnemy == null || !currentEnemy.isAlive()) {
+ System.out.println("No enemies here.");
+ return;
+ }
+
+ Enemy enemy = currentEnemy;
+
+ System.out.println("\nA wild " + enemy.getName() + " appeared!");
+
+ while (player.isAlive() && enemy.isAlive()) {
+
+ System.out.println("\n===== COMBAT =====");
+ System.out.println(player.getName() + " HP: " + player.getHp());
+ System.out.println(enemy.getName() + " HP: " + enemy.getHp());
+
+ System.out.println("\nChoose action:");
+ System.out.println("1. Light Attack");
+ System.out.println("2. Heavy Attack");
+ System.out.println("3. Defend");
+ System.out.println("4. Heal");
+ System.out.println("5. Special Ability");
+
+ int choice = scanner.nextInt();
+ scanner.nextLine();
+
+ switch (choice) {
+ case 1:
+ player.lightAttack(enemy);
+ break;
+ case 2:
+ player.heavyAttack(enemy);
+ break;
+ case 3:
+ player.defend();
+ break;
+ case 4:
+ player.heal();
+ break;
+ case 5:
+ player.specialAbility(enemy);
+ break;
+ default:
+ System.out.println("Invalid choice.");
+ continue;
+ }
+
+ if (enemy.isAlive()) {
+ System.out.println("\n" + enemy.getName() + "'s turn!");
+ enemy.attack(player);
+ }
+ }
+
+ if (!enemy.isAlive()) {
+ System.out.println("\n" + enemy.getName() + " was defeated!");
+
+ player.gainXP(enemy.getXpReward());
+
+ Item loot = enemy.dropLoot();
+
+ if (loot != null) {
+ player.getInventory().addItem(loot);
+ System.out.println(enemy.getName() + " dropped: " + loot.getName());
+ }
+
+ currentEnemy = null;
+
+ if (enemy instanceof Dragon) {
+ System.out.println("\n====================");
+ System.out.println("YOU DEFEATED THE DRAGON!");
+ System.out.println("====== YOU WIN ======");
+ System.exit(0);
+ }
+ }
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/Inventory.java b/Java-Knight/src/main/java/org/project/Inventory.java
new file mode 100644
index 0000000..2d5a822
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/Inventory.java
@@ -0,0 +1,46 @@
+package org.project.inventory;
+
+import org.project.item.Item;
+
+import java.util.ArrayList;
+
+public class Inventory {
+
+ private ArrayList- items;
+
+ public Inventory() {
+ items = new ArrayList<>();
+ }
+
+ public void addItem(Item item) {
+
+ items.add(item);
+
+ System.out.println(item.getName() + " added to inventory.");
+ }
+
+ public void removeItem(Item item) {
+ items.remove(item);
+ }
+
+ public ArrayList
- getItems() {
+ return items;
+ }
+
+ public void showInventory() {
+
+ if(items.isEmpty()) {
+ System.out.println("Inventory is empty.");
+ return;
+ }
+
+ System.out.println("=== Inventory ===");
+
+ for(int i = 0; i < items.size(); i++) {
+
+ System.out.println(
+ (i + 1) + ". " + items.get(i).getName()
+ );
+ }
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/Main.java b/Java-Knight/src/main/java/org/project/Main.java
index 6bde20e..dd34305 100644
--- a/Java-Knight/src/main/java/org/project/Main.java
+++ b/Java-Knight/src/main/java/org/project/Main.java
@@ -1,15 +1,10 @@
package org.project;
-import org.project.location.Location;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.project.GameEngine;
public class Main {
public static void main(String[] args) {
- // TODO: ADD LOCATIONS TO YOUR GAME
- List locations = new ArrayList<>();
-
- // TODO: IMPLEMENT GAMEPLAY
+ GameEngine game = new GameEngine();
+ game.startGame();
}
-}
\ No newline at end of file
+}
diff --git a/Java-Knight/src/main/java/org/project/entity/Entity.java b/Java-Knight/src/main/java/org/project/entity/Entity.java
index 2a060f9..9ba31fa 100644
--- a/Java-Knight/src/main/java/org/project/entity/Entity.java
+++ b/Java-Knight/src/main/java/org/project/entity/Entity.java
@@ -1,21 +1,128 @@
package org.project.entity;
-public interface Entity {
- void attack(Entity target);
+import org.project.item.weapons.Weapon;
- void defend();
+public abstract class Entity {
- void heal(int health);
+ protected String name;
+ protected int hp;
+ protected int maxHp;
- void fillMana(int mana);
+ protected int mana;
+ protected int maxMana;
- void takeDamage(int damage);
+ protected Weapon weapon;
- int getMaxHP();
+ protected boolean isDefending;
- int getMaxMP();
+ public Entity(String name, int hp, int mana, Weapon weapon) {
- /*
- TODO: ADD OTHER REQUIRED AND BONUS METHODS
- */
+ this.name = name;
+
+ this.hp = hp;
+ this.maxHp = hp;
+
+ this.mana = mana;
+ this.maxMana = mana;
+
+ this.weapon = weapon;
+
+ this.isDefending = false;
+ }
+
+ public boolean useMana(int amount) {
+
+ if (mana >= amount) {
+
+ mana -= amount;
+ return true;
+ }
+
+ return false;
+ }
+
+ public void takeDamage(int damage) {
+
+ if (isDefending) {
+ damage /= 2;
+ }
+
+ hp -= damage;
+
+ if (hp < 0) {
+ hp = 0;
+ }
+
+ System.out.println(name + " took " + damage + " damage.");
+ }
+
+ public void heal(int amount) {
+
+ hp += amount;
+
+ if (hp > maxHp) {
+ hp = maxHp;
+ }
+
+ System.out.println(name + " healed for " + amount + " HP.");
+ }
+
+ public boolean isAlive() {
+ return hp > 0;
+ }
+
+ public void defend() {
+
+ isDefending = true;
+
+ System.out.println(name + " is defending.");
+ }
+
+ public void resetDefending() {
+ isDefending = false;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getHp() {
+ return hp;
+ }
+
+ public void setHp(int hp) {
+ this.hp = hp;
+ }
+
+ public int getMaxHp() {
+ return maxHp;
+ }
+
+ public int getMana() {
+ return mana;
+ }
+
+ public void setMana(int mana) {
+ this.mana = mana;
+ }
+
+ public int getMaxMana() {
+ return maxMana;
+ }
+
+ public Weapon getWeapon() {
+ return weapon;
+ }
+
+ public void setWeapon(Weapon weapon) {
+ this.weapon = weapon;
+ }
+
+ public boolean isDefending() {
+ return isDefending;
+ }
+
+ public void setDefending(boolean defending) {
+ isDefending = defending;
+ }
}
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java
new file mode 100644
index 0000000..bbd59d8
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java
@@ -0,0 +1,24 @@
+package org.project.entity.enemies;
+
+import org.project.entity.Entity;
+import org.project.item.weapons.Staff;
+
+public class Dragon extends Enemy {
+
+ public Dragon() {
+ super("Dragon", 300, 100, new Staff() , 150);
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+ int damage = getWeapon().getDamage() * 3;
+
+
+
+ target.takeDamage(damage);
+
+
+ System.out.println(getName() + " uses Breath Fire!");
+ System.out.println(target.getName() + " takes " + damage + " fire damage.");
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java b/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java
index e019acb..b9f5a45 100644
--- a/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java
@@ -1,34 +1,69 @@
package org.project.entity.enemies;
+import org.project.entity.Entity;
+import org.project.item.Item;
+import org.project.item.Key;
+import org.project.item.consumables.Flask;
import org.project.item.weapons.Weapon;
-// TODO: UPDATE IMPLEMENTATION
-public abstract class Enemy {
- Weapon weapon;
- private int hp;
- private int mp;
+import java.util.Random;
- public Enemy(int hp, int mp, Weapon weapon) {
- this.hp = hp;
- this.mp = mp;
+public abstract class Enemy extends Entity {
- this.weapon = weapon;
+ protected int xpReward;
+
+ public Enemy(String name, int hp, int mana, Weapon weapon, int xpReward) {
+
+ super(name, hp, mana, weapon);
+
+ this.xpReward = xpReward;
}
- @Override
- public void takeDamage(int damage) {
- hp -= damage;
+ public int getXpReward() {
+ return xpReward;
}
- public int getHp() {
- return hp;
+ public void attack(Entity target) {
+
+ int damage = 0;
+
+ if (weapon != null) {
+ damage = weapon.getDamage();
+ }
+
+ target.takeDamage(damage);
+
+ System.out.println(name + " attacks " + target.getName());
+
+ target.resetDefending();
}
- public int getMp() {
- return mp;
+ public void defend() {
+
+ setDefending(true);
+
+ System.out.println(name + " is defending.");
}
- public Weapon getWeapon() {
- return weapon;
+
+ public Item dropLoot() {
+
+ Random random = new Random();
+
+ int chance = random.nextInt(100);
+
+ if (chance < 30) {
+ return new Flask();
+ }
+
+ if (chance >= 30 && chance < 40) {
+ return new Key("Castle Key");
+ }
+
+ return null;
}
+
+
+
+ public abstract void specialAbility(Entity target);
}
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java
new file mode 100644
index 0000000..c3d4add
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java
@@ -0,0 +1,22 @@
+package org.project.entity.enemies;
+
+import org.project.entity.Entity;
+import org.project.item.weapons.Dagger;
+
+public class Goblin extends Enemy {
+
+ public Goblin() {
+ super("Goblin", 80, 0, new Dagger() , 20);
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+ int damage = getWeapon().getDamage() + 5;
+
+ target.takeDamage(damage);
+
+
+ System.out.println("Goblin uses Sneak Attack!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Skeleton.java b/Java-Knight/src/main/java/org/project/entity/enemies/Skeleton.java
index 8a6a555..f01f90e 100644
--- a/Java-Knight/src/main/java/org/project/entity/enemies/Skeleton.java
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Skeleton.java
@@ -1,6 +1,18 @@
package org.project.entity.enemies;
-// TODO: UPDATE IMPLEMENTATION
-public class Skeleton {
- // TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
+import org.project.entity.Entity;
+import org.project.item.weapons.Sword;
+
+public class Skeleton extends Enemy {
+
+ public Skeleton() {
+ super("Skeleton", 100, 0, new Sword() , 30);
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+ defend();
+
+ System.out.println("Skeleton raises its shield.");
+ }
}
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java b/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java
new file mode 100644
index 0000000..8b81622
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java
@@ -0,0 +1,24 @@
+package org.project.entity.enemies;
+
+import org.project.entity.Entity;
+import org.project.item.weapons.Dagger;
+
+public class Vampire extends Enemy {
+
+ public Vampire() {
+ super("Vampire", 120, 50, new Dagger() , 50);
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+ int damage = getWeapon().getDamage() * 2;
+
+ target.takeDamage(damage);
+
+
+ setHp(getHp() + damage / 2);
+
+ System.out.println("Vampire uses Life Drain!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java
new file mode 100644
index 0000000..0383499
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java
@@ -0,0 +1,76 @@
+package org.project.entity.players;
+
+import org.project.entity.Entity;
+import org.project.item.armors.AssassinArmor;
+import org.project.item.weapons.Dagger;
+
+public class Assassin extends Player {
+
+ public Assassin(String name) {
+ super(name, 120, 80, new Dagger());
+ }
+
+ @Override
+ public void heavyAttack(Entity target) {
+
+ int manaCost = 15;
+
+ if (getMana() < manaCost) {
+ System.out.println("Not enough mana!");
+ return;
+ }
+
+ useMana(manaCost);
+
+ int damage = weapon.getDamage() * 2;
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.takeDamage(damage);
+
+
+ System.out.println(name + " performs a deadly strike!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+
+ @Override
+ public void heal() {
+
+ int healAmount = 20;
+ int manaGain = 20;
+
+ setHp(Math.min(getHp() + healAmount, getMaxHp()));
+
+ setMana(Math.min(getMana() + manaGain, getMaxMana()));
+
+
+ System.out.println(name + " regains " + healAmount + " HP and " + manaGain + " mana.");
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+
+ int manaCost = 30;
+
+ if (getMana() < manaCost) {
+ System.out.println("Not enough mana!");
+ return;
+ }
+
+ useMana(manaCost);
+
+ int damage = weapon.getDamage() * 3;
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.takeDamage(damage);
+
+
+ System.out.println(name + " uses Shadow Strike!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/entity/players/CombatActions.java b/Java-Knight/src/main/java/org/project/entity/players/CombatActions.java
new file mode 100644
index 0000000..a271818
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/players/CombatActions.java
@@ -0,0 +1,16 @@
+package org.project.entity.players;
+
+import org.project.entity.Entity;
+
+public interface CombatActions {
+
+ void lightAttack(Entity target);
+
+ void heavyAttack(Entity target);
+
+ void defend();
+
+ void heal();
+
+ void specialAbility(Entity target);
+}
diff --git a/Java-Knight/src/main/java/org/project/entity/players/Knight.java b/Java-Knight/src/main/java/org/project/entity/players/Knight.java
index 14d8fa2..08f43af 100644
--- a/Java-Knight/src/main/java/org/project/entity/players/Knight.java
+++ b/Java-Knight/src/main/java/org/project/entity/players/Knight.java
@@ -1,6 +1,54 @@
package org.project.entity.players;
-// TODO: UPDATE IMPLEMENTATION
-public class Knight {
- // TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
+import org.project.entity.Entity;
+import org.project.item.armors.KnightArmor;
+import org.project.item.weapons.Sword;
+
+public class Knight extends Player {
+
+ public Knight(String name) {
+ super(name, 150, 50, new Sword());
+ }
+
+ @Override
+ public void heavyAttack(Entity target) {
+
+ int damage = weapon.getDamage() * 2;
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.takeDamage(damage);
+
+
+ System.out.println(name + " performs a heavy sword strike!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+
+ @Override
+ public void heal() {
+
+ int healAmount = 30;
+ setHp(Math.min(getHp() + healAmount, getMaxHp()));
+
+
+ System.out.println(name + " recovers " + healAmount + " HP.");
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+
+ int damage = weapon.getDamage() + 20;
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.takeDamage(damage);
+
+
+ System.out.println(name + " uses Shield Bash!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
}
diff --git a/Java-Knight/src/main/java/org/project/entity/players/Player.java b/Java-Knight/src/main/java/org/project/entity/players/Player.java
index ff5385c..bb21db8 100644
--- a/Java-Knight/src/main/java/org/project/entity/players/Player.java
+++ b/Java-Knight/src/main/java/org/project/entity/players/Player.java
@@ -1,89 +1,138 @@
package org.project.entity.players;
import org.project.entity.Entity;
-import org.project.item.armors.Armor;
+import org.project.inventory.Inventory;
import org.project.item.weapons.Weapon;
-// TODO: UPDATE IMPLEMENTATION
-public abstract class Player {
- protected String name;
- Weapon weapon;
- Armor armor;
- private int hp;
- private int maxHP;
- private int mp;
- private int maxMP;
+public abstract class Player extends Entity implements CombatActions {
- public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
- this.name = name;
- this.hp = hp;
- this.mp = mp;
+ protected Inventory inventory;
- this.weapon = weapon;
- this.armor = armor;
+ protected int level;
+ protected int xp;
+ protected int xpToNextLevel;
+
+ protected int baseDamage;
+
+ public Player(String name,
+ int hp,
+ int mana,
+ Weapon weapon) {
+
+ super(name, hp, mana, weapon);
+
+ this.inventory = new Inventory();
+
+ this.level = 1;
+ this.xp = 0;
+ this.xpToNextLevel = 100;
+
+ this.baseDamage = 10;
+ }
+
+ public Inventory getInventory() {
+ return inventory;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public int getXp() {
+ return xp;
+ }
+
+ public int getBaseDamage() {
+ return baseDamage;
+ }
+
+ public void gainXP(int amount) {
+
+ xp += amount;
+
+ System.out.println(name + " gained " + amount + " XP!");
+
+ while (xp >= xpToNextLevel) {
+ levelUp();
+ }
+ }
+
+ private void levelUp() {
+
+ level++;
+
+ xp -= xpToNextLevel;
+
+ xpToNextLevel += 50;
+
+ maxHp += 20;
+ hp = maxHp;
+
+ maxMana += 10;
+ mana = maxMana;
+
+ baseDamage += 5;
+
+ System.out.println("\n=== LEVEL UP ===");
+ System.out.println(name + " reached level " + level);
+ System.out.println("HP increased!");
+ System.out.println("Mana increased!");
+ System.out.println("Damage increased!");
}
@Override
- public void attack(Entity target) {
- target.takeDamage(weapon.getDamage());
+ public void lightAttack(Entity target) {
+
+ System.out.println(
+ this.name +
+ " uses a light attack on " +
+ target.getName()
+ );
+
+ if (weapon != null) {
+
+ weapon.use(target);
+
+ } else {
+
+ target.takeDamage(baseDamage);
+
+ System.out.println("Basic attack dealt " +
+ baseDamage +
+ " damage.");
+ }
+
+ target.resetDefending();
}
@Override
public void defend() {
- // TODO
+
+ isDefending = true;
+
+ System.out.println(name + " is defending!");
}
+ public int getKeyCount() {
+ int count = 0;
- @Override
- public void takeDamage(int damage) {
- hp -= damage - armor.getDefense();
- }
+ for (var item : inventory.getItems()) {
- @Override
- public void heal(int health) {
- hp += health;
- if (hp > maxHP) {
- hp = maxHP;
+ if (item.getName().equals("Castle Key")) {
+ count++;
+ }
}
+
+ return count;
}
+
@Override
- public void fillMana(int mana) {
- mp += mana;
- if (mp > maxMP) {
- mp = maxMP;
- }
- }
-
-
- public String getName() {
- return name;
- }
-
- public int getHp() {
- return hp;
- }
+ public abstract void heavyAttack(Entity target);
@Override
- public int getMaxHP() {
- return maxHP;
- }
-
- public int getMp() {
- return mp;
- }
+ public abstract void heal();
@Override
- public int getMaxMP() {
- return maxMP;
- }
-
- public Weapon getWeapon() {
- return weapon;
- }
-
- public Armor getArmor() {
- return armor;
- }
-
+ public abstract void specialAbility(Entity target);
}
diff --git a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java
new file mode 100644
index 0000000..e29f310
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java
@@ -0,0 +1,80 @@
+package org.project.entity.players;
+
+import org.project.entity.Entity;
+import org.project.item.weapons.Staff;
+
+public class Wizard extends Player {
+
+ public Wizard(String name) {
+ super(name, 100, 150, new Staff());
+ }
+
+ @Override
+ public void heavyAttack(Entity target) {
+
+ int manaCost = 20;
+
+ if (getMana() < manaCost) {
+ System.out.println("Not enough mana!");
+ return;
+ }
+
+ useMana(manaCost);
+
+ int damage = weapon.getDamage() * 2;
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.takeDamage(damage);
+
+
+ System.out.println(name + " casts a powerful fire spell!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+
+ @Override
+ public void heal() {
+
+ int manaCost = 15;
+
+ if (getMana() < manaCost) {
+ System.out.println("Not enough mana!");
+ return;
+ }
+
+ useMana(manaCost);
+
+ int healAmount = 40;
+ setHp(Math.min(getHp() + healAmount, getMaxHp()));
+
+
+ System.out.println(name + " casts a healing spell and restores " + healAmount + " HP.");
+ }
+
+ @Override
+ public void specialAbility(Entity target) {
+
+ int manaCost = 40;
+
+ if (getMana() < manaCost) {
+ System.out.println("Not enough mana!");
+ return;
+ }
+
+ useMana(manaCost);
+
+ int damage = weapon.getDamage() * 3;
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.takeDamage(damage);
+
+
+ System.out.println(name + " unleashes Lightning Storm!");
+ System.out.println(target.getName() + " takes " + damage + " damage.");
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/Item.java b/Java-Knight/src/main/java/org/project/item/Item.java
index 6d6b5ad..6259726 100644
--- a/Java-Knight/src/main/java/org/project/item/Item.java
+++ b/Java-Knight/src/main/java/org/project/item/Item.java
@@ -3,9 +3,8 @@ package org.project.item;
import org.project.entity.Entity;
public interface Item {
- void use(Entity target);
- /*
- TODO: ADD OTHER REQUIRED AND BONUS METHODS
- */
+ String getName();
+
+ void use(Entity target);
}
diff --git a/Java-Knight/src/main/java/org/project/item/Key.java b/Java-Knight/src/main/java/org/project/item/Key.java
new file mode 100644
index 0000000..cc24a49
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/Key.java
@@ -0,0 +1,24 @@
+package org.project.item;
+
+import org.project.entity.Entity;
+import org.project.item.Item;
+
+public class Key implements Item {
+
+ private String name;
+
+ public Key(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void use(Entity target) {
+
+ System.out.println("This key is used automatically to unlock the castle.");
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/armors/Armor.java b/Java-Knight/src/main/java/org/project/item/armors/Armor.java
index 7ca8774..739a325 100644
--- a/Java-Knight/src/main/java/org/project/item/armors/Armor.java
+++ b/Java-Knight/src/main/java/org/project/item/armors/Armor.java
@@ -1,7 +1,7 @@
package org.project.item.armors;
-// TODO: UPDATE IMPLEMENTATION
public abstract class Armor {
+
private int defense;
private int maxDefense;
private int durability;
@@ -12,16 +12,25 @@ public abstract class Armor {
public Armor(int defense, int durability) {
this.defense = defense;
this.durability = durability;
+ this.maxDefense = defense;
+ this.maxDurability = durability;
+ this.isBroke = false;
}
public void checkBreak() {
if (durability <= 0) {
+ durability = 0;
isBroke = true;
defense = 0;
}
}
- // TODO: (BONUS) UPDATE THE REPAIR METHOD
+ public void takeDamage(int amount) {
+ durability -= amount;
+ checkBreak();
+ }
+
+
public void repair() {
isBroke = false;
defense = maxDefense;
@@ -29,6 +38,9 @@ public abstract class Armor {
}
public int getDefense() {
+ if (isBroke) {
+ return 0;
+ }
return defense;
}
diff --git a/Java-Knight/src/main/java/org/project/item/armors/AssassinArmor.java b/Java-Knight/src/main/java/org/project/item/armors/AssassinArmor.java
new file mode 100644
index 0000000..7b84021
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/armors/AssassinArmor.java
@@ -0,0 +1,7 @@
+package org.project.item.armors;
+
+public class AssassinArmor extends Armor {
+ public AssassinArmor(){
+ super(5,25);
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java b/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java
index eb59a46..c828cfb 100644
--- a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java
+++ b/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java
@@ -1,6 +1,9 @@
package org.project.item.armors;
-// TODO: UPDATE IMPLEMENTATION
-public class KnightArmor {
- // TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
-}
\ No newline at end of file
+public class KnightArmor extends Armor {
+
+ public KnightArmor() {
+ super(8, 40);
+ }
+
+}
diff --git a/Java-Knight/src/main/java/org/project/item/armors/MageArmor.java b/Java-Knight/src/main/java/org/project/item/armors/MageArmor.java
new file mode 100644
index 0000000..9dbcbe3
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/armors/MageArmor.java
@@ -0,0 +1,7 @@
+package org.project.item.armors;
+
+public class MageArmor extends Armor{
+ public MageArmor(){
+ super(2,15);
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java b/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java
index 028e13d..c581bc0 100644
--- a/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java
+++ b/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java
@@ -1,8 +1,17 @@
package org.project.item.consumables;
-// TODO: UPDATE IMPLEMENTATION
-public abstract class Consumable {
- /*
- TODO: ADD OTHER REQUIRED AND BONUS METHODS
- */
+import org.project.item.Item;
+
+public abstract class Consumable implements Item {
+
+ private String name;
+
+ public Consumable(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
}
diff --git a/Java-Knight/src/main/java/org/project/item/consumables/Flask.java b/Java-Knight/src/main/java/org/project/item/consumables/Flask.java
index c0e7a6d..dd05087 100644
--- a/Java-Knight/src/main/java/org/project/item/consumables/Flask.java
+++ b/Java-Knight/src/main/java/org/project/item/consumables/Flask.java
@@ -2,15 +2,33 @@ package org.project.item.consumables;
import org.project.entity.Entity;
-// TODO: UPDATE IMPLEMENTATION
-public class Flask {
- /*
- THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
- */
+public class Flask extends Consumable {
+
+ private int healAmount;
+
+ public Flask() {
+ super("Flask");
+ this.healAmount = 30;
+ }
- // TODO: UPDATE USE METHOD
@Override
public void use(Entity target) {
- target.heal(target.getMaxHP() / 10);
+
+ target.heal(healAmount);
+
+
+ System.out.println(
+ target.getName() +
+ " drinks a flask and restores " +
+ healAmount + " HP."
+ );
+ }
+
+ public int getHealAmount() {
+ return healAmount;
+ }
+
+ public void setHealAmount(int healAmount) {
+ this.healAmount = healAmount;
}
}
diff --git a/Java-Knight/src/main/java/org/project/item/weapons/Dagger.java b/Java-Knight/src/main/java/org/project/item/weapons/Dagger.java
new file mode 100644
index 0000000..d1766f1
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/weapons/Dagger.java
@@ -0,0 +1,28 @@
+package org.project.item.weapons;
+
+import org.project.entity.Entity;
+
+public class Dagger extends Weapon {
+
+ public Dagger() {
+ super(10, 0);
+ }
+
+ @Override
+ public String getName() {
+ return "Dagger";
+ }
+
+ @Override
+ public void use(Entity target) {
+ int damage = getDamage();
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.setHp(target.getHp() - damage);
+
+ System.out.println("Dagger deals " + damage + " damage to " + target.getName());
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/weapons/Staff.java b/Java-Knight/src/main/java/org/project/item/weapons/Staff.java
new file mode 100644
index 0000000..26d6e63
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/weapons/Staff.java
@@ -0,0 +1,28 @@
+package org.project.item.weapons;
+
+import org.project.entity.Entity;
+
+public class Staff extends Weapon {
+
+ public Staff() {
+ super(12, 5);
+ }
+
+ @Override
+ public String getName() {
+ return " Staff";
+ }
+
+ @Override
+ public void use(Entity target) {
+ int damage = getDamage();
+
+ if (target.isDefending()) {
+ damage /= 2;
+ }
+
+ target.setHp(target.getHp() - damage);
+
+ System.out.println("Staff deals " + damage + " damage to " + target.getName());
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/weapons/Sword.java b/Java-Knight/src/main/java/org/project/item/weapons/Sword.java
index 96226ee..748d9f7 100644
--- a/Java-Knight/src/main/java/org/project/item/weapons/Sword.java
+++ b/Java-Knight/src/main/java/org/project/item/weapons/Sword.java
@@ -2,25 +2,27 @@ package org.project.item.weapons;
import org.project.entity.Entity;
-import java.util.ArrayList;
-
-// TODO: UPDATE IMPLEMENTATION
-public class Sword {
- /*
- THIS IS AN EXAMPLE OF A WEAPON DESIGN.
- */
-
- int abilityCharge;
+public class Sword extends Weapon {
public Sword() {
- // TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
+ super(15, 0);
}
- // TODO: (BONUS) UPDATE THE UNIQUE ABILITY
- public void uniqueAbility(ArrayList targets) {
- abilityCharge += 2;
- for (Entity target : targets) {
- target.takeDamage(getDamage());
+ @Override
+ public String getName() {
+ return "Sword";
+ }
+
+ @Override
+ public void use(Entity target) {
+ int damage = getDamage();
+
+ if (target.isDefending()) {
+ damage /= 2;
}
+
+ target.setHp(target.getHp() - damage);
+
+ System.out.println("Sword deals " + damage + " damage to " + target.getName());
}
}
diff --git a/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java b/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java
index cb9fcf2..cf156a6 100644
--- a/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java
+++ b/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java
@@ -1,26 +1,18 @@
package org.project.item.weapons;
import org.project.entity.Entity;
+import org.project.item.Item;
+
+public abstract class Weapon implements Item {
-// TODO: UPDATE IMPLEMENTATION
-public abstract class Weapon {
private int damage;
private int manaCost;
- /*
- TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
- */
-
public Weapon(int damage, int manaCost) {
this.damage = damage;
this.manaCost = manaCost;
}
- @Override
- public void use(Entity target) {
- target.takeDamage(damage);
- }
-
public int getDamage() {
return damage;
}
@@ -29,7 +21,14 @@ public abstract class Weapon {
return manaCost;
}
- /*
- TODO: ADD OTHER REQUIRED AND BONUS METHODS
- */
+ public void setDamage(int damage) {
+ this.damage = damage;
+ }
+
+ public void setManaCost(int manaCost) {
+ this.manaCost = manaCost;
+ }
+
+
+ public abstract void use(Entity target);
}
diff --git a/Java-Knight/src/main/java/org/project/location/Location.java b/Java-Knight/src/main/java/org/project/location/Location.java
index b0b4b98..67ef7ac 100644
--- a/Java-Knight/src/main/java/org/project/location/Location.java
+++ b/Java-Knight/src/main/java/org/project/location/Location.java
@@ -5,24 +5,40 @@ import org.project.entity.enemies.Enemy;
import java.util.ArrayList;
public class Location {
+
private String name;
+ private ArrayList connectedLocations;
+
private ArrayList enemies;
- public Location(ArrayList locations, ArrayList enemies) {
- this.locations = locations;
- this.enemies = enemies;
+ public Location(String name) {
+ this.name = name;
+ this.connectedLocations = new ArrayList<>();
+ this.enemies = new ArrayList<>();
}
public String getName() {
return name;
}
- public ArrayList getLocations() {
- return locations;
+ public ArrayList getConnectedLocations() {
+ return connectedLocations;
}
public ArrayList getEnemies() {
return enemies;
}
+
+ public void connectLocation(Location location) {
+ connectedLocations.add(location);
+ }
+
+ public void addEnemy(Enemy enemy) {
+ enemies.add(enemy);
+ }
+
+ public void removeEnemy(Enemy enemy) {
+ enemies.remove(enemy);
+ }
}
diff --git a/Java-Knight/target/classes/org/project/GameEngine.class b/Java-Knight/target/classes/org/project/GameEngine.class
new file mode 100644
index 0000000..04485bf
Binary files /dev/null and b/Java-Knight/target/classes/org/project/GameEngine.class differ
diff --git a/Java-Knight/target/classes/org/project/Main.class b/Java-Knight/target/classes/org/project/Main.class
new file mode 100644
index 0000000..d2ad8e6
Binary files /dev/null and b/Java-Knight/target/classes/org/project/Main.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/Entity.class b/Java-Knight/target/classes/org/project/entity/Entity.class
new file mode 100644
index 0000000..f71b47a
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/Entity.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Dragon.class b/Java-Knight/target/classes/org/project/entity/enemies/Dragon.class
new file mode 100644
index 0000000..bd5fd26
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Dragon.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Enemy.class b/Java-Knight/target/classes/org/project/entity/enemies/Enemy.class
new file mode 100644
index 0000000..56e3485
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Enemy.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Goblin.class b/Java-Knight/target/classes/org/project/entity/enemies/Goblin.class
new file mode 100644
index 0000000..90d3bb1
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Goblin.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class b/Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class
new file mode 100644
index 0000000..85790e9
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Vampire.class b/Java-Knight/target/classes/org/project/entity/enemies/Vampire.class
new file mode 100644
index 0000000..a23b214
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Vampire.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Assassin.class b/Java-Knight/target/classes/org/project/entity/players/Assassin.class
new file mode 100644
index 0000000..a138482
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Assassin.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/CombatActions.class b/Java-Knight/target/classes/org/project/entity/players/CombatActions.class
new file mode 100644
index 0000000..3ffe4fd
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/CombatActions.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Knight.class b/Java-Knight/target/classes/org/project/entity/players/Knight.class
new file mode 100644
index 0000000..63cde10
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Knight.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Mage.class b/Java-Knight/target/classes/org/project/entity/players/Mage.class
new file mode 100644
index 0000000..7d78636
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Mage.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Player.class b/Java-Knight/target/classes/org/project/entity/players/Player.class
new file mode 100644
index 0000000..33eaf8f
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Player.class differ
diff --git a/Java-Knight/target/classes/org/project/inventory/Inventory.class b/Java-Knight/target/classes/org/project/inventory/Inventory.class
new file mode 100644
index 0000000..1c798e3
Binary files /dev/null and b/Java-Knight/target/classes/org/project/inventory/Inventory.class differ
diff --git a/Java-Knight/target/classes/org/project/item/Item.class b/Java-Knight/target/classes/org/project/item/Item.class
new file mode 100644
index 0000000..1f8ab25
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/Item.class differ
diff --git a/Java-Knight/target/classes/org/project/item/Key.class b/Java-Knight/target/classes/org/project/item/Key.class
new file mode 100644
index 0000000..46c913c
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/Key.class differ
diff --git a/Java-Knight/target/classes/org/project/item/armors/Armor.class b/Java-Knight/target/classes/org/project/item/armors/Armor.class
new file mode 100644
index 0000000..2d618e3
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/armors/Armor.class differ
diff --git a/Java-Knight/target/classes/org/project/item/armors/AssassinArmor.class b/Java-Knight/target/classes/org/project/item/armors/AssassinArmor.class
new file mode 100644
index 0000000..01087f8
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/armors/AssassinArmor.class differ
diff --git a/Java-Knight/target/classes/org/project/item/armors/KnightArmor.class b/Java-Knight/target/classes/org/project/item/armors/KnightArmor.class
new file mode 100644
index 0000000..e1caccf
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/armors/KnightArmor.class differ
diff --git a/Java-Knight/target/classes/org/project/item/armors/MageArmor.class b/Java-Knight/target/classes/org/project/item/armors/MageArmor.class
new file mode 100644
index 0000000..36d514a
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/armors/MageArmor.class differ
diff --git a/Java-Knight/target/classes/org/project/item/consumables/Consumable.class b/Java-Knight/target/classes/org/project/item/consumables/Consumable.class
new file mode 100644
index 0000000..03951f8
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/consumables/Consumable.class differ
diff --git a/Java-Knight/target/classes/org/project/item/consumables/Flask.class b/Java-Knight/target/classes/org/project/item/consumables/Flask.class
new file mode 100644
index 0000000..92b8035
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/consumables/Flask.class differ
diff --git a/Java-Knight/target/classes/org/project/item/weapons/Dagger.class b/Java-Knight/target/classes/org/project/item/weapons/Dagger.class
new file mode 100644
index 0000000..0d81e74
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/weapons/Dagger.class differ
diff --git a/Java-Knight/target/classes/org/project/item/weapons/Staff.class b/Java-Knight/target/classes/org/project/item/weapons/Staff.class
new file mode 100644
index 0000000..a6e7ca7
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/weapons/Staff.class differ
diff --git a/Java-Knight/target/classes/org/project/item/weapons/Sword.class b/Java-Knight/target/classes/org/project/item/weapons/Sword.class
new file mode 100644
index 0000000..b91eb49
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/weapons/Sword.class differ
diff --git a/Java-Knight/target/classes/org/project/item/weapons/Weapon.class b/Java-Knight/target/classes/org/project/item/weapons/Weapon.class
new file mode 100644
index 0000000..72a4908
Binary files /dev/null and b/Java-Knight/target/classes/org/project/item/weapons/Weapon.class differ
diff --git a/Java-Knight/target/classes/org/project/location/Location.class b/Java-Knight/target/classes/org/project/location/Location.class
new file mode 100644
index 0000000..646eb57
Binary files /dev/null and b/Java-Knight/target/classes/org/project/location/Location.class differ
diff --git a/README.md b/README.md
index 1e2c975..84ec0d2 100644
--- a/README.md
+++ b/README.md
@@ -1,175 +1,146 @@
-# Fourth Assignment - Java Knight ⚔️
-A turn-based RPG with Roguelike elements which can be run in the terminal.
+# Java Knight Game
-### **Prologue: The Legend of Javanest**
-*For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!*
+## Project Overview
+Java Knight is a text-based RPG game developed using Object-Oriented Programming (OOP) principles in Java. The player selects a character class, explores different locations, fights enemies, collects items, and tries to unlock the Castle by gathering keys.
-### **Introduction**
-Welcome to **Java knight**, a turn-based RPG inspired by Roguelike games! In this assignment, you will develop a **text-based role-playing game (RPG)**. This project is designed to rigorously test your understanding of **Object-Oriented Programming (OOP) principles**.
-
-⚠️ **REQUIREMENT:** You **must** utilize all the OOP concepts you have learned so far—including *Inheritance, Interfaces, Abstract Classes, Encapsulation, Polymorphism, Overloading, and Overriding*. It is extremely important that you use everything in its right place. Your design and architecture will be graded based on how well you apply these principles to avoid code duplication and maintain a clean structure.
-
-🎯 **Your goal is not just to complete the assignment but to learn and apply OOP effectively!**
-
-### **What is a Turn-Based Game?**
-In this combat system, two sides - which are usually the player's side and the enemy's side - attack each other in turns. The side which is not attacking can perform actions to avoid or deflect the enemy's attack.
-
-### **Core Mechanics:**
-- **Turn-based combat** – Players and monsters take turns attacking each other.
-- **Character classes with Unique Traits** – Players can choose from archetypes like **Knight, Assassin, or Wizard**, each starting with distinctly different base stats.
-- **Unified Mana/Stamina System** – All player classes use a unified resource (Mana/Stamina) to perform actions.
-- **Standardized Action Set** – Every player character has exactly 5 specific actions available during their turn.
-- **Experience & Leveling System** – Earn XP based on enemy strength to automatically level up and increase your base stats.
-- **Progression System** – You cannot fight the Dragon immediately. You must farm enemies for a chance to drop their specific key, collect all three, and grow stronger first.
+The goal of the project is to demonstrate important OOP concepts such as inheritance, abstraction, polymorphism, and encapsulation while building a simple turn-based RPG system.
---
-## Tasks 📝
+## Game Flow
-### 1️⃣ Step 1: Fork & Setup 🍴
-1. **Fork** this repository and clone it to your local machine.
-```bash
-git clone https://git.meshcomp.ir/AdvancedProgramming1404/HW-04-JAVA-KNIGHT.git
-```
-2. Create a new branch named `develop` and switch to it.
-```bash
-git checkout -b develop
-```
-### 2️⃣ Step 2: Implement the Class Hierarchy 🌲
+### 1. Starting the Game
+When the program starts, the player enters their name and selects a character class. The available classes are:
-A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing shared logic in abstract classes.
+- Knight
+- Assassin
+- Wizard
-- **Entities & Locations:** You have `Entity`, `Item`(Bonus) , and `Location`.
-- **Players:** `Player` is an abstract class implementing `Entity`. Subclasses: `Wizard`, `Knight`, `Assassin`.
- - **Base Stat Differences:** Each class must have distinct starting stats. For example:
- - **Knight:** Highest Base Damage.
- - **Wizard:** Highest Max Health (HP).
- - **Assassin:** Highest Max Stamina/Mana.
-- **Enemies:** `Enemy` is an abstract class implementing `Entity`. Subclasses: `Skeleton`, `Goblin`, `Vampire`, and **`Dragon`**.
- - **The Boss:** Even though `Dragon` is the final boss, it **must** be a subclass of `Enemy` to inherit common combat properties, while possessing extremely high stats and unique mechanics.
-- **Item (Bonus):** `Consumable`, `Armor`, `Weapon` are abstract classes implementing `Item`. example :
- - KnightArmor extends Armor - you can add more subclasses of Armor for extra score
- - Sword extends Weapon - you can add more subclasses of Weapon for extra score
- - Flask extends Consumable - you can add more subclasses of Consumable for extra score
-
-
-
-### 3️⃣ Step 3: Implement Player & Monster Methods 🏹
-
-**Player Actions (The Rule of Five):**
-Every player class **must** implement exactly the following 5 actions (You can use an interface like `ICombatActions`). Every action (except Light Attack) consumes a specific amount of Mana/Stamina. The **Special Ability** must consume the *highest* amount of Mana compared to the others.
-1. **Light Attack:** Deals moderate damage and costs **NO Mana**. (Note: If the player runs out of Mana/Stamina, this is the ONLY action they can perform.)
-2. **Heavy Attack:** Deals high damage, medium Mana cost.
-3. **Defend:** Completely blocks or significantly reduces the damage of the enemy's *next* strike. Medium Mana cost.
-4. **Heal:** Restores a portion of the player's HP. Medium-high Mana cost.
-5. **Special Ability:** A unique class-based ultimate move (Highest Mana cost):
- - **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.
- - **Knight** ⚔️: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage.
-
-**Monster Abilities:**
-- **Goblin** 👹: High critical hit chance but low health.
-- **Skeleton** ☠️: Can resurrect once per battle with 50% HP.
-- **Vampire** 🦇: Lifesteal ability – a portion of the damage it deals to the player is added back to its own health.
-- **Dragon (Final Boss)** 🐉: Immune to normal defense. Its fiery breath bypasses shields and deals massive damage.
-
-🔹 Make sure each entity **prints messages** when performing actions. example output (while in combat) :
-
-```bash
-You chose to FIGHT!
-
-[Ser Duncan - 45/45 HP | 40/40 Mana]
-[Goblin - 30/30 HP]
+Each class has different attributes such as health, mana, and combat abilities.
---
-Your Turn:
-1. Light Attack | 2. Heavy Attack (-8 Mana) | 3. Defend (-6 Mana) | 4. Heal (-12 Mana) | 5. Shield Bash (-15 Mana)
-```
+### 2. Main Game Menu
+After character selection, the game enters a continuous game loop where the player can choose between several actions.
-```bash
-→ Chose: Light Attack
-⚔️ Ser Duncan (Knight) used Light Attack! (0 Mana)
-Goblin took 10 damage!
-Goblin has 20/30 HP remaining.
-Ser Duncan Mana: 40/40
-```
-```
-Goblin's Turn :
-👹 Goblin used Critical Strike!
-💥 Critical hit! Ser Duncan took 20 damage!
-Ser Duncan has 25/45 HP remaining.
-```
-🔹 *Narrative Console:* Use ANSI escape codes to print colorful narrative logs (e.g., Red for damage, Blue for Mana usage, Green for healing).
+The menu options are:
+1. Move
+2. Fight
+3. Show Inventory
+4. Exit
-### 4️⃣ Step 4: Implement the Game Loop & Progression 🎮
-
-1. **The Core Loop:** The game starts with the player entering a location. A random standard enemy (`Goblin`, `Skeleton`, or `Vampire`) spawns immediately.
-2. **Player Choices:** Before engaging, the player is presented with the following options:
- - **1. Fight the enemy:** Enter the turn-based combat sequence.
- - **2. Move to another location:** Skip the current enemy and spawn a new random one.
- - **3. Go to the Castle to fight the Dragon:** *(Note: This option must remain strictly hidden or locked until the player has successfully collected all 3 keys).*
-3. **The Key Drop Logic (RNG Gatekeeping):**
- - When the player defeats an enemy, there is a **specific percentage chance (e.g., 20%)** that it will drop the unique key associated with its species (Goblin Key, Skeleton Key, Vampire Key).
- - **One Key Per Species:** Once a player obtains a specific key (e.g., Goblin Key), subsequent enemies of that same type (other Goblins) will **never** drop a key again.
- - The player **must collect all 3 distinct keys** to unlock Option 3 and enter the Castle.
-4. **Post-Combat Recovery:** After each successful battle, the player's HP and Mana bars must automatically replenish (either fully or partially) to their base amounts so they are ready for the next encounter.
-5. **Experience & Leveling System:**
- - Defeating an enemy grants **XP**. The amount of XP must scale proportionally to the enemy's power level.
- - Upon reaching an XP threshold, the player levels up. **Leveling up must automatically increase the player's Max HP and Max Stamina/Mana**, making them strong enough to eventually face the Dragon.
-6. **Final Boss Fight:** Once the 3 Keys are obtained and the player chooses to go to the Castle, they will face the Dragon. Defeating the Dragon breaks the curse, resulting in **Victory**. Dying at any point results in **Game Over**.
-
-🔹 Example game loop structure:
-
-```java
-while (player.isAlive() && enemy.isAlive())
- player.attack(enemy);
- if (enemy.isAlive()) {
- enemy.attack(player);
- }
-}
-```
-
-
-### 5️⃣ Step 5: Extra Features & Bonus Tasks ⭐
-*(Optional for extra credit)*
-
-✅ **Dynamic Economy & Merchant System:** Implement coins that drop from enemies. Add a "Visit Merchant" option to the main loop where players can spend coins to buy specific weapons, armors, or consumables.
-✅ **Multiple Weapons & Inventory:** Players can buy, store, and swap between multiple weapons or use consumables mid-combat.
-✅ **Multiplayer/Party Mode:** Allow multiple players to team up and fight multiple enemies together. The Dragon's breath attack will damage the entire party simultaneously.
-✅ **PvP Mode:** Implement a **Player vs. Player** combat system.
-
-### 6️⃣ Step 6: Write a Comprehensive README 📄
-As the final mandatory step of your development, you must replace the default `README.md` with your own comprehensive documentation. Your README should include:
-- A brief introduction to the game.
-- How to compile and run your project from the terminal.
-- An explanation of the classes, design patterns, and OOP principles you used.
-- A brief guide on how to play (controls, stats, classes).
+These options allow the player to explore the world, battle enemies, manage items, or quit the game.
---
-## Evaluation Criteria ⚖
+## Locations
-| **Criteria** | **Points** |
-|-------------------------------------------------------------|------------|
-| Proper use of OOP principles | **50** |
-| Working combat mechanics, Leveling System & Enemy abilities | **20** |
-| Clear and Comprehensive `README.md` | **20** |
-| Code readability, documentation, and comments | **10** |
-| Meaningful, interactive, & colored console outputs | **10** |
-| Inventory (item) and Merchant System (bonus) | **20** |
-| Other Extra features (bonus tasks) | **20** |
-| **Total Score** | **150** |
+The game world contains several locations that the player can visit:
-## Tips 🚀
-- **Follow OOP principles**: Avoid redundant code by using inheritance properly. Think carefully about what belongs in an abstract class vs. a specific subclass. Make sure you use overriding and overloading correctly.
-- **Test your code**: Run different scenarios (fighting, running out of mana, leveling up, dying) to ensure everything works as expected.
-- **Ask for help**: If you're stuck, reach out to your classmates or mentors.
+- Village
+- Forest
+- Cave
+- Castle
-## Submission ⌛
-- **Deadline**: Submit your assignment before **21 Ordibehesht (May 11th, 2026)**.
-- **Submission Format**: Push your code to your forked repository, create a PR, and ensure your comprehensive `README.md` is included in the root directory.
+Different locations may contain different enemies and items. The Castle acts as a special location that can only be accessed after collecting the required keys.
+
+---
+
+## Combat System
+
+Combat in the game is turn-based. When the player encounters an enemy and chooses to fight, they are presented with five possible actions:
+
+1. Light Attack
+2. Heavy Attack
+3. Defend
+4. Heal
+5. Special Ability
+
+The player performs an action, and then the enemy responds with its own attack. The battle continues until either the player or the enemy reaches zero HP.
+
+---
+
+## Enemy Types
+
+The game includes several enemy types with different behaviors.
+
+### Goblin
+A fast enemy that focuses on critical strikes.
+
+### Skeleton
+Can resurrect once during battle with half of its maximum health.
+
+### Vampire
+Has a lifesteal ability that restores health when it attacks.
+
+### Dragon
+A powerful enemy capable of bypassing normal defense.
+
+---
+
+## Inventory System
+
+Players can collect and manage items using an inventory system. The inventory stores different types of items such as:
+
+- Weapons
+- Armors
+- Consumables
+- Keys
+
+Examples of items include swords, daggers, staffs, armor sets, healing flasks, and keys required to unlock the Castle.
+
+---
+
+## Object-Oriented Design
+
+### Inheritance
+The project uses inheritance to organize game entities.
+
+Examples:
+- Player → Knight, Assassin, Wizard
+- Enemy → Goblin, Skeleton, Vampire, Dragon
+- Item → Weapon, Armor, Consumable
+
+---
+
+### Abstraction
+Several base classes are abstract to define shared behavior without implementing full functionality.
+
+Examples:
+- Player
+- Enemy
+- Item
+
+Subclasses provide specific implementations.
+
+---
+
+### Polymorphism
+Different characters and enemies override methods such as attacks or special abilities, allowing each class to behave differently during combat.
+
+---
+
+### Encapsulation
+Attributes such as health, mana, defense, and damage are protected within classes and accessed through getters and setters.
+
+---
+
+## Random Enemy Spawning
+
+Enemies appear randomly depending on the location the player moves to. Each location has its own pool of possible enemies, and one may spawn when the player enters that location.
+
+---
+
+## Winning Condition
+
+To win the game, the player must:
+
+1. Explore locations and defeat enemies
+2. Collect the required keys
+3. Unlock the Castle
+
+The game ends either when the player defeats the final challenge or when the player's HP reaches zero.
+
+---
-
-###### - Born of God and Void. You shall seal the blinding light that plagues their dreams. You are the Vessel. You are the Java Knight.
\ No newline at end of file