From 08f26044f06bf1c749e100aca4bb5c2136121e51 Mon Sep 17 00:00:00 2001 From: Bita Date: Tue, 5 May 2026 17:56:16 +0330 Subject: [PATCH 1/4] Complete Characters --- .../main/java/org/project/entity/Entity.java | 8 +- .../org/project/entity/enemies/Dragon.java | 21 ++++ .../org/project/entity/enemies/Enemy.java | 83 +++++++++++--- .../org/project/entity/enemies/Goblin.java | 21 ++++ .../org/project/entity/enemies/Skeleton.java | 24 +++- .../org/project/entity/enemies/Vampire.java | 20 ++++ .../org/project/entity/players/Assassin.java | 26 +++++ .../org/project/entity/players/Knight.java | 30 ++++- .../org/project/entity/players/Player.java | 106 +++++++++++------- .../org/project/entity/players/Wizard.java | 26 +++++ .../src/main/java/org/project/item/Item.java | 3 - .../java/org/project/item/weapons/Weapon.java | 8 -- .../java/org/project/location/Location.java | 1 - 13 files changed, 302 insertions(+), 75 deletions(-) create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java create mode 100644 Java-Knight/src/main/java/org/project/entity/players/Assassin.java create mode 100644 Java-Knight/src/main/java/org/project/entity/players/Wizard.java 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..76396bc 100644 --- a/Java-Knight/src/main/java/org/project/entity/Entity.java +++ b/Java-Knight/src/main/java/org/project/entity/Entity.java @@ -5,7 +5,9 @@ public interface Entity { void defend(); - void heal(int health); + void heal(); + + boolean isAlive(); void fillMana(int mana); @@ -15,7 +17,5 @@ public interface Entity { int getMaxMP(); - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ + void specialAbility(Entity target); } 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..9135788 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java @@ -0,0 +1,21 @@ +package org.project.entity.enemies; + +import org.project.entity.Entity; +import org.project.item.weapons.Weapon; + +public class Dragon extends Enemy +{ + public Dragon(int hp, int mp) { super(30, 30); } + + @Override + public void specialAbility(Entity target) + { + if(getMp() >= 5) + { + super.specialAbility(target); + target.takeDamage(10); + this.setMp(this.getMp() - 5); + System.out.println("The Dragon threw a huge fire at the player 🔥🔥"); + } + } +} 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..58dbef1 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,91 @@ package org.project.entity.enemies; -import org.project.item.weapons.Weapon; +import org.project.entity.Entity; -// TODO: UPDATE IMPLEMENTATION -public abstract class Enemy { - Weapon weapon; +public abstract class Enemy implements Entity { + protected boolean isDefending = false; private int hp; private int mp; + private int maxHP = 50; + private int maxMP = 50; - public Enemy(int hp, int mp, Weapon weapon) { + public Enemy(int hp, int mp) { this.hp = hp; this.mp = mp; + } - this.weapon = weapon; + @Override + public void attack(Entity target) + { + target.takeDamage(2); + System.out.println("Enemy is attacking ⚔️"); + } + + @Override + public void defend() + { + if(getMp() >= 3) + { + this.setMp(this.getMp() - 3); + System.out.println("Enemy is defending 🛡️"); + isDefending = true; + } + else System.out.println("Enemy does not have enough mp to defend"); } @Override public void takeDamage(int damage) { - hp -= damage; + if(isDefending == true) { + damage = damage / 2; + hp -= damage; + isDefending = false; + System.out.println("Enemy get a little damage !"); + } + else + { + hp -= damage; + if (hp < 0) hp = 0; + System.out.println("The enemy get damage 🩸"); + } } - public int getHp() { - return hp; + @Override + public void specialAbility(Entity target) + { + System.out.println("Enemy is using its special ability !"); } - public int getMp() { - return mp; + @Override + public void heal() { + if(getMp() >= 6) { + hp += 10; + if (hp > maxHP) hp = maxHP; + } } - public Weapon getWeapon() { - return weapon; + @Override + public void fillMana(int mana) { + mp += mana; + if (mp > maxMP) { + mp = maxMP; + } } + + @Override + public boolean isAlive() { return hp > 0; } + + @Override + public int getMaxHP() { return maxHP; } + + @Override + public int getMaxMP() { return maxMP;} + + public int getHp() { return hp; } + + public void setHp(int newHp) { this.hp = newHp; } + + public int getMp() { return mp; } + + public void setMp(int newMp) { this.mp = newMp; } + } 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..aeed8fc --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java @@ -0,0 +1,21 @@ +package org.project.entity.enemies; + +import org.project.entity.Entity; +import org.project.item.weapons.Weapon; + +public class Goblin extends Enemy +{ + public Goblin(int hp, int mp) { super(10, 15); } + + @Override + public void specialAbility(Entity target) + { + if(getMp() >= 5) + { + super.specialAbility(target); + target.takeDamage(7); + this.setMp(this.getMp() - 5); + System.out.println("The Goblin struck a powerful below 👊"); + } + } +} 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..0915377 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,22 @@ 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.Weapon; + +public class Skeleton extends Enemy +{ + public Skeleton(int hp, int mp) { super(10, 10); } + + @Override + public void specialAbility(Entity target) + { + if(getMp() >= 4) + { + super.specialAbility(target); + target.takeDamage(0); + this.setMp(this.getMp() - 4); + this.setHp(10); + System.out.println("Skeleton is regenerating its bones !"); + } + } +} \ No newline at end of file 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..eba2f67 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java @@ -0,0 +1,20 @@ +package org.project.entity.enemies; + +import org.project.entity.Entity; + +public class Vampire extends Enemy +{ + public Vampire(int hp, int mp) { super(15, 20); } + + @Override + public void specialAbility(Entity target) + { + if(getMp() >= 8) + { + super.specialAbility(target); + target.takeDamage(10); + this.setMp(this.getMp() - 8); + System.out.println("The Goblin struck a powerful below 👊"); + } + } +} 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..b82f7d8 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java @@ -0,0 +1,26 @@ +package org.project.entity.players; + +import org.project.entity.Entity; +import org.project.item.armors.Armor; +import org.project.item.weapons.Weapon; + +public class Assassin extends Player +{ + public Assassin (String name) { super(name , 40, 60, 0); } + + @Override + public void specialAbility(Entity target) + { + if (this.getMp() >= 9) + { + target.takeDamage(15); + super.specialAbility(target); + this.setMp(this.getMp() - 9); + System.out.println("Assassin picks up the axe and deals a heavy below to the enemy ⚒️"); + } + else + { + System.out.println("You dont have enough mp to use special ability 😓"); + } + } +} 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..4daf600 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,30 @@ 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.Armor; +import org.project.item.weapons.Sword; +import org.project.item.weapons.Weapon; + +public class Knight extends Player +{ + public Knight(String name) + { + super(name , 50, 50 , 0); + } + + @Override + public void specialAbility(Entity target) + { + if (this.getMp() >= 7) + { + target.takeDamage(10); + super.specialAbility(target); + this.setMp(this.getMp() - 7); + System.out.println("The Knight atacked the enemy with a sharp sword 🗡️💪"); + } + else + { + System.out.println("You dont have enough mp to use special ability 😓"); + } + } } 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..798a80f 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 @@ -4,47 +4,78 @@ import org.project.entity.Entity; import org.project.item.armors.Armor; import org.project.item.weapons.Weapon; -// TODO: UPDATE IMPLEMENTATION -public abstract class Player { +public abstract class Player implements Entity{ protected String name; - Weapon weapon; - Armor armor; + protected boolean isDefending = false; private int hp; - private int maxHP; + private int maxHP = 100; private int mp; - private int maxMP; + private int maxMP = 100; + private int xp; - public Player(String name, int hp, int mp, Weapon weapon, Armor armor) { + public Player(String name, int hp, int mp,int xp) { this.name = name; + this.isDefending = isDefending; this.hp = hp; this.mp = mp; + this.xp = xp; + } - this.weapon = weapon; - this.armor = armor; + public void gainXp(int amount) { + setXp(this.xp += amount); + System.out.println(getName() + " gained " + amount + " XP 🪙"); } @Override public void attack(Entity target) { - target.takeDamage(weapon.getDamage()); + target.takeDamage(2); + System.out.println(getName() + " is attacking ⚔️"); + } + + public void heavyAttack(Entity target) { + if(getMp() >= 2) { + target.takeDamage(4); + System.out.println(getName() + "has heavy attack 💣"); + this.setMp(this.getMp() - 2); + } + else { + System.out.println("You do not have enough mp to have heavy attack 😓"); + } } @Override public void defend() { - // TODO + if(getMp() >= 3) { + this.setMp(this.getMp() - 3); + System.out.println(getName() + " is defending 🛡️"); + isDefending = true; + } + else System.out.println("You do not have enough mp to defend 😓"); } - @Override public void takeDamage(int damage) { - hp -= damage - armor.getDefense(); + if(isDefending == true) { + damage = damage / 2; + hp -= damage; + isDefending = false; + System.out.println(getName() + " get a little damage !"); + } + else + { + hp -= damage; + if (hp < 0) hp = 0; + System.out.println("Oh, the " + getName() + " get damage 🩸"); + } } @Override - public void heal(int health) { - hp += health; - if (hp > maxHP) { - hp = maxHP; + public void heal() { + if(getMp() >= 6) { + hp += 10; + if (hp > maxHP) hp = maxHP; } + else System.out.println("Unfortunately you dont have enough mp 😓"); } @Override @@ -55,35 +86,32 @@ public abstract class Player { } } - - public String getName() { - return name; - } - - public int getHp() { - return hp; - } + @Override + public boolean isAlive() { return hp > 0; } @Override - public int getMaxHP() { - return maxHP; + public void specialAbility(Entity target) { + System.out.println(getName() + "is using special ability 😎"); } - public int getMp() { - return mp; - } + public String getName() { return name; } + + public int getHp() { return hp; } + + public void setHp(int newHp) { this.hp = newHp; } + + public int getXp() { return xp; } + + public void setXp(int newXp) { this.xp = newXp; } @Override - public int getMaxMP() { - return maxMP; - } + public int getMaxHP() { return maxHP; } - public Weapon getWeapon() { - return weapon; - } + public int getMp() { return mp; } - public Armor getArmor() { - return armor; - } + public void setMp(int newMp) { mp = newMp; } + + @Override + public int getMaxMP() { return maxMP; } } 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..222b6f0 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java @@ -0,0 +1,26 @@ +package org.project.entity.players; + +import org.project.entity.Entity; +import org.project.item.armors.Armor; +import org.project.item.weapons.Weapon; + +public class Wizard extends Player +{ + public Wizard (String name) { super(name , 60, 40,0); } + + @Override + public void specialAbility(Entity target) + { + if (this.getMp() >= 8) + { + target.takeDamage(12); + super.specialAbility(target); + this.setMp(this.getMp() - 8); + System.out.println("Amazing magic is comingggg, Bibbidi bobbidi boooooooo ⭐🪄"); + } + else + { + System.out.println("You dont have enough mp to use special ability 😓"); + } + } +} 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..f4fe85b 100644 --- a/Java-Knight/src/main/java/org/project/item/Item.java +++ b/Java-Knight/src/main/java/org/project/item/Item.java @@ -5,7 +5,4 @@ import org.project.entity.Entity; public interface Item { void use(Entity target); - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ } 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..5306bda 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 @@ -2,15 +2,10 @@ package org.project.item.weapons; import org.project.entity.Entity; -// 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; @@ -29,7 +24,4 @@ public abstract class Weapon { return manaCost; } - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ } 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..af5ecac 100644 --- a/Java-Knight/src/main/java/org/project/location/Location.java +++ b/Java-Knight/src/main/java/org/project/location/Location.java @@ -6,7 +6,6 @@ import java.util.ArrayList; public class Location { private String name; - private ArrayList enemies; public Location(ArrayList locations, ArrayList enemies) { -- 2.54.0 From 6f0ef3630127d408165dcc7e704bfb589caa5325 Mon Sep 17 00:00:00 2001 From: Bita Date: Sat, 9 May 2026 21:34:42 +0330 Subject: [PATCH 2/4] Complete other classes --- .idea/compiler.xml | 3 + .idea/encodings.xml | 2 + .idea/misc.xml | 6 + .../src/main/java/org/project/Main.java | 54 +++- .../main/java/org/project/entity/Entity.java | 9 +- .../org/project/entity/enemies/Dragon.java | 7 +- .../org/project/entity/enemies/Enemy.java | 80 +++--- .../org/project/entity/enemies/Goblin.java | 9 +- .../org/project/entity/enemies/Skeleton.java | 11 +- .../org/project/entity/enemies/Vampire.java | 8 +- .../org/project/entity/players/Assassin.java | 13 +- .../org/project/entity/players/Knight.java | 20 +- .../org/project/entity/players/Player.java | 113 +++++---- .../org/project/entity/players/Wizard.java | 12 +- .../src/main/java/org/project/item/Item.java | 8 - .../java/org/project/item/armors/Armor.java | 42 ---- .../org/project/item/armors/KnightArmor.java | 6 - .../project/item/consumables/Consumable.java | 8 - .../org/project/item/consumables/Flask.java | 16 -- .../java/org/project/item/weapons/Sword.java | 26 -- .../java/org/project/item/weapons/Weapon.java | 27 -- .../org/project/location/GameDisplay.java | 101 ++++++++ .../java/org/project/location/GameEngine.java | 236 ++++++++++++++++++ .../java/org/project/location/Location.java | 18 +- .../target/classes/org/project/Main.class | Bin 0 -> 2339 bytes .../classes/org/project/entity/Entity.class | Bin 0 -> 277 bytes .../org/project/entity/enemies/Dragon.class | Bin 0 -> 1085 bytes .../org/project/entity/enemies/Enemy.class | Bin 0 -> 2852 bytes .../org/project/entity/enemies/Goblin.class | Bin 0 -> 1070 bytes .../org/project/entity/enemies/Skeleton.class | Bin 0 -> 1074 bytes .../org/project/entity/enemies/Vampire.class | Bin 0 -> 1081 bytes .../org/project/entity/players/Assassin.class | Bin 0 -> 1086 bytes .../org/project/entity/players/Knight.class | Bin 0 -> 1063 bytes .../org/project/entity/players/Player.class | Bin 0 -> 4437 bytes .../org/project/entity/players/Wizard.class | Bin 0 -> 1072 bytes .../org/project/location/GameDisplay.class | Bin 0 -> 5716 bytes .../org/project/location/GameEngine.class | Bin 0 -> 7136 bytes .../org/project/location/Location.class | Bin 0 -> 922 bytes 38 files changed, 536 insertions(+), 299 deletions(-) delete mode 100644 Java-Knight/src/main/java/org/project/item/Item.java delete mode 100644 Java-Knight/src/main/java/org/project/item/armors/Armor.java delete mode 100644 Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java delete mode 100644 Java-Knight/src/main/java/org/project/item/consumables/Consumable.java delete mode 100644 Java-Knight/src/main/java/org/project/item/consumables/Flask.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/Sword.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/Weapon.java create mode 100644 Java-Knight/src/main/java/org/project/location/GameDisplay.java create mode 100644 Java-Knight/src/main/java/org/project/location/GameEngine.java create mode 100644 Java-Knight/target/classes/org/project/Main.class create mode 100644 Java-Knight/target/classes/org/project/entity/Entity.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Dragon.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Enemy.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Goblin.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Vampire.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Assassin.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Knight.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Player.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Wizard.class create mode 100644 Java-Knight/target/classes/org/project/location/GameDisplay.class create mode 100644 Java-Knight/target/classes/org/project/location/GameEngine.class create mode 100644 Java-Knight/target/classes/org/project/location/Location.class diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 935cb4a..38042b4 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -9,5 +9,8 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index c16bbb5..22aee67 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -3,5 +3,7 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be3fc8d..fed738e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,8 +5,14 @@ + diff --git a/Java-Knight/src/main/java/org/project/Main.java b/Java-Knight/src/main/java/org/project/Main.java index 6bde20e..f8df345 100644 --- a/Java-Knight/src/main/java/org/project/Main.java +++ b/Java-Knight/src/main/java/org/project/Main.java @@ -1,15 +1,57 @@ package org.project; +import org.project.entity.players.Assassin; +import org.project.entity.players.Knight; +import org.project.entity.players.Player; +import org.project.entity.players.Wizard; +import org.project.location.GameDisplay; +import org.project.location.GameEngine; import org.project.location.Location; import java.util.ArrayList; import java.util.List; +import java.util.Scanner; -public class Main { - public static void main(String[] args) { - // TODO: ADD LOCATIONS TO YOUR GAME - List locations = new ArrayList<>(); +public class Main +{ + public static void main(String[] args) + { + while (true) + { + GameDisplay display = new GameDisplay(); + String choice = display.mainMenu(); - // TODO: IMPLEMENT GAMEPLAY + Scanner scanner; + if (choice.equals("1")) + { + scanner = new Scanner(System.in); + System.out.println(display.BLUE + "Enter your name :" + display.RESET); + String n = scanner.nextLine(); + String c = display.chooseCharacter(); + Player p = null; + + if (c.equals("1")) p = new Knight(n); + else if (c.equals("2")) p = new Assassin(n); + else if (c.equals("3")) p = new Wizard(n); + else + { + System.out.println("Invalid option"); + return; + } + GameEngine gameEngine = new GameEngine(p); + gameEngine.runGame(); + } + else if (choice.equals("2")) display.help(); + else if (choice.equals("3")) + { + System.out.println("GOOD BYE!"); + break; + } + else + { + System.out.println("Invalid option"); + return; + } + } } -} \ 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 76396bc..930b70a 100644 --- a/Java-Knight/src/main/java/org/project/entity/Entity.java +++ b/Java-Knight/src/main/java/org/project/entity/Entity.java @@ -1,6 +1,7 @@ package org.project.entity; -public interface Entity { +public interface Entity +{ void attack(Entity target); void defend(); @@ -9,13 +10,7 @@ public interface Entity { boolean isAlive(); - void fillMana(int mana); - void takeDamage(int damage); - int getMaxHP(); - - int getMaxMP(); - void specialAbility(Entity target); } 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 index 9135788..19118b0 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java @@ -1,11 +1,11 @@ package org.project.entity.enemies; import org.project.entity.Entity; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; public class Dragon extends Enemy { - public Dragon(int hp, int mp) { super(30, 30); } + public Dragon(int hp, int mp, String name) { super(hp, mp,name); } @Override public void specialAbility(Entity target) @@ -13,9 +13,10 @@ public class Dragon extends Enemy if(getMp() >= 5) { super.specialAbility(target); + System.out.println(GameDisplay.CYAN + "The Dragon threw a huge fire at the player 🔥🔥" + GameDisplay.RESET); target.takeDamage(10); this.setMp(this.getMp() - 5); - System.out.println("The Dragon threw a huge fire at the player 🔥🔥"); } + else System.out.println(GameDisplay.RED + "Dragon does not have enough MP tp use special ability!" + GameDisplay.RESET); } } 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 58dbef1..3f06880 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,84 +1,73 @@ package org.project.entity.enemies; import org.project.entity.Entity; +import org.project.location.GameDisplay; public abstract class Enemy implements Entity { protected boolean isDefending = false; + private String name; private int hp; private int mp; - private int maxHP = 50; - private int maxMP = 50; - public Enemy(int hp, int mp) { + public Enemy(int hp, int mp, String name) { this.hp = hp; this.mp = mp; + this.name = name; } + public void resetDefendState() { this.isDefending = false; } + @Override - public void attack(Entity target) - { + public void attack(Entity target) { + System.out.println(GameDisplay.RED + "Enemy attacks! ⚔️" + GameDisplay.RESET); target.takeDamage(2); - System.out.println("Enemy is attacking ⚔️"); } @Override - public void defend() - { - if(getMp() >= 3) - { - this.setMp(this.getMp() - 3); - System.out.println("Enemy is defending 🛡️"); - isDefending = true; + public void defend() { + if (getMp() >= 5) { + this.mp -= 5; + this.isDefending = true; + System.out.println(GameDisplay.BLUE + "Enemy defends! 🛡️" + GameDisplay.RESET); + } else { + System.out.println(GameDisplay.RED + "Enemy cannot defend! " + GameDisplay.RESET); } - else System.out.println("Enemy does not have enough mp to defend"); } @Override public void takeDamage(int damage) { - if(isDefending == true) { - damage = damage / 2; - hp -= damage; - isDefending = false; - System.out.println("Enemy get a little damage !"); - } - else - { - hp -= damage; - if (hp < 0) hp = 0; - System.out.println("The enemy get damage 🩸"); + if (isDefending) { + damage = 0; + this.isDefending = false; + System.out.println(GameDisplay.GREEN + "Enemy blocks damage! 🛡️" + GameDisplay.RESET); } + else System.out.println(GameDisplay.RED + "Enemy takes " + damage + " damage 🩸" + GameDisplay.RESET); + + this.hp -= damage; + if (this.hp < 0) this.hp = 0; } @Override - public void specialAbility(Entity target) - { - System.out.println("Enemy is using its special ability !"); + public void specialAbility(Entity target) { + System.out.println(GameDisplay.MAGENTA + "Enemy uses special ability! " + GameDisplay.RESET); } @Override public void heal() { - if(getMp() >= 6) { - hp += 10; - if (hp > maxHP) hp = maxHP; - } - } - - @Override - public void fillMana(int mana) { - mp += mana; - if (mp > maxMP) { - mp = maxMP; + if (getMp() >= 6) { + this.hp += 10; + if (this.hp > 100) this.hp = 100; + this.mp -= 6; + System.out.println(GameDisplay.GREEN + "Enemy heals (+10 HP) 💊" + GameDisplay.RESET); + } else { + System.out.println(GameDisplay.RED + "Enemy cannot heal" + GameDisplay.RESET); } } @Override public boolean isAlive() { return hp > 0; } - @Override - public int getMaxHP() { return maxHP; } - - @Override - public int getMaxMP() { return maxMP;} + public String getName() {return name; } public int getHp() { return hp; } @@ -87,5 +76,4 @@ public abstract class Enemy implements Entity { public int getMp() { return mp; } public void setMp(int newMp) { this.mp = newMp; } - -} +} \ No newline at end of file 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 index aeed8fc..6f4ce33 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java @@ -1,11 +1,11 @@ package org.project.entity.enemies; import org.project.entity.Entity; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; public class Goblin extends Enemy { - public Goblin(int hp, int mp) { super(10, 15); } + public Goblin(int hp, int mp, String name) { super(hp, mp, name); } @Override public void specialAbility(Entity target) @@ -13,9 +13,10 @@ public class Goblin extends Enemy if(getMp() >= 5) { super.specialAbility(target); - target.takeDamage(7); this.setMp(this.getMp() - 5); - System.out.println("The Goblin struck a powerful below 👊"); + System.out.println(GameDisplay.CYAN + "The Goblin struck a powerful below 👊" + GameDisplay.RESET); + target.takeDamage(7); } + else System.out.println(GameDisplay.RED + "Goblin does not have enough MP to use Special ability" + GameDisplay.RESET); } } 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 0915377..3e4b312 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,11 +1,12 @@ package org.project.entity.enemies; import org.project.entity.Entity; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; + public class Skeleton extends Enemy { - public Skeleton(int hp, int mp) { super(10, 10); } + public Skeleton(int hp, int mp, String name) { super(hp, mp, name); } @Override public void specialAbility(Entity target) @@ -13,10 +14,10 @@ public class Skeleton extends Enemy if(getMp() >= 4) { super.specialAbility(target); - target.takeDamage(0); + System.out.println(GameDisplay.CYAN + "Skeleton is regenerating its bones(+ %50 HP)! 🦴" + GameDisplay.RESET); this.setMp(this.getMp() - 4); - this.setHp(10); - System.out.println("Skeleton is regenerating its bones !"); + this.setHp(this.getHp() / 2); } + else System.out.println(GameDisplay.RED + "Skeleton does not have enough MP to use special ability!" + GameDisplay.RESET); } } \ No newline at end of file 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 index eba2f67..b468b4f 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java @@ -1,10 +1,11 @@ package org.project.entity.enemies; import org.project.entity.Entity; +import org.project.location.GameDisplay; public class Vampire extends Enemy { - public Vampire(int hp, int mp) { super(15, 20); } + public Vampire(int hp, int mp, String name) { super(hp, mp, name); } @Override public void specialAbility(Entity target) @@ -12,9 +13,10 @@ public class Vampire extends Enemy if(getMp() >= 8) { super.specialAbility(target); + System.out.println(GameDisplay.CYAN + "The Vampire strikes with a powerful bite! 🦷" + GameDisplay.RESET); target.takeDamage(10); this.setMp(this.getMp() - 8); - System.out.println("The Goblin struck a powerful below 👊"); } + else System.out.println(GameDisplay.RED + "Vampire does not have enough MP for special ability." + GameDisplay.RESET); } -} +} \ No newline at end of file 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 index b82f7d8..bcbd4c4 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java @@ -1,8 +1,8 @@ package org.project.entity.players; import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; + public class Assassin extends Player { @@ -13,14 +13,11 @@ public class Assassin extends Player { if (this.getMp() >= 9) { - target.takeDamage(15); super.specialAbility(target); + System.out.println(GameDisplay.CYAN + "Assassin picks up the axe and deals a heavy below to the enemy ⚒️" + GameDisplay.RESET); this.setMp(this.getMp() - 9); - System.out.println("Assassin picks up the axe and deals a heavy below to the enemy ⚒️"); - } - else - { - System.out.println("You dont have enough mp to use special ability 😓"); + target.takeDamage(12); } + else System.out.println(GameDisplay.RED + "Assassin does not have enough MP to use special ability 😓" + GameDisplay.RESET); } } 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 4daf600..c0f846a 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,30 +1,22 @@ package org.project.entity.players; import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Sword; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; public class Knight extends Player { - public Knight(String name) - { - super(name , 50, 50 , 0); - } + public Knight(String name) { super(name, 50, 50, 0); } @Override public void specialAbility(Entity target) { if (this.getMp() >= 7) { - target.takeDamage(10); super.specialAbility(target); + System.out.println(GameDisplay.CYAN + "The Knight attacks with a sharp sword! 🗡️💪" + GameDisplay.RESET); + target.takeDamage(8); this.setMp(this.getMp() - 7); - System.out.println("The Knight atacked the enemy with a sharp sword 🗡️💪"); - } - else - { - System.out.println("You dont have enough mp to use special ability 😓"); } + else System.out.println(GameDisplay.RED + "Knight does not have enough MP to use special ability 😓" + GameDisplay.RESET); } -} +} \ No newline at end of file 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 798a80f..ce286e1 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,10 +1,9 @@ package org.project.entity.players; import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; -public abstract class Player implements Entity{ +public abstract class Player implements Entity { protected String name; protected boolean isDefending = false; private int hp; @@ -13,88 +12,101 @@ public abstract class Player implements Entity{ private int maxMP = 100; private int xp; - public Player(String name, int hp, int mp,int xp) { + public Player(String name, int hp, int mp, int xp) { this.name = name; - this.isDefending = isDefending; this.hp = hp; this.mp = mp; this.xp = xp; } - public void gainXp(int amount) { - setXp(this.xp += amount); - System.out.println(getName() + " gained " + amount + " XP 🪙"); + public void gainXp(int newXp) { + this.xp += newXp; + System.out.println(GameDisplay.YELLOW + getName() + " gained " + newXp + " XP 🪙" + GameDisplay.RESET); } @Override public void attack(Entity target) { + System.out.println(GameDisplay.CYAN + getName() + " attacks! ⚔️" + GameDisplay.RESET); target.takeDamage(2); - System.out.println(getName() + " is attacking ⚔️"); } public void heavyAttack(Entity target) { - if(getMp() >= 2) { + if (getMp() >= 2) { + System.out.println(GameDisplay.CYAN + getName() + " uses Heavy Attack! 💣" + GameDisplay.RESET); target.takeDamage(4); - System.out.println(getName() + "has heavy attack 💣"); - this.setMp(this.getMp() - 2); - } - else { - System.out.println("You do not have enough mp to have heavy attack 😓"); + this.mp -= 2; + } else { + System.out.println(GameDisplay.RED + getName() + " does not have enough MP for Heavy Attack! 😓" + GameDisplay.RESET); } } @Override public void defend() { - if(getMp() >= 3) { - this.setMp(this.getMp() - 3); - System.out.println(getName() + " is defending 🛡️"); - isDefending = true; + if (getMp() >= 5) { + this.mp -= 5; + this.isDefending = true; + System.out.println(GameDisplay.BLUE + getName() + " defends ! 🛡️" + GameDisplay.RESET); + } else { + System.out.println(GameDisplay.RED + getName() + "does not have enough MP to defend! 😓" + GameDisplay.RESET); } - else System.out.println("You do not have enough mp to defend 😓"); } @Override public void takeDamage(int damage) { - if(isDefending == true) { - damage = damage / 2; - hp -= damage; - isDefending = false; - System.out.println(getName() + " get a little damage !"); - } - else - { - hp -= damage; - if (hp < 0) hp = 0; - System.out.println("Oh, the " + getName() + " get damage 🩸"); + if (isDefending) { + damage = 0; + this.isDefending = false; + System.out.println(GameDisplay.GREEN + getName() + " blocks damage!🛡️" + GameDisplay.RESET); } + else System.out.println(GameDisplay.RED + getName() + " takes " + damage + " damage 🩸"+ GameDisplay.RESET); + + this.hp -= damage; + if (this.hp < 0) this.hp = 0; } @Override public void heal() { - if(getMp() >= 6) { - hp += 10; - if (hp > maxHP) hp = maxHP; - } - else System.out.println("Unfortunately you dont have enough mp 😓"); - } - - @Override - public void fillMana(int mana) { - mp += mana; - if (mp > maxMP) { - mp = maxMP; + if (getMp() >= 6) { + this.hp += 10; + if (this.hp > maxHP) this.hp = maxHP; + this.mp -= 6; + System.out.println(GameDisplay.GREEN + getName() + " heals! 🩹" + GameDisplay.RESET); + } else { + System.out.println(GameDisplay.RED + getName() + " cannot heal due to lack of MP! 😓" + GameDisplay.RESET); } } - @Override - public boolean isAlive() { return hp > 0; } + public void fillMana() { + if (xp >= 10) { + this.mp = getMaxMP(); + this.xp -= 10; + System.out.println(GameDisplay.GREEN + getName() + " restored full Mana 🧪!" + GameDisplay.RESET); + } else { + System.out.println(GameDisplay.RED + getName() + " does not have enough XP to restore Mana! 😓" + GameDisplay.RESET); + } + } + + public void fillHp() { + if (xp >= 50) { + this.hp = getMaxHP(); + this.xp -= 50; + System.out.println(GameDisplay.GREEN + getName() + " restored 20 HP using 50 XP! 💪🤩" + GameDisplay.RESET); + } else { + System.out.println(GameDisplay.RED + getName() + " does not have enough XP to restore HP! 😓" + GameDisplay.RESET); + } + } @Override public void specialAbility(Entity target) { - System.out.println(getName() + "is using special ability 😎"); + System.out.println(GameDisplay.MAGENTA +getName() + " uses special ability 😎" + GameDisplay.RESET); } - public String getName() { return name; } + @Override + public boolean isAlive() { + return hp > 0; + } + + public String getName() {return name; } public int getHp() { return hp; } @@ -104,14 +116,11 @@ public abstract class Player implements Entity{ public void setXp(int newXp) { this.xp = newXp; } - @Override public int getMaxHP() { return maxHP; } public int getMp() { return mp; } - public void setMp(int newMp) { mp = newMp; } + public void setMp(int newMp) { this.mp = newMp; } - @Override public int getMaxMP() { return maxMP; } - -} +} \ No newline at end of file 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 index 222b6f0..bf8bf42 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java @@ -1,8 +1,7 @@ package org.project.entity.players; import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; +import org.project.location.GameDisplay; public class Wizard extends Player { @@ -13,14 +12,11 @@ public class Wizard extends Player { if (this.getMp() >= 8) { - target.takeDamage(12); super.specialAbility(target); this.setMp(this.getMp() - 8); - System.out.println("Amazing magic is comingggg, Bibbidi bobbidi boooooooo ⭐🪄"); - } - else - { - System.out.println("You dont have enough mp to use special ability 😓"); + System.out.println(GameDisplay.CYAN + "Amazing magic is comingggg, Bibbidi bobbidi boooooooo ⭐🪄" + GameDisplay.RESET); + target.takeDamage(10); } + else System.out.println(GameDisplay.RED + "Wizard does not have enough MP to use special ability 😓" + GameDisplay.RESET); } } diff --git a/Java-Knight/src/main/java/org/project/item/Item.java b/Java-Knight/src/main/java/org/project/item/Item.java deleted file mode 100644 index f4fe85b..0000000 --- a/Java-Knight/src/main/java/org/project/item/Item.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.project.item; - -import org.project.entity.Entity; - -public interface Item { - void use(Entity target); - -} 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 deleted file mode 100644 index 7ca8774..0000000 --- a/Java-Knight/src/main/java/org/project/item/armors/Armor.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.project.item.armors; - -// TODO: UPDATE IMPLEMENTATION -public abstract class Armor { - private int defense; - private int maxDefense; - private int durability; - private int maxDurability; - - private boolean isBroke; - - public Armor(int defense, int durability) { - this.defense = defense; - this.durability = durability; - } - - public void checkBreak() { - if (durability <= 0) { - isBroke = true; - defense = 0; - } - } - - // TODO: (BONUS) UPDATE THE REPAIR METHOD - public void repair() { - isBroke = false; - defense = maxDefense; - durability = maxDurability; - } - - public int getDefense() { - return defense; - } - - public int getDurability() { - return durability; - } - - public boolean isBroke() { - return isBroke; - } -} 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 deleted file mode 100644 index eb59a46..0000000 --- a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java +++ /dev/null @@ -1,6 +0,0 @@ -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 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 deleted file mode 100644 index 028e13d..0000000 --- a/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.project.item.consumables; - -// TODO: UPDATE IMPLEMENTATION -public abstract class Consumable { - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ -} 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 deleted file mode 100644 index c0e7a6d..0000000 --- a/Java-Knight/src/main/java/org/project/item/consumables/Flask.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.project.item.consumables; - -import org.project.entity.Entity; - -// TODO: UPDATE IMPLEMENTATION -public class Flask { - /* - THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN. - */ - - // TODO: UPDATE USE METHOD - @Override - public void use(Entity target) { - target.heal(target.getMaxHP() / 10); - } -} 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 deleted file mode 100644 index 96226ee..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/Sword.java +++ /dev/null @@ -1,26 +0,0 @@ -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 Sword() { - // TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR - } - - // TODO: (BONUS) UPDATE THE UNIQUE ABILITY - public void uniqueAbility(ArrayList targets) { - abilityCharge += 2; - for (Entity target : targets) { - target.takeDamage(getDamage()); - } - } -} 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 deleted file mode 100644 index 5306bda..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.project.item.weapons; - -import org.project.entity.Entity; - -public abstract class Weapon { - private int damage; - private int manaCost; - - 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; - } - - public int getManaCost() { - return manaCost; - } - -} diff --git a/Java-Knight/src/main/java/org/project/location/GameDisplay.java b/Java-Knight/src/main/java/org/project/location/GameDisplay.java new file mode 100644 index 0000000..23b81a9 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/location/GameDisplay.java @@ -0,0 +1,101 @@ +package org.project.location; + +import org.project.entity.enemies.Enemy; +import org.project.entity.players.Player; + +import java.util.Scanner; + +public class GameDisplay +{ + public static final Scanner scanner = new Scanner(System.in); + + public static final String RED = "\u001B[31m"; + public static final String GREEN = "\u001B[32m"; + public static final String YELLOW = "\u001B[33m"; + public static final String BLUE = "\u001B[34m"; + public static final String MAGENTA = "\u001B[35m"; + public static final String CYAN = "\u001B[36m"; + public static final String PINK = "\u001B[38;5;206m"; + + public static final String RESET = "\u001B[0m"; + + public void showPlayerTurn (Player player) { System.out.println("\n--- " + player.getName() + "'s Turn ---"); } + + public void showStatus(Player player, Enemy enemy, GameEngine gameEngine) + { + System.out.println(BLUE + "\n==========================================================" + RESET); + System.out.println("[ Name: " + player.getName() + ", HP: " + player.getHp() + "/" + player.getMaxHP() + + ", MP: "+ player.getMp() + "/" + player.getMaxMP() + " XP: " + player.getXp() + +", Keys:" + gameEngine.keys + " ]"); + System.out.println("[ Enemy: " + enemy.getName() + ", HP: " + enemy.getHp() + ", MP: " + enemy.getMp() + "]"); + System.out.println(BLUE + "==========================================================" + RESET); + } + + public String battleChoices() + { + System.out.println("Your turn :"); + System.out.println(PINK + "1. Attack (Free) " + RESET + YELLOW + "6. Restore Mana (10 XP) " + RESET); + System.out.println(PINK + "2. Heavy Attack (-2 MP) " + RESET + YELLOW +"7. Restore HP (50 XP)" + RESET); + System.out.println(PINK + "3. Defend (-5 MP)" ); + System.out.println("4. Special Ability (Knight -7, Wizard -8, Assassin -9 MP)"); + System.out.println("5. Heal (-6 MP, +10 HP)" + RESET); + return scanner.nextLine(); + } + + public String mainMenu() + { + System.out.println(BLUE + "==== Main Menu ====" + RESET); + System.out.println("1. New Game"); + System.out.println("2. help"); + System.out.println("3. Exit"); + return scanner.nextLine(); + } + + public String chooseCharacter() + { + System.out.println(BLUE + "Choose your character:" + RESET); + System.out.println("1. Knight (50 HP, 50 MP)"); + System.out.println("2. Assassin (40 HP, 60 MP)"); + System.out.println("3. Wizard (60 HP, 40 MP)"); + return scanner.nextLine(); + } + + public void help() + { + System.out.println(""); + System.out.println("================================================================================"); + System.out.println(" WELCOME TO THE DARK REALM "); + System.out.println("================================================================================"); + System.out.println(""); + System.out.println("You have entered a land shrouded in darkness, where evil creatures roam freely."); + System.out.println("Your mission is clear: defeat the forces of darkness and save the world from destruction."); + System.out.println(""); + System.out.println(" HOW TO PLAY "); + System.out.println("1. CHOOSE YOUR HERO:"); + System.out.println(" Before your journey begins, select one of the following classes:"); + System.out.println(" 1.Knight 2.Wizard 3.Assassin"); + System.out.println(" Each class has unique abilities and strengths. Choose wisely!"); + System.out.println(""); + System.out.println("2. EXPLORE AND COMBAT:"); + System.out.println(" As you venture into the realm, you will encounter hostile monsters such as Goblins, Vampires, and Skeletons."); + System.out.println(" Engage them in battle to gain experience points (XP) and level up your character."); + System.out.println(" Higher levels mean stronger stats and better chances of survival."); + System.out.println(""); + System.out.println("3. COLLECT KEYS:"); + System.out.println(" Defeating specific types of monsters drops special keys:"); + System.out.println(" - Killing Goblins drops the Goblin Key."); + System.out.println(" - Slaying Vampires yields the Vampire Key."); + System.out.println(" - Destroying Skeletons grants the Skeleton Key."); + System.out.println(" You must collect all three keys to unlock the final challenge."); + System.out.println(""); + System.out.println("4. THE FINAL BOSS: THE DRAGON:"); + System.out.println(" Once you possess all three keys, the path to the Dragon's Lair will open."); + System.out.println(" The Dragon is the ultimate ruler of evil and possesses immense power."); + System.out.println(" This is the final battle. If you defeat the Dragon, you will restore peace to the world and win the game."); + System.out.println(" If you fail, darkness will prevail forever."); + System.out.println(""); + System.out.println("GOOD LUCK, HERO! MAY YOUR BLADE BE SHARP AND YOUR MAGIC STRONG :) "); + System.out.println("================================================================================"); + System.out.println(""); + } +} \ No newline at end of file diff --git a/Java-Knight/src/main/java/org/project/location/GameEngine.java b/Java-Knight/src/main/java/org/project/location/GameEngine.java new file mode 100644 index 0000000..4acc782 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/location/GameEngine.java @@ -0,0 +1,236 @@ +package org.project.location; + +import org.project.entity.enemies.*; +import org.project.entity.players.Player; +import java.util.*; + +public class GameEngine +{ + int keys = 0; + boolean goblinKey = false; + boolean skeletonKey = false; + boolean vampireKey = false; + + GameDisplay display = new GameDisplay(); + Player player; + Random random = new Random(); + + List locations = new ArrayList<>(); + + public GameEngine(Player player) + { + this.player = player; + createLocations(); + } + + public void runGame() + { + Location dragonLoc = locations.get(locations.size() - 1); + + List enemyLoc = new ArrayList<>(locations); + enemyLoc .remove(enemyLoc .size() - 1); + + Collections.shuffle(enemyLoc , random); + + while (true) + { + if (keys >= 3) + { + System.out.println(display.YELLOW + "\n>>> You have collected all 3 Keys!🔑" + display.RESET); + System.out.println(">>> 🔓 Final battle : "); + System.out.println("----------------------------------------\n"); + + fightEnemies(dragonLoc.getEnemies(), dragonLoc.getName()); + + if(!player.isAlive()) + { + System.out.println(display.RED + "\n ❌ GAME OVER! ❌ " + display.RESET); + return; + } + else + { + System.out.println(display.YELLOW + "\n🎉 CONGRATULATIONS! 🎉" + display.RESET); + return; + } + } + + + for (Location loc : enemyLoc) + { + System.out.println(">>> Entering: " + loc.getName()); + System.out.println("----------------------------------------"); + + fightEnemies(loc.getEnemies(), loc.getName()); + + if (!player.isAlive()) + { + System.out.println(display.RED + "\n ❌ You died! GAME OVER ❌" + display.RESET); + return; + } + if (keys >= 3) break; + } + } + } + + private void fightEnemies(List enemies, String locationName) + { + for (int i = 0; i < enemies.size(); i++) + { + Enemy enemy = enemies.get(i); + + System.out.println("❗An enemy is coming : " + enemy.getName() + "❗"); + + while (enemy.isAlive() && player.isAlive()) + { + display.showStatus(player, enemy, this); + + String choice = display.battleChoices(); + + switch (choice) + { + case "1": + display.showPlayerTurn(player); + player.attack(enemy); + break; + case "2": + display.showPlayerTurn(player); + player.heavyAttack(enemy); + break; + case "3": + display.showPlayerTurn(player); + player.defend(); + break; + case "4": + display.showPlayerTurn(player); + player.specialAbility(enemy); + break; + case "5": + display.showPlayerTurn(player); + player.heal(); + break; + case "6": + display.showPlayerTurn(player); + player.fillMana(); + break; + case "7": + display.showPlayerTurn(player); + player.fillHp(); + break; + default: + System.out.println("Invalid option. Try again."); + continue; + } + + if (!enemy.isAlive()) + { + System.out.println(display.BLUE + ">> Enemy died ! ✔️" + display.RESET); + break; + } + + enemyTurn(enemy); + + if (!player.isAlive()) break; + } + + if (player.isAlive() && !enemy.isAlive()) + { + int xp= 0; + boolean isLastEnemyInLocation = (i == enemies.size() - 1); + + if (enemy instanceof Goblin) + { + xp = 10; + if (!goblinKey) + { + if (isLastEnemyInLocation || random.nextDouble() < 0.4) + { + goblinKey = true; + keys++; + System.out.println(display.YELLOW + ">> You found the Goblin Key! 🔑" + display.RESET); + } + } + } + else if (enemy instanceof Skeleton) + { + xp = 15; + if (!skeletonKey) + { + if (isLastEnemyInLocation || random.nextDouble() < 0.4) + { + skeletonKey = true; + keys++; + System.out.println(display.YELLOW + ">> You found the Skeleton Key!🔑" + display.RESET); + } + } + } + else if (enemy instanceof Vampire) + { + xp = 20; + if (!vampireKey) + { + if (isLastEnemyInLocation || random.nextDouble() < 0.4) + { + vampireKey = true; + keys++; + System.out.println(display.YELLOW + ">> You found the Vampire Key!🔑" + display.RESET); + } + } + } + player.gainXp(xp); + } + if (keys >= 3) return; + } + } + + private void enemyTurn(Enemy enemy) + { + enemy.resetDefendState(); + System.out.println("\n--- Enemy's Turn ---"); + int action = random.nextInt(4); + + switch (action) + { + case 0: + enemy.attack(player); + break; + case 1: + enemy.defend(); + break; + case 2: + enemy.specialAbility(player); + break; + case 3: + enemy.heal(); + break; + } + } + + private void createLocations() + { + List goblins = new ArrayList<>(); + for (int i = 0; i < 4; i++) + { + goblins.add(new Goblin(10, 10, "Goblin👹")); + } + + List skeletons = new ArrayList<>(); + for (int i = 0; i < 4; i++) + { + skeletons.add(new Skeleton(20, 20, "Skeleton💀")); + } + + List vampires = new ArrayList<>(); + for (int i = 0; i < 4; i++) + { + vampires.add(new Vampire(30, 30, "Vampire🧛‍♂️")); + } + + List dragon = new ArrayList<>(); + dragon.add(new Dragon(100, 100, "Dragon🐉")); + + locations.add(new Location("Goblin Forest", goblins)); + locations.add(new Location("Skeleton Graveyard", skeletons)); + locations.add(new Location("Vampire Castle", vampires)); + locations.add(new Location("Dragon Cave", dragon)); + } +} \ No newline at end of file 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 af5ecac..086832e 100644 --- a/Java-Knight/src/main/java/org/project/location/Location.java +++ b/Java-Knight/src/main/java/org/project/location/Location.java @@ -2,14 +2,16 @@ package org.project.location; import org.project.entity.enemies.Enemy; -import java.util.ArrayList; +import java.util.List; -public class Location { +public class Location +{ private String name; - private ArrayList enemies; + private List enemies; - public Location(ArrayList locations, ArrayList enemies) { - this.locations = locations; + public Location(String name,List enemies) + { + this.name = name; this.enemies = enemies; } @@ -17,11 +19,7 @@ public class Location { return name; } - public ArrayList getLocations() { - return locations; - } - - public ArrayList getEnemies() { + public List getEnemies() { return enemies; } } 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 0000000000000000000000000000000000000000..cad7b823684b3a9dbe0a917a55711e3b35bfec37 GIT binary patch literal 2339 zcmaJ@NpllN6#m+lHS%PPu?#kjS!6I^gF$9V0Lcl9Y`{TYf{7jDEVQMGGXo|=c@I% z?P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K+nHatX%g1 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..88bbd8159130aabe24d17e1239480b04db0bb611 GIT binary patch literal 277 zcmZ{fJ#GR)3`W0!WtaazNt1eMm;t)s>=f#$Z=*evRY=TvYR#3yc%#sEbmSR*Q7)q>U3j#AK5=HqPPfL2 zkwB~RQf2&ZtU#SV!HIW^737dS1jORoKn(Alpc%6D%r-iq@1hs7?>X6gky^vx7n4an AR{#J2 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5e9f99887d439526ebdff980dde394e1de4f2586 GIT binary patch literal 1085 zcmaKrZBG+H5Xb-97Ou1hl!u~Nz^#auA{dHtuYWy^aJ=^_zK3^UNvZ{xnyo;c6a8tGqc}+eE9}o18W&1kTj4o(T9Ep9)z~l z41+^iSC;gZquTV7o+Be`gZ^!X{s)flsD}&}O4VxZP#g=(6~1k4tI+Z7wfWr)(ikw1 zF_DGIQ2bBG^-$P>&(LQ}wb^7ymgcLPXvoAcatuRJQ`Q~fKG}C%LSdLG)p~^6=zvn{ z0gPhIz_^J#CKz((=-QEz9%TqxiXk6!JAt)D(2CHd@YW1m{Hp?PP#4MxeCxUJ!|7#`8hR=n=54gwi*KTy0OjwP3V(6SqRbBn7cZ$*-KyTe7?o}#`O zMSmI`P?F)ABwo^ z!fhnUOS9jN{+evPRw%A~NDfkhVUjs|8zY#emr}+!rOtN%C*m}}0V`O=9fG(^CsRn24btzCp1}Q|B(nxC literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..92b534eaf37fbab77aff14410ee279023f38fb5d GIT binary patch literal 2852 z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^tW~}R1PCVT_oS7z^u#Y3Kgpn4;NlBvFc($eSt$Jx)^s^RG-QMUG&-FEB?e)lZ z&#^!8i7Esk|4V5>qGLCSxt1huw{(X*nT*WzC Jg^6|a{0Hy%LjC{% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..39ad8ecb74e3ccc2ce27ee664a5cbeefb6cbfac0 GIT binary patch literal 1070 zcmaKr-A)rx5Xb+gEo^BQD20MpgoB8-MOdJUA2lQfkTfZVq=Xx;PRp@f*pFuS6w*h~ zr_d{}@dBcWK7jASD;Q_H)u5?nli8U$XJ>x%vEP4u`37JIr34~~YKZ9=z#s#6y@t{9 z+!I+>hIEvvI`opZDScyy-W`U)7p7yXO@^slxm-CBXTq?A(=e*aGo3~$f0#fVLmCn~ zlF%9E{}Xc8ty!kSFwl@{uf-6}<;wxlh>lUD7)Jb-tee7mSu-s{VVKQT`h?r*g7#9U zb&O+zV)|jsSgxEu9Ks}~G~CiLjoS>V8`vFRNt;r;ZN-oY3o>0}pQ=$*lN5GI!^~f; zvD~^)rt28H!j{{n-?Bs}j#-BF>``&UK4?lF*2aD1wdA3Ailke?wFvJQo326oRGQ%%!nSm-y%U#k|vlo%pS+6q=C#U>@@P`87y zH^vuk9j&Dj9&HgrwqM}hhA<3Qm8hTYiB^v$QFYs1UA{5{-ej0}B?ymsTH^@)Bp^xK zgh7%I$=XMZ9w1)G&MaSnU370OlMHT$0IyOl)SX; zz36Yr4$g{&OK9;ASS&1EVYtw>jxRCx37PbrOUx~$w9iS!g7O sDZwbo6s9nSIiv|{f>LL?fRkaG-+)DI;0ZxIr7vTM6g1MGksiVGpIW;9zyJUM literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..64fec5578fa7f149e5f4f4bcd90b9008f4b457e8 GIT binary patch literal 1074 zcmaJ=TTc^F5dKbE*iyD!ir}S)ry|mp%Ysn6fF?vyniSKdh8Lc;<)l5Z-QDb-lJqzD zC-li@jVXx_`~d$8f5AAX7e#|+lQ}bUW@o>8Mt9$8Z!(NSMaq%C7M*hYbl259&+hfWrD2;ys(?w25$Yuf#cO|B|X=AV>iVs z8TyXhj^hr)^YqciR&&q*mmv>Cou~>Z+^ut|LSFS;5oVY8LSc>Xmvb3@`QhTS^EG|6 z)=Xd)cMZ&$xChQK)rI*d7zV@F&>UiCI{Po8@0*y%1L802@fXV$dlPtQVo}qtiQV`0 zOmZgjgV23Hj%9{jYGVC&6UUwix$7z3u+Ib+uGgwJ_(7Q~kGDd>`=j7?Zx$Kd2t(|p zcPtpjOVSl@Tg|En-q}@$JgE|K=N#IB)OOz)Qwu4>N9Z;(b>FZMW_k$r>QFiV0!1nui5*4o%)WmD45hn+gS9Jkoh_nbj z6Obe#F-&rWtTJNs0r7l#cI6!Gb2nm@q>cbaV3ExCVz7pFvM3slu+hDbW0N$UIgSFh z5G5}ydq4Yovh`gd-+^I##A1Hw9LX=3Ox^Avo$q>&JIH8lVaVwq`w64^dWo(zlqfWm yIT$3zsKf-4n55^BqFtN9GHIKb=|Y_875W9SfX8@3FrLz%F+`RP(w~tY!S+vo7X2as literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5be0cd3271923040ec882be0d8b699f88b99ab2b GIT binary patch literal 1081 zcmaKr-A)rh6vzM57PgcHO8HPM;(~~!d@P8dh?*Ed)1(*@2sd0!%g_$&S9Yh6K7%iz zS6=HyiC*vkz6-BlJku^lO*Na$o;fr7Kfm*_-+z3&0NQYP$rV8aQdOK}Wirt4C zMhuLa7{fS2_BXs{q=ZWm{Dxu}>wrt&-Xm&7?1H;n25$dV0>`g%C4J9+%U!W8qrlbiBAKU#4!n8aNJ zQzq`gVi;*7{t3ch1RBfnh_ukH#{HPVeFL*59$=1P;-58P$S8g$wzH121cROw&9k=x+h7 zR50|?x=6b{r04qwH9 zhCWt*PkVi~UTne0raxk?xNwPqFBr~Ew2)uOX1-!Nfnw+QxP^zG(63L)k=H0mXp|`! vv<{$;qz6fS9K+#Lr?M*u{ooPC^XrIA_ ziSAtK%C#;4P4oeL4EMx0FrMj;)TD7SXYTpA=X~co=l=Np^*exVJc=NIpoWl+Aq+Fj zxs8fhZ@9;@q)h23OSR0pEn2eSnfvWO!|;aXSn4subh280clXTPbgy&ff!%#)4-8w@snaca9#&nFsU>Ni2vSbN+vuN1_hha8Z z7?5zg4K|lL3?qg~4cBzUF~wl?L2P+S)~JHpR1EPBc*`~S3ArNtQq*!9rWtsDe%mbx zWx0;IBWiNX@_af*aGhZovgZR_Vm!%{o_A$;C_hoH8#mvvMW9AxQbWB zspQgeo0Tfx-S^vSdXjgi#YJaa{PO*`%Zs;ugAAdkZdo#n7c58aHETuLcrJ=ISz-ku z**+8v%h$Wckg8f9!@{6x_jaEClcoQQu3BgkLrYzw9hDl4DfZAUQ#$V}yT_@W%0gv@1B-zi_fxBOgPSZiWz8 M(&)TS=Kvo50gD_DivR!s literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a147354d8e9a2e42108631432f98e7c35d442c42 GIT binary patch literal 1063 zcmaKr-A)rh6vzM57Phntl=2a)plK|I1kxL>hIY~}ba$KGDTHV6 z!V6zOu1vg>3qTWn0N;i92FA19Rcq3Cb9Uy;%>Vq($A16$HdeWt)wrVi;&hwcTcj=JI8qX+*~;QVb(rTh>g`dUjy82!>%cSLwsJ z)kQ7kt3ya*T*HKpNlY=MdH_#7B`u2JbSU0rfNna*4sk1@m%=J(m}cO;`Yop>lL@Swbzt9NP!EbMD57qC#Gt0!M&z%+uS>G+d+D@m@uip9TQHRx(4c91TC9xjrd3a-Jx67A># zma#(TR2!s1u{VfzZ><$Bpry1k%omE67(T~XdgcO|Vk-U_*$4{3as2}KKOpI!k|X1X zjlvH*3ythBhDdsZ#HTPuzBKVp;354He{t6S;H+Vl&KTC{Wekx8jn?b5j^NQR7)=UW literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..dafec99c598fb35583ced529bd4859c37d95f8e7 GIT binary patch literal 4437 zcma)3~`Jat1iRdEzE>3k6icwgl2t^f2+|*a}w5eN*>1XF}8hKZt=$WEbbVn5m^$*N8 zP(3xoD6Uc?sS5SjmBneAhUU#n+-6dQ(u5P)GLVf+a zEhhrJ#c7D1iqWu2$LP31dxZ$w;XqVoRMP@|fZKuDR#Iq$k-nzTk)RQ~SsLjSosLmP zr89I^p?v|9eNoK0LU9*KUeHVWBBm+aKQS=NYCWyeIU2(>L#?T@sGx~f6x>KFg}4cG z6X7PxO^lvsg%z$EXoT&bQE8Ix>)BqvJ(X*vIKOU`uX8FrSMxfH*DAkm;-;BK6zU8} zbYcQ@fE>3AU~QQ!TE>-XY2K*J=<}v1GCQxEvwEe-_uj*>yHv!C9hwZ#V0*!5uwoYV zqIC`VMl9nN_fg$-_589z-Tgrhq=*@&in@9Q$tslmih)>DONPF(I_7z8nr81)df9`G z7Q}jkx5DO(V7v((7mB7irCT~)@nsfl%}&|K7j<)NzG!0kqL7Ntm|0wb5?Jup<>c|e zh-0{-M^d5(r$`ddH+!CBPMZ7pv|X*_jY~xqwNdT{gIu~;c;{`~b=-Cyi6;rsu-|E_%h zEroi$_f^Mmv@C0+Ns)Ts=^qd8{!xznwn7<ut1am(hGtlHb#Y0X%4rLB zCBVV`_oRdGU@GC@I6DwpJDQB}_cb5qdkP(sK^_&uwLNQTyXpM<3Ox?PVK|>R?fkN% z$!YB26lwzeP$A9Bf>)md#pFPt+JpNN^$n~7&l?v3G-FL4JdkhSQfSEYk=HGu0|se@ zs-c0-L|JL}0`%BU_!ET=dp;|M3ztA8L3=%jUGIgZ*DSF@!RaCU-yM%H zVOd6H+|(T`q!|4c^SvvlAk-LrjFs`#L$UYByuv-$;_GlMox;u^=7S!mW|%)L(AV*i zE_!?@h#qIU=<$gldK~KL+h8A|Z=jvU-N&$tpg)@Wf|OKfonom(VV#;pyC-#Yo!U}e z>(rS#uujQTdw89?|0bMWMSBFt4&l2b46FtmG%WyWN09xrhYnIJ_2TO!g@D&E>bML; zFVJ<|A)vrl#1(_ri7Q49i7SQ;19FbedZ<_NhDRk+FWkds@-k5FQcvo0>Pv3G9eqye zEwpCgrUOu&z}Y7d9+T!iLXvJE2)?E0Mf#=}WEx{QNQdWogH8y~MfSk(puU_?>tcBq zeB3uY+)?0kC*o_=p91*Td9rzZCE@_vTwoh;%ha zMWt>{`DhIkDsYgQ79YVh>@hv-iPfDL-p2I&E~e=~rt4su1JeyKy$Gh4z@+~VrX_#D zX1yID;ZM?xAEi#LLjEHp6haHs-CA`Czitx#Hc+ISUU8pC&uguTOY{?pg+HZm=r4F6 zOO%%+Vepo4O*O(rsIKuG+vCp)E$`!L^lTD=zqY^PLZV4Or5ZmG&yPaODD&OMoeWWH zYzG>f{xUu7=@U&Qy;W9g{Ys4@QD2cLmAswT3WVt13E>1n*ufArCzQ;;`Ur^4?H~U{ z0ZKIOgt!$5f&aAtLW6E#gh>~eE|@Ac0#-s01={!m~n?( z^fyq&@4;17w6{dND%w{?`He}IJ|#I JAJHeY@4p7=ho%4k literal 0 HcmV?d00001 diff --git a/Java-Knight/target/classes/org/project/entity/players/Wizard.class b/Java-Knight/target/classes/org/project/entity/players/Wizard.class new file mode 100644 index 0000000000000000000000000000000000000000..7d72b53620990bf4e05db5314dbfc831ad2cd248 GIT binary patch literal 1072 zcmaKrOHUI~6vzL!Elg<#DCHrD!bK4KKnBF3Nr^@UwMj7~7+kQrZEwnjc{DRq5?H%) zW8xRUl`9vz040$R;Ky*^uV6gWDW)dGS)94&&b|NhJCFJK`}_jH1|B95K~zIbM-O@# zW*oO}G+bw2R((U-zVeTZhAEDu>ls_^H$(55vX%dcVLVgb7l*yQ(973 zMGZF?cz0masR~~?w(&w(a$R{rmExFUcsaSdvT8lC#4*)_TcWP2TzS0eSme{Qz@Ms0 zMb#9qIG1lHeE6@=?^`Dqt@F2&yGvFA95Whj>6pbF!*HAUUoHl%5m1^ofnU*$>`oH% zxT7JXBO8=tqC167f5X}_Bz$oo*98&FIPwe|l*qCbHi*|8>2cff`JOnGT-r{vzQ;GW zxbN_$CwZq!T!d}nt&<3|R1Y>qqZ2=|?KIu0 ze69k*WEg2NkjD&7b%g#Jkfq_m9N7i(9@9G5Pv-KewNxg02KJ?W=q}k_It047NOmkd z1_Mjv(FH8y9(||UAk`6jhiLm$A$JNb75|9&T>cFGxzMehV(2SI(>G5solhmc<8}m} zkPNoyz;qBciXiM1G_w8ZBk2JWpTH3Dr-^q2_c7XqQ}~NhzzTh1DA3IqA`2R=S7{x= FgFjlY3!wl2 literal 0 HcmV?d00001 diff --git a/Java-Knight/target/classes/org/project/location/GameDisplay.class b/Java-Knight/target/classes/org/project/location/GameDisplay.class new file mode 100644 index 0000000000000000000000000000000000000000..fd5781ac3c61133396d18fc2f3d01adc11687ad4 GIT binary patch literal 5716 zcmb_gd3YPe6@Qb@TVV9zr`QxJKGum{-v`zmyM(ZP8)0-(oo7<>8 zOy^K|4SBxq`Jw_Ur-n@zrxYX8iDq5X_Vd0gjLJ|uok!=l(Uve>Kpl*BIBqFgbsZ@u zDs12M>(Q!Z)P?IsvkEe5D+zzns0cZomsE@;5qIpO z;m??U8UJ~{Vf!AVYa(awY{9IZE~U;kx-3lF=yFCEwlDz-Ri#0e4I5i=oo=J;jCiwU zmIIAU$BvG{juF$7CWeSJ8re42KTv7E_J96to7-EFKD{zbSJ6&J8{w>ERYhuC;;#wQ zE{P8TpEgb;vl7`ArrizVbX8)y!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(&Ij;q6R0&Qh&9bapW|Vb*Lc-~?+yKG#Ga zyc-y5zDsEqakTEd=?mm~cwA2I@nF(vqdzjb`YfATsoF+=#?kTbNl_1hU9`rf zu$emLl>z^C(ue57#ONdVe;s`k>yI_9KaTY$o7SJg`oX64Ls&o3w0;!p&or%1V*S~s z_2;mDqG|nkbW-#b+Js;EjwK3+QJpsKew^6DN~JI1S3Z^l{Fm_?4hZNg^i`}FeT}}3 zU%7b%21w(!JVI@IPSUxj=t82Cbjg`~wkkeb16s`oyXYJAO>koLE&8_R_#k9%0LKhC zc3c5gnlrfX!1ro=BlzyYx3}jp+INZ$Dv2QLK1qZ4UW@N_r|9|yx?^~aLffeg>@S0u zZFrq>Idua@X*-S56*Ng)DY`pQVO7zLRupQ{cj!rFMuxsi-=pqvS(P;w`fyc%A*28!;2Y7zW(;jPE+rl=fT zjmi&J)iAUgyQCVkTFjh=$27dHh1jjg3z-oi2-!mWAhr);`sY6>&eZIeG_0JlZajB1{tgWrcu%iu8m?$q z*YNooHt1id*Du!aB^ti$47yk7^{X^|wT7?N@bwzLQNsrRH|h18HGHdvZ`bf08aC+P zrPmGnCH{2r-Ag+W&lns$3|Jyd-Hpz54|>;qRG|CuPU8WZriW+-edZ{FHH+fCnVzOOdWLSHXXzOIjc%pC z({1z*`A&iiCSONvp(4AK7ETA3b?RIS(GMHJMXIld#zf~mK~uAj(0d-I_diNmX%SO} r5wxXtQ2hwFb@XHU3E)Lo{|Xd8Rlh%1zrUd0<4HTPf1p3nU#Rn63|iWb literal 0 HcmV?d00001 diff --git a/Java-Knight/target/classes/org/project/location/GameEngine.class b/Java-Knight/target/classes/org/project/location/GameEngine.class new file mode 100644 index 0000000000000000000000000000000000000000..03832c8f954dd41028716031501b80be2006e5b7 GIT binary patch literal 7136 zcma)B3t&{$nf}h5$;@Q9Kp4U!JSPH@7lfAqi2-8>keY-?AT*%WOXiY{OlIQDB$C=% z*V=VysgKpJ1|LP*8ryEIs3ZbPYrA&sbF0=}yY6aB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{7#Z&i~ljfC0d!Yek+dkd&wiTZT}$Nu9>Fe z#Y&FLPw-~&Ddn?(Pj$H%%OL)fPR8kf8bHW}{MP{dg#1~I#-r28B5ocyLQy=!*0W6a z-(j-&9+SlPnIN8L1o{E5pI<;Ten=zwG0o{`TF7CCyNt-tss+l^4O2=fDLH8%h`du+ zqJqAl)F-@*cS``U#S#D~+ybQ0Q!~xKAJfZ^;H9>LU_mf+VhI0p2=6lG-)g9VGjF&d04}k%yGiiSpaVur6ADwV)_m~TP{9ZEWKG;8ZCYEu+X{swit{4Ar1V892upp4zh zXUV_lq zd~i&N!|po&3euoAVz+Pdk7Q{_I#Z{!=~xvX;&JNw=Z(@)Txh#5gB5e8+4A0BJ*;U! z`W>ssb@lvWiSX|KeckGYw)Y@W=G2M3-R-SkSD?WJD~Z#&v&^}v^y{_Yt=I`Y%xA?! zz13E$=5qQk?aXn&IeUC+9zQ-A=W*x|*mQmeKK&}Tc)rcZC$2u%cK|M?Yy{);O# zzcS?G9&HB|+9quab-te#!FCwgUzA}N_qij0qZ7`vgdQHy4@qXv+Qjk779KM82#;xP w1Cp!FsrJ7i_(I2Xv^5vpa#RbDYDvYv08g2nl4KPc_YH~;_u literal 0 HcmV?d00001 -- 2.54.0 From d499f00d5410e26741eb5e6faf3f6c49fd9ff4fe Mon Sep 17 00:00:00 2001 From: Bita Date: Sun, 10 May 2026 19:40:38 +0330 Subject: [PATCH 3/4] Update README2.md --- README2.md | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 README2.md diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..ffc83f5 --- /dev/null +++ b/README2.md @@ -0,0 +1,104 @@ +# Java Knight ⚔️ +A turn-based RPG with Roguelike elements which can be run in the terminal. + +### 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! + +### Your Mission : +1️⃣ Explore dangerous lands inhabited by Goblins, Skeletons, and Vampires.
+2️⃣ Defeat these enemies to gain experience points (XP) and collect special Keys.
+3️⃣ Collect all three keys (Goblin Key, Skeleton Key, Vampire Key).
+4️⃣ Once all keys are collected, the path to the Dragon’s Lair will open.
+5️⃣ Face the Dragon in a final, epic battle. Victory means saving the world; failure means eternal darkness.
+ +--- +## How to play ? +#### 1. Character Selection 👤
+At the start of the game, choose one of the following classes:
+**💂‍♀️Knight :** Balanced stats with high defense. Good for players who prefer a tank-like playstyle.
+**🥷Assassin :** High damage output but lower HP. Requires careful management of MP for critical hits.
+**🧙‍♂️ Wizard :** Powerful magic abilities capable of dealing massive area damage, but fragile in close combat.
+#### 2. Combat System🎮 +Turn-Based Battles:
+Engage in turn-based combat against various enemies. + +**Actions:**
+- Attack: Basic free attack.
+- Heavy Attack: Costs MP but deals double damage.
+- Defend: Blocks incoming damage completely (Costs MP).
+- Special Ability: Each class has a unique powerful move (e.g., Wizard’s fireball, Assassin’s backstab).
+- Heal: Restore HP using MP.
+- Restore Mana/HP: Use accumulated XP to refill resources.
+- Enemy AI: Enemies can attack, defend, use special abilities, or heal themselves.
+#### 3. Progression & Keys🔑 +Killing specific types of enemies drops a corresponding key:
+Kill Goblins → Get Goblin Key.
+Kill Skeletons → Get Skeleton Key.
+Kill Vampires → Get Vampire Key.
+You must collect all 3 Keys to unlock the final stage.
+XP gained from battles allows you to restore health and mana during fights. +--- + +## 💻 Object-Oriented Programming Concepts Used +This project is built using the main concepts of Object-Oriented Programming (OOP) in Java. Let’s explain each one in a simple way. + +### 1️⃣ Abstraction +Abstraction means defining the important structure first, and leaving the details for later. + +**In this project :**
+The Entity interface defines what every living being in the game must be able to do (like attack, defend, and take damage).
+The Player and Enemy classes are abstract.
+They contain shared logic.
+But they leave some methods (like specialAbility) for subclasses to implement. + +### 2️⃣ Inheritance +Inheritance allows one class to reuse properties and behaviors from another class. + +In this project:
+Knight, Assassin, and Wizard inherit from Player.
+Goblin, Skeleton, Vampire, and Dragon inherit from Enemy.
+This means:
+All players can attack and defend (because they inherit from Player).
+But each one has its own unique special ability. + +### 3️⃣ Polymorphism +Polymorphism means we can treat different objects as the same general type, but they behave differently. + +**Example :**
+```bash +player.specialAbility(target); +``` +Java decides at runtime which version to execute :
+- Knight’s ability
+- Wizard’s spell
+- Assassin’s strike + + +### 4️⃣ Encapsulation +Encapsulation means protecting the internal data of a class. + +In this project: +- Private Fields: Attributes like hp, mp, and xp in Player and Enemy classes are marked as private. +- Getters/Setters: Access to these variables is controlled via public methods like getHp(), setHp(), etc. + + +### 5️⃣ Interface +An interface works like a contract. + +The Entity interface says that every entity in the game must implement: +```bash +attack() +takeDamage() +isAlive() +``` +It doesn’t matter if it’s a Player or an Enemy — they must follow these rules. + +--- +## How to Run 🚀 +- Clone the repository.
+- Open the project in your preferred Java IDE.
+- Ensure all packages (org.project.entity, org.project.location, etc.) are correctly structured.
+- Run the Main class.
+ +**Follow the on-screen instructions to begin your adventure and enjoy the game :)** + -- 2.54.0 From 4288fd1de74677a6bdf718ac977028518cd40e17 Mon Sep 17 00:00:00 2001 From: Bita Date: Sat, 16 May 2026 14:44:44 +0330 Subject: [PATCH 4/4] Replace README --- README.md | 247 +++++++++++++++++++---------------------------------- README2.md | 104 ---------------------- 2 files changed, 88 insertions(+), 263 deletions(-) delete mode 100644 README2.md diff --git a/README.md b/README.md index 1e2c975..ffc83f5 100644 --- a/README.md +++ b/README.md @@ -1,175 +1,104 @@ -# Fourth Assignment - Java Knight ⚔️ +# Java Knight ⚔️ A turn-based RPG with Roguelike elements which can be run in the terminal. -### **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!* +### 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! -### **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. +### Your Mission : +1️⃣ Explore dangerous lands inhabited by Goblins, Skeletons, and Vampires.
+2️⃣ Defeat these enemies to gain experience points (XP) and collect special Keys.
+3️⃣ Collect all three keys (Goblin Key, Skeleton Key, Vampire Key).
+4️⃣ Once all keys are collected, the path to the Dragon’s Lair will open.
+5️⃣ Face the Dragon in a final, epic battle. Victory means saving the world; failure means eternal darkness.
--- +## How to play ? +#### 1. Character Selection 👤
+At the start of the game, choose one of the following classes:
+**💂‍♀️Knight :** Balanced stats with high defense. Good for players who prefer a tank-like playstyle.
+**🥷Assassin :** High damage output but lower HP. Requires careful management of MP for critical hits.
+**🧙‍♂️ Wizard :** Powerful magic abilities capable of dealing massive area damage, but fragile in close combat.
+#### 2. Combat System🎮 +Turn-Based Battles:
+Engage in turn-based combat against various enemies. -## Tasks 📝 - -### 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 🌲 - -A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing shared logic in abstract classes. - -- **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 - -![structure](Readme_Pictures/structure.png) - -### 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] - +**Actions:**
+- Attack: Basic free attack.
+- Heavy Attack: Costs MP but deals double damage.
+- Defend: Blocks incoming damage completely (Costs MP).
+- Special Ability: Each class has a unique powerful move (e.g., Wizard’s fireball, Assassin’s backstab).
+- Heal: Restore HP using MP.
+- Restore Mana/HP: Use accumulated XP to refill resources.
+- Enemy AI: Enemies can attack, defend, use special abilities, or heal themselves.
+#### 3. Progression & Keys🔑 +Killing specific types of enemies drops a corresponding key:
+Kill Goblins → Get Goblin Key.
+Kill Skeletons → Get Skeleton Key.
+Kill Vampires → Get Vampire Key.
+You must collect all 3 Keys to unlock the final stage.
+XP gained from battles allows you to restore health and mana during fights. --- -Your Turn: -1. Light Attack | 2. Heavy Attack (-8 Mana) | 3. Defend (-6 Mana) | 4. Heal (-12 Mana) | 5. Shield Bash (-15 Mana) -``` +## 💻 Object-Oriented Programming Concepts Used +This project is built using the main concepts of Object-Oriented Programming (OOP) in Java. Let’s explain each one in a simple way. +### 1️⃣ Abstraction +Abstraction means defining the important structure first, and leaving the details for later. + +**In this project :**
+The Entity interface defines what every living being in the game must be able to do (like attack, defend, and take damage).
+The Player and Enemy classes are abstract.
+They contain shared logic.
+But they leave some methods (like specialAbility) for subclasses to implement. + +### 2️⃣ Inheritance +Inheritance allows one class to reuse properties and behaviors from another class. + +In this project:
+Knight, Assassin, and Wizard inherit from Player.
+Goblin, Skeleton, Vampire, and Dragon inherit from Enemy.
+This means:
+All players can attack and defend (because they inherit from Player).
+But each one has its own unique special ability. + +### 3️⃣ Polymorphism +Polymorphism means we can treat different objects as the same general type, but they behave differently. + +**Example :**
```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 +player.specialAbility(target); ``` +Java decides at runtime which version to execute :
+- Knight’s ability
+- Wizard’s spell
+- Assassin’s strike + + +### 4️⃣ Encapsulation +Encapsulation means protecting the internal data of a class. + +In this project: +- Private Fields: Attributes like hp, mp, and xp in Player and Enemy classes are marked as private. +- Getters/Setters: Access to these variables is controlled via public methods like getHp(), setHp(), etc. + + +### 5️⃣ Interface +An interface works like a contract. + +The Entity interface says that every entity in the game must implement: +```bash +attack() +takeDamage() +isAlive() ``` -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). - - -### 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). +It doesn’t matter if it’s a Player or an Enemy — they must follow these rules. --- +## How to Run 🚀 +- Clone the repository.
+- Open the project in your preferred Java IDE.
+- Ensure all packages (org.project.entity, org.project.location, etc.) are correctly structured.
+- Run the Main class.
-## Evaluation Criteria ⚖ +**Follow the on-screen instructions to begin your adventure and enjoy the game :)** -| **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** | - -## 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. - -## 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. - -![cover](Readme_Pictures/image.png) -###### - 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 diff --git a/README2.md b/README2.md deleted file mode 100644 index ffc83f5..0000000 --- a/README2.md +++ /dev/null @@ -1,104 +0,0 @@ -# Java Knight ⚔️ -A turn-based RPG with Roguelike elements which can be run in the terminal. - -### 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! - -### Your Mission : -1️⃣ Explore dangerous lands inhabited by Goblins, Skeletons, and Vampires.
-2️⃣ Defeat these enemies to gain experience points (XP) and collect special Keys.
-3️⃣ Collect all three keys (Goblin Key, Skeleton Key, Vampire Key).
-4️⃣ Once all keys are collected, the path to the Dragon’s Lair will open.
-5️⃣ Face the Dragon in a final, epic battle. Victory means saving the world; failure means eternal darkness.
- ---- -## How to play ? -#### 1. Character Selection 👤
-At the start of the game, choose one of the following classes:
-**💂‍♀️Knight :** Balanced stats with high defense. Good for players who prefer a tank-like playstyle.
-**🥷Assassin :** High damage output but lower HP. Requires careful management of MP for critical hits.
-**🧙‍♂️ Wizard :** Powerful magic abilities capable of dealing massive area damage, but fragile in close combat.
-#### 2. Combat System🎮 -Turn-Based Battles:
-Engage in turn-based combat against various enemies. - -**Actions:**
-- Attack: Basic free attack.
-- Heavy Attack: Costs MP but deals double damage.
-- Defend: Blocks incoming damage completely (Costs MP).
-- Special Ability: Each class has a unique powerful move (e.g., Wizard’s fireball, Assassin’s backstab).
-- Heal: Restore HP using MP.
-- Restore Mana/HP: Use accumulated XP to refill resources.
-- Enemy AI: Enemies can attack, defend, use special abilities, or heal themselves.
-#### 3. Progression & Keys🔑 -Killing specific types of enemies drops a corresponding key:
-Kill Goblins → Get Goblin Key.
-Kill Skeletons → Get Skeleton Key.
-Kill Vampires → Get Vampire Key.
-You must collect all 3 Keys to unlock the final stage.
-XP gained from battles allows you to restore health and mana during fights. ---- - -## 💻 Object-Oriented Programming Concepts Used -This project is built using the main concepts of Object-Oriented Programming (OOP) in Java. Let’s explain each one in a simple way. - -### 1️⃣ Abstraction -Abstraction means defining the important structure first, and leaving the details for later. - -**In this project :**
-The Entity interface defines what every living being in the game must be able to do (like attack, defend, and take damage).
-The Player and Enemy classes are abstract.
-They contain shared logic.
-But they leave some methods (like specialAbility) for subclasses to implement. - -### 2️⃣ Inheritance -Inheritance allows one class to reuse properties and behaviors from another class. - -In this project:
-Knight, Assassin, and Wizard inherit from Player.
-Goblin, Skeleton, Vampire, and Dragon inherit from Enemy.
-This means:
-All players can attack and defend (because they inherit from Player).
-But each one has its own unique special ability. - -### 3️⃣ Polymorphism -Polymorphism means we can treat different objects as the same general type, but they behave differently. - -**Example :**
-```bash -player.specialAbility(target); -``` -Java decides at runtime which version to execute :
-- Knight’s ability
-- Wizard’s spell
-- Assassin’s strike - - -### 4️⃣ Encapsulation -Encapsulation means protecting the internal data of a class. - -In this project: -- Private Fields: Attributes like hp, mp, and xp in Player and Enemy classes are marked as private. -- Getters/Setters: Access to these variables is controlled via public methods like getHp(), setHp(), etc. - - -### 5️⃣ Interface -An interface works like a contract. - -The Entity interface says that every entity in the game must implement: -```bash -attack() -takeDamage() -isAlive() -``` -It doesn’t matter if it’s a Player or an Enemy — they must follow these rules. - ---- -## How to Run 🚀 -- Clone the repository.
-- Open the project in your preferred Java IDE.
-- Ensure all packages (org.project.entity, org.project.location, etc.) are correctly structured.
-- Run the Main class.
- -**Follow the on-screen instructions to begin your adventure and enjoy the game :)** - -- 2.54.0