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 0000000..cad7b82
Binary files /dev/null and b/Java-Knight/target/classes/org/project/Main.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/Entity.class b/Java-Knight/target/classes/org/project/entity/Entity.class
new file mode 100644
index 0000000..88bbd81
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/Entity.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Dragon.class b/Java-Knight/target/classes/org/project/entity/enemies/Dragon.class
new file mode 100644
index 0000000..5e9f998
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Dragon.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Enemy.class b/Java-Knight/target/classes/org/project/entity/enemies/Enemy.class
new file mode 100644
index 0000000..92b534e
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Enemy.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Goblin.class b/Java-Knight/target/classes/org/project/entity/enemies/Goblin.class
new file mode 100644
index 0000000..39ad8ec
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Goblin.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class b/Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class
new file mode 100644
index 0000000..64fec55
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/enemies/Vampire.class b/Java-Knight/target/classes/org/project/entity/enemies/Vampire.class
new file mode 100644
index 0000000..5be0cd3
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/enemies/Vampire.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Assassin.class b/Java-Knight/target/classes/org/project/entity/players/Assassin.class
new file mode 100644
index 0000000..4171b71
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Assassin.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Knight.class b/Java-Knight/target/classes/org/project/entity/players/Knight.class
new file mode 100644
index 0000000..a147354
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Knight.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Player.class b/Java-Knight/target/classes/org/project/entity/players/Player.class
new file mode 100644
index 0000000..dafec99
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Player.class differ
diff --git a/Java-Knight/target/classes/org/project/entity/players/Wizard.class b/Java-Knight/target/classes/org/project/entity/players/Wizard.class
new file mode 100644
index 0000000..7d72b53
Binary files /dev/null and b/Java-Knight/target/classes/org/project/entity/players/Wizard.class differ
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 0000000..fd5781a
Binary files /dev/null and b/Java-Knight/target/classes/org/project/location/GameDisplay.class differ
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 0000000..03832c8
Binary files /dev/null and b/Java-Knight/target/classes/org/project/location/GameEngine.class differ
diff --git a/Java-Knight/target/classes/org/project/location/Location.class b/Java-Knight/target/classes/org/project/location/Location.class
new file mode 100644
index 0000000..a092afa
Binary files /dev/null and b/Java-Knight/target/classes/org/project/location/Location.class differ