diff --git a/Java-Knight.rar b/Java-Knight.rar
new file mode 100644
index 0000000..b1c09cc
Binary files /dev/null and b/Java-Knight.rar differ
diff --git a/Java-Knight/.idea/.gitignore b/Java-Knight/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/Java-Knight/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/Java-Knight/.idea/compiler.xml b/Java-Knight/.idea/compiler.xml
new file mode 100644
index 0000000..935cb4a
--- /dev/null
+++ b/Java-Knight/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/.idea/encodings.xml b/Java-Knight/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/Java-Knight/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/.idea/jarRepositories.xml b/Java-Knight/.idea/jarRepositories.xml
new file mode 100644
index 0000000..e84e677
--- /dev/null
+++ b/Java-Knight/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/.idea/misc.xml b/Java-Knight/.idea/misc.xml
new file mode 100644
index 0000000..eba6e1f
--- /dev/null
+++ b/Java-Knight/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/.idea/vcs.xml b/Java-Knight/.idea/vcs.xml
new file mode 100644
index 0000000..6ddb3e9
--- /dev/null
+++ b/Java-Knight/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/.idea/.gitignore b/Java-Knight/src/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/Java-Knight/src/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/Java-Knight/src/.idea/misc.xml b/Java-Knight/src/.idea/misc.xml
new file mode 100644
index 0000000..a20905f
--- /dev/null
+++ b/Java-Knight/src/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/.idea/modules.xml b/Java-Knight/src/.idea/modules.xml
new file mode 100644
index 0000000..ec92401
--- /dev/null
+++ b/Java-Knight/src/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/.idea/vcs.xml b/Java-Knight/src/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/Java-Knight/src/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/Java-Knight.iml b/Java-Knight/src/Java-Knight.iml
new file mode 100644
index 0000000..54c844c
--- /dev/null
+++ b/Java-Knight/src/Java-Knight.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/main/.idea/main.iml b/Java-Knight/src/main/.idea/main.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/Java-Knight/src/main/.idea/main.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/main/.idea/modules.xml b/Java-Knight/src/main/.idea/modules.xml
new file mode 100644
index 0000000..aaf7df4
--- /dev/null
+++ b/Java-Knight/src/main/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/main/.idea/vcs.xml b/Java-Knight/src/main/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/Java-Knight/src/main/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/main/.idea/workspace.xml b/Java-Knight/src/main/.idea/workspace.xml
new file mode 100644
index 0000000..a25c6bc
--- /dev/null
+++ b/Java-Knight/src/main/.idea/workspace.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1778879078762
+
+
+ 1778879078762
+
+
+
+
+
\ No newline at end of file
diff --git a/Java-Knight/src/main/java/org/project/Colors.java b/Java-Knight/src/main/java/org/project/Colors.java
new file mode 100644
index 0000000..9165589
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/Colors.java
@@ -0,0 +1,12 @@
+package org.project;
+
+public class Colors {
+
+ public static final String RESET = "\u001B[0m";
+ 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 PURPLE = "\u001B[35m";
+ public static final String CYAN = "\u001B[36m";
+}
diff --git a/Java-Knight/src/main/java/org/project/Main.java b/Java-Knight/src/main/java/org/project/Main.java
index 6bde20e..cbc4615 100644
--- a/Java-Knight/src/main/java/org/project/Main.java
+++ b/Java-Knight/src/main/java/org/project/Main.java
@@ -1,15 +1,311 @@
package org.project;
+import org.project.entity.enemies.*;
+import org.project.entity.players.*;
+import org.project.item.armors.*;
+import org.project.item.weapons.*;
import org.project.location.Location;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Scanner;
+import java.util.Random;
public class Main {
+ private static Scanner in = new Scanner(System.in);
+ private static Random random = new Random();
+ private static String playerClass = "";
+ private static int totalKeys = 0;
+
public static void main(String[] args) {
- // TODO: ADD LOCATIONS TO YOUR GAME
- List locations = new ArrayList<>();
+ System.out.println("Enter your name:");
+ String name = in.next();
+
+ System.out.println("choose your character:\n1.Knight 2.Wizard 3.Assassin");
+ int choice = in.nextInt();
+
+ Player player = null;
+
+ switch (choice) {
+ case 1:
+ player = new Knight(name);
+ playerClass = "knight";
+ break;
+ case 2:
+ player = new Wizard(name);
+ playerClass = "wizard";
+ break;
+ case 3:
+ player = new Assassin(name);
+ playerClass = "assassin";
+ break;
+ default:
+ player = new Knight(name);
+ playerClass = "knight";
+ }
+
+ final Player finalPlayer = player;
+
+ int menuChoice = 0;
+ while (menuChoice != 3) {
+ clearScreen();
+ displayMenu();
+ menuChoice = in.nextInt();
+
+ switch (menuChoice) {
+ case 1:
+ newGame(1, finalPlayer);
+ break;
+ case 2:
+ newGame(2, finalPlayer);
+ break;
+ case 3:
+ System.out.println("\nπ GOODBYE!");
+ break;
+ }
+ }
+ }
+
+ public static void displayMenu() {
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.println("β ποΈ KEYS: " + totalKeys + " ποΈ β");
+ System.out.println("β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ£");
+ System.out.println("β β");
+ System.out.println("β βοΈ [1] NEW GAME βοΈ β");
+ System.out.println("β π [2] VS DRAGON π β");
+ System.out.println("β β [3] EXIT β β");
+ System.out.println("β β");
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.print("β‘οΈ CHOOSE: ");
+ }
+
+ public static void newGame(int model, Player player) {
+ Enemy enemy = null;
- // TODO: IMPLEMENT GAMEPLAY
+ //Ψ¬ΩΪ― Ψ¨Ψ§ Ψ―Ψ΄Ω
Ω Ψ±ΩΨ―ΩΩ
+ if (model == 1) {
+ Location loc=new Location();
+ String location = loc.chooseLocation();
+ System.out.println("π You are in " + location);
+
+ if (loc.thereIsKey()) {
+ System.out.println("π There is a Key here!");
+ }
+ delay(2500);
+
+ int chooseEnemy = random.nextInt(3);
+ switch (chooseEnemy) {
+ case 0:
+ enemy = new Skeleton();
+ System.out.println("You're fighting with skeleton \uD83D\uDC80");
+ break;
+ case 1:
+ enemy = new Vampier();
+ System.out.println("You're fighting with Vampire \uD83E\uDDDB");
+ break;
+ case 2:
+ enemy = new Orc();
+ System.out.println("You're fighting with Orc \uD83D\uDC79");
+ break;
+ }
+ delay(3000);
+
+ startBattle(player, enemy,loc);
+
+ //Ψ¬ΩΪ― Ψ¨Ψ§ Ψ§ΪΨ―ΩΨ§
+ } else {
+ if (totalKeys >= 3) {
+ enemy = new Dragon();
+ System.out.println("π YOU ARE IN DRAGON'S HOUSE! π");
+ System.out.println(" You used 3 keys!");
+ totalKeys -= 3;
+ Location loc=new Location(1);// ΨͺΨ§Ψ¨ΨΉ Ψ³Ψ§Ψ²ΩΨ―Ω Ψ§ΪΨ―ΩΨ§ ΫΪ© ΨΉΨ―Ψ― ΩΨ±ΩΨ―Ϋ Ψ―Ψ±ΫΨ§ΩΨͺ Ω
ΫΪ©ΩΩ
+ delay(2000);
+
+ startBattle(player, enemy, loc);
+
+ if (enemy.getHp() <= 0) {
+ System.out.println("π LEGEND! YOU DEFEATED THE DRAGON! π");
+ }
+
+ //Ψ§Ϊ―Ψ± 3 Ϊ©ΩΫΨ― ΩΨ―Ψ§Ψ΄Ψͺ
+ } else {
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.println("β β YOU NEED 3 KEYS TO FIGHT THE DRAGON! β β");
+ System.out.printf("β π YOUR KEYS: %d / 3 β\n", totalKeys);
+ System.out.println("β βοΈ Defeat enemies in NEW GAME to get keys! β");
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ delay(2000);
+ }
+ }
+ }
+
+ public static void startBattle(Player player, Enemy enemy, Location loc) {
+ while (player.getHp() > 0 && enemy.getHp() > 0) {
+ clearScreen();
+ displayBattle(player.getHp(), player.getMaxHP(), player.getMp(), player.getMaxMP(),
+ enemy.getHp(), enemy.getMaxHP(), player.getArmor().getDurability(),
+ player.getArmor().getDefense(), playerClass);
+
+ int playerChoice = in.nextInt();
+ clearScreen();
+
+ System.out.println("You:");
+ switch (playerChoice) {
+ case 1:
+ player.LightAttack(enemy);
+ break;
+ case 2:
+ if (player.getMp() > 0) {
+ player.HeavyAttack(enemy);
+ } else
+ {
+ System.out.println("Your MP is out.");
+ player.LightAttack(enemy);
+ }
+ break;
+ case 3:
+ if(player.getMp()>0)
+ player.defend();
+ else
+ {
+ System.out.println("Your MP is out.");
+ player.LightAttack(enemy);
+ }
+ break;
+ case 4:
+ if(player.getMp()>0)
+ player.SpecialAttack(enemy,1);
+ else
+ {
+ System.out.println("Your MP is out.");
+ player.LightAttack(enemy);
+ }
+ break;
+ case 5:
+ if(player.getMp()>0)
+ player.heal();
+ else
+ {
+ System.out.println("Your MP is out.");
+ player.LightAttack(enemy);
+ }
+ break;
+ }
+
+ delay(2500);
+
+ if (enemy.getHp() > 0) {
+ clearScreen();
+ System.out.println("Enemy: ");
+ int enemyMove = random.nextInt(3);
+ switch (enemyMove) {
+ case 0:
+ if(!player.getIsDefending()) {
+ enemy.LightAttack(player);
+ System.out.println("The enemy made a light attack \uD83D\uDC4A");
+ }
+ else {
+ player.defend();
+ System.out.println("The enemy attacked, but you defended.\uD83D\uDCAF");
+ }
+ break;
+ case 1:
+ enemy.heal();
+ System.out.println("The enemy healed. \uD83E\uDE84");
+ break;
+ case 2:
+ if(!player.getIsDefending())
+ {
+ if (enemy instanceof Vampier) {
+ enemy.HeavyAttack(player);
+ System.out.println("The Vampire made a heavy attack \uD83E\uDE78");
+ } else if (enemy instanceof Dragon) {
+ ((Dragon) enemy).burn(player);
+ System.out.println("The dragon breathed fire \uD83D\uDD25\uD83D\uDD25");
+ } else {
+ enemy.LightAttack(player);
+ System.out.println("The enemy made a light attack \uD83D\uDC4A");
+ }
+ }
+ else
+ {
+ player.defend();
+ System.out.println("The enemy attacked, but you defended.\uD83D\uDCAF");
+ }
+ break;
+ }
+ delay(2500);
+ }
+ }
+
+ clearScreen();
+ if (enemy.getHp() <= 0) {
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.println("β π YOU WON! π β");
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+
+ if (loc.thereIsKey()) {
+ totalKeys++;
+ System.out.println("π You found a KEY on the enemy!");
+ System.out.println("ποΈ Total keys: " + totalKeys);
+ }
+ } else {
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.println("β π YOU LOST! π β");
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ }
+ delay(2500);
+ player.fillHP();
+ player.fillHP();
+ player.filldurability();
+ }
+
+
+ public static void displayBattle(int playerHP, int playerMaxHP, int playerMP, int playerMaxMP,
+ int enemyHP, int enemyMaxHP, int ArmorDurability, int ArmorDefense, String playerClass) {
+
+ String playerEmoji = "";
+ if (playerClass.equals("wizard")) {
+ playerEmoji = "π§";
+ } else if (playerClass.equals("knight")) {
+ playerEmoji = "βοΈ";
+ } else if (playerClass.equals("assassin")) {
+ playerEmoji = "π‘οΈ";
+ } else {
+ playerEmoji = "π§";
+ }
+
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.println("β βοΈ BATTLE START! βοΈ β");
+ System.out.println("β ββββββββββββββββββββββββ¦βββββββββββββββββββββββββββββββββββββββββββββββ£");
+ System.out.printf("β %s %-18sβ πΎ %-30sβ\n", playerEmoji, playerClass.toUpperCase(), "ENEMY");
+ System.out.println("β ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββ£");
+ System.out.printf("β β€οΈ HP: %3d/%-3d β β€οΈ HP: %3d/%-3d β\n",
+ playerHP, playerMaxHP, enemyHP, enemyMaxHP);
+ System.out.printf("β π MP: %3d/%-3d β βοΈ %-40sβ\n",
+ playerMP, playerMaxMP, "");
+ System.out.printf("β π‘οΈ Armor: Durability: %3d Defense: %3d β\n",
+ ArmorDurability,
+ ArmorDefense);
+ System.out.println("βββββββββββββββββββββββββ©βββββββββββββββββββββββββββββββββββββββββββββββ");
+
+ System.out.println("\nπ ACTIONS:");
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.println("β [1] β‘ Light Attack [2] π₯ Heavy Attack [3] π‘οΈ Defend β");
+ System.out.println("β [4] β¨ Special Attack [5] π Heal β");
+ System.out.println("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
+ System.out.print("\nβ‘οΈ Choose: ");
+ }
+
+ public static void clearScreen() {
+ System.out.print("\033[H\033[2J");
+ System.out.flush();
+ }
+
+ public static void delay(int ms) {
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
}
}
\ No newline at end of file
diff --git a/Java-Knight/src/main/java/org/project/entity/Entity.java b/Java-Knight/src/main/java/org/project/entity/Entity.java
index 2a060f9..a5bbb93 100644
--- a/Java-Knight/src/main/java/org/project/entity/Entity.java
+++ b/Java-Knight/src/main/java/org/project/entity/Entity.java
@@ -1,21 +1,13 @@
package org.project.entity;
public interface Entity {
- void attack(Entity target);
- void defend();
+ void LightAttack(Entity target);
- void heal(int health);
-
- void fillMana(int mana);
+ void heal();
void takeDamage(int damage);
int getMaxHP();
- int getMaxMP();
-
- /*
- TODO: ADD OTHER REQUIRED AND BONUS METHODS
- */
}
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..0b3f83e
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java
@@ -0,0 +1,15 @@
+package org.project.entity.enemies;
+
+import org.project.entity.players.Player;
+import org.project.item.weapons.wand;
+
+public class Dragon extends Enemy{
+ public Dragon(){
+ super(400, 400, new wand());
+ }
+
+ public void burn(Player player)
+ {
+ player.takeDamage(70);
+ }
+}
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..e79c64c 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,17 +1,18 @@
package org.project.entity.enemies;
import org.project.item.weapons.Weapon;
+import org.project.entity.Entity;
+import org.project.Colors;
// TODO: UPDATE IMPLEMENTATION
-public abstract class Enemy {
+public class Enemy implements Entity{
Weapon weapon;
private int hp;
- private int mp;
+ private int maxHP;
- public Enemy(int hp, int mp, Weapon weapon) {
+ public Enemy(int hp, int maxHP, Weapon weapon) {
this.hp = hp;
- this.mp = mp;
-
+ this.maxHP = maxHP;
this.weapon = weapon;
}
@@ -20,12 +21,33 @@ public abstract class Enemy {
hp -= damage;
}
+ @Override
+ public void LightAttack(Entity target) {
+ target.takeDamage(weapon.getLightDamage());
+ }
+
+ public void HeavyAttack(Entity target)
+ {
+ System.out.println("poof");
+ }
+
+ @Override
+ public void heal() {
+ hp += 20;
+ if (hp > maxHP) {
+ hp = maxHP;
+ }
+ hp -= 20;
+
+ }
+
public int getHp() {
return hp;
}
- public int getMp() {
- return mp;
+ @Override
+ public int getMaxHP() {
+ return maxHP;
}
public Weapon getWeapon() {
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Orc.java b/Java-Knight/src/main/java/org/project/entity/enemies/Orc.java
new file mode 100644
index 0000000..b19e3f5
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Orc.java
@@ -0,0 +1,14 @@
+package org.project.entity.enemies;
+
+import org.project.item.weapons.Sword;
+
+public class Orc extends Enemy{
+
+ public Orc()
+ {
+ super(200, 200, new Sword());
+ }
+}
+
+
+
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..855430a 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,12 @@
package org.project.entity.enemies;
+import org.project.item.weapons.machete;
+
// TODO: UPDATE IMPLEMENTATION
-public class Skeleton {
- // TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
-}
+public class Skeleton extends Enemy{
+
+ public Skeleton()
+ {
+ super(50,50, new machete());
+ }
+}
\ No newline at end of file
diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Vampier.java b/Java-Knight/src/main/java/org/project/entity/enemies/Vampier.java
new file mode 100644
index 0000000..b4f9046
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/enemies/Vampier.java
@@ -0,0 +1,17 @@
+package org.project.entity.enemies;
+
+import org.project.entity.Entity;
+import org.project.item.weapons.Sword;
+
+public class Vampier extends Enemy{
+
+ public Vampier()
+ {
+ super(200, 200, new Sword());
+ }
+
+ @Override
+ public void HeavyAttack(Entity target) {
+ target.takeDamage(((Sword) getWeapon()).getHeavyDamage());
+ }
+}
\ 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
new file mode 100644
index 0000000..980c43b
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java
@@ -0,0 +1,42 @@
+package org.project.entity.players;
+
+import org.project.entity.Entity;
+import org.project.Colors;
+import org.project.item.armors.AssassinArmor;
+import org.project.item.weapons.machete;
+
+
+public class Assassin extends Player{
+ public Assassin(String name)
+ {
+
+ super(name, new machete(), new AssassinArmor());
+ }
+
+ @Override
+ public void SpecialAttack(Entity target, int time)
+ {
+ if (time>0){
+ time--;
+ mp=100;
+
+ System.out.println(Colors.PURPLE + "β¨ SPECIAL ATTACK! β¨" + Colors.RESET);
+ System.out.println(Colors.PURPLE + "WHOOSH!" + Colors.RESET);
+ System.out.println("π₯ Recovery completed ");
+ }
+ }
+
+ @Override
+ public void heal() {
+ hp += 15;
+ if (hp > 100) {
+ hp = 100;
+ }
+ mp-=10;
+ System.out.println(Colors.GREEN + "π HEAL! π" + Colors.RESET);
+ System.out.println(Colors.GREEN + " WHOOSH!" + Colors.RESET);
+ System.out.println(Colors.RED + " HP restored: + 15" + Colors.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 14d8fa2..b679851 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,35 @@
package org.project.entity.players;
+import org.project.entity.Entity;
+import org.project.item.armors.KnightArmor;
+import org.project.item.weapons.Sword;
+import org.project.Colors;
+
// TODO: UPDATE IMPLEMENTATION
-public class Knight {
- // TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
-}
+
+public class Knight extends Player {
+
+ Sword sward=new Sword();
+
+ public Knight(String name) {
+
+ super(name, new Sword(), new KnightArmor());
+ }
+
+ @Override
+ public void SpecialAttack(Entity target, int time) {
+ if (time > 0) {
+ time--;
+ int index = hp;
+ HeavyAttack(target);
+ HeavyAttack(target);
+ hp = index;
+ mp -= 20;
+
+ System.out.println(Colors.PURPLE + "β¨ SPECIAL ATTACK! β¨" + Colors.RESET);
+ System.out.println(Colors.PURPLE + "KABOOM!" + Colors.RESET);
+ System.out.println("π₯ Damage: " + 2 * sward.getHeavyDamage());
+ }
+ }
+
+}
\ 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 ff5385c..cd79158 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
@@ -3,58 +3,88 @@ 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.Colors;
// TODO: UPDATE IMPLEMENTATION
-public abstract class Player {
+public class Player implements Entity{
protected String name;
Weapon weapon;
Armor armor;
- private int hp;
- private int maxHP;
- private int mp;
- private int maxMP;
+ protected int hp = 100;
+ private int maxHP = 100;
+ protected int mp = 100;
+ private int maxMP = 100;
+ private boolean isDefending = false;
- public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
+ public Player(String name, Weapon weapon, Armor armor) {
this.name = name;
- this.hp = hp;
- this.mp = mp;
-
this.weapon = weapon;
this.armor = armor;
}
- @Override
- public void attack(Entity target) {
- target.takeDamage(weapon.getDamage());
+ public void SpecialAttack(Entity target, int time) {
+ System.out.println("poof");
+ }
+
+
+ public void HeavyAttack(Entity target) {
+ target.takeDamage(weapon.getHeavyDamage());
+ mp -= weapon.getManaCost();
+
+ System.out.println(Colors.CYAN + "β‘ HEAVY ATTACK! β‘" + Colors.RESET);
+ System.out.println(Colors.GREEN + "BOOM!" + Colors.RESET);
+ System.out.println(Colors.YELLOW + " π‘οΈ Damage: " + weapon.getHeavyDamage() + Colors.RESET);
}
@Override
+ public void LightAttack(Entity target) {
+ target.takeDamage(weapon.getLightDamage());
+
+ System.out.println(Colors.CYAN + "β‘ LIGHT ATTACK! β‘" + Colors.RESET);
+ System.out.println(Colors.GREEN + " SMASH!" + Colors.RESET);
+ System.out.println(Colors.YELLOW + " π‘οΈ Damage: " + weapon.getLightDamage() + Colors.RESET);
+ }
+
public void defend() {
- // TODO
- }
+ if (!isDefending) {
+ mp -= 10;
+ }
+ isDefending = !isDefending;
+ System.out.println("π‘οΈ Defend! π‘οΈ");
+ System.out.println(Colors.BLUE + "THWACK!" + Colors.RESET);
+ System.out.println(" Damage reduced!");
+ }
@Override
public void takeDamage(int damage) {
hp -= damage - armor.getDefense();
+ armor.decreacDurability();
}
@Override
- public void heal(int health) {
- hp += health;
+ public void heal() {
+ hp += 10;
if (hp > maxHP) {
hp = maxHP;
}
+ mp -= 10;
+
+ System.out.println(Colors.GREEN + "π HEAL! π" + Colors.RESET);
+ System.out.println(Colors.GREEN + "WHOOSH!" + Colors.RESET);
+ System.out.println(Colors.RED + " HP restored: +10" + Colors.RESET);
}
- @Override
- public void fillMana(int mana) {
- mp += mana;
- if (mp > maxMP) {
+ public void fillMana() {
mp = maxMP;
- }
}
+ public void fillHP() {hp=maxHP; }
+
+ public void filldurability()
+ {
+ armor.filldur();
+ }
public String getName() {
return name;
@@ -64,7 +94,6 @@ public abstract class Player {
return hp;
}
- @Override
public int getMaxHP() {
return maxHP;
}
@@ -73,7 +102,6 @@ public abstract class Player {
return mp;
}
- @Override
public int getMaxMP() {
return maxMP;
}
@@ -86,4 +114,8 @@ public abstract class Player {
return armor;
}
+ public boolean getIsDefending() {
+ return isDefending;
+ }
+
}
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..ef8d542
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java
@@ -0,0 +1,43 @@
+package org.project.entity.players;
+
+import org.project.entity.Entity;
+import org.project.Colors;
+import org.project.item.armors.WizardArmor;
+import org.project.item.weapons.wand;
+import org.project.item.armors.WizardArmor;
+
+import org.project.item.weapons.Weapon;
+
+public class Wizard extends Player {
+
+ public Wizard(String name) {
+ super(name, new wand(), new WizardArmor());
+
+ }
+
+ @Override
+ public void SpecialAttack(Entity target, int time) {
+ if (time > 0) {
+ time--;
+ hp = 100;
+ mp -= 20;
+
+ System.out.println(Colors.PURPLE + "β¨ SPECIAL ATTACK! β¨" + Colors.RESET);
+ System.out.println(Colors.PURPLE + "WHOOSH!" + Colors.RESET);
+ System.out.println("π₯ Recovery completed ");
+ }
+ }
+
+ @Override
+ public void heal() {
+ hp += 30;
+ if (hp > 100) {
+ hp = 100;
+ }
+ mp -= 10;
+
+ System.out.println(Colors.GREEN + "π HEAL! π" + Colors.RESET);
+ System.out.println(Colors.GREEN + " WHOOSH!" + Colors.RESET);
+ System.out.println(Colors.RED + " HP restored: + 30" + Colors.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 6d6b5ad..0000000
--- a/Java-Knight/src/main/java/org/project/item/Item.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.project.item;
-
-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/armors/Armor.java b/Java-Knight/src/main/java/org/project/item/armors/Armor.java
index 7ca8774..0940a01 100644
--- a/Java-Knight/src/main/java/org/project/item/armors/Armor.java
+++ b/Java-Knight/src/main/java/org/project/item/armors/Armor.java
@@ -4,8 +4,8 @@ package org.project.item.armors;
public abstract class Armor {
private int defense;
private int maxDefense;
- private int durability;
- private int maxDurability;
+ protected int durability;
+ private final int maxDurability=100;
private boolean isBroke;
@@ -21,6 +21,22 @@ public abstract class Armor {
}
}
+ public void decreacDurability()
+ {
+ if(durability>30)
+ durability-=30;
+ else
+ {
+ durability=0;
+ checkBreak();
+ }
+ }
+
+ public void filldur()
+ {
+ durability=maxDurability;
+ }
+
// TODO: (BONUS) UPDATE THE REPAIR METHOD
public void repair() {
isBroke = false;
diff --git a/Java-Knight/src/main/java/org/project/item/armors/AssassinArmor.java b/Java-Knight/src/main/java/org/project/item/armors/AssassinArmor.java
new file mode 100644
index 0000000..0a1dc34
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/armors/AssassinArmor.java
@@ -0,0 +1,9 @@
+package org.project.item.armors;
+
+public class AssassinArmor extends Armor {
+
+ public AssassinArmor()
+ {
+ super(10 , 100);
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java b/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java
index eb59a46..8f934cf 100644
--- a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java
+++ b/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java
@@ -1,6 +1,21 @@
package org.project.item.armors;
// TODO: UPDATE IMPLEMENTATION
-public class KnightArmor {
- // TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
+public class KnightArmor extends Armor{
+ public KnightArmor ()
+ {
+ super(15, 100);
+ }
+
+ @Override
+ public void decreacDurability()
+ {
+ if(durability>10)
+ durability-=10;
+ else
+ {
+ durability=0;
+ checkBreak();
+ }
+ }
}
\ No newline at end of file
diff --git a/Java-Knight/src/main/java/org/project/item/armors/WizardArmor.java b/Java-Knight/src/main/java/org/project/item/armors/WizardArmor.java
new file mode 100644
index 0000000..01043a0
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/armors/WizardArmor.java
@@ -0,0 +1,21 @@
+package org.project.item.armors;
+
+public class WizardArmor extends Armor{
+
+ public WizardArmor()
+ {
+ super(10 , 100);
+ }
+
+ @Override
+ public void decreacDurability()
+ {
+ if(durability>20)
+ durability-=20;
+ else
+ {
+ durability=0;
+ checkBreak();
+ }
+ }
+}
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
index 96226ee..e344232 100644
--- a/Java-Knight/src/main/java/org/project/item/weapons/Sword.java
+++ b/Java-Knight/src/main/java/org/project/item/weapons/Sword.java
@@ -4,23 +4,13 @@ import org.project.entity.Entity;
import java.util.ArrayList;
-// TODO: UPDATE IMPLEMENTATION
-public class Sword {
- /*
- THIS IS AN EXAMPLE OF A WEAPON DESIGN.
- */
-
- int abilityCharge;
+public class Sword extends Weapon{
public Sword() {
- // TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
+ super(30,50,10);
}
+
// 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
index cb9fcf2..651dfd5 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
@@ -3,26 +3,29 @@ package org.project.item.weapons;
import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION
-public abstract class Weapon {
- private int damage;
+public class Weapon {
+ private int LightDamage;
+ private int HeavyDamage;
private int manaCost;
/*
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
*/
- public Weapon(int damage, int manaCost) {
- this.damage = damage;
+ public Weapon(int LightDamage,int HeavyDamage, int manaCost) {
+ this.LightDamage = LightDamage;
+ this.HeavyDamage=HeavyDamage;
this.manaCost = manaCost;
}
- @Override
- public void use(Entity target) {
- target.takeDamage(damage);
+
+ public int getLightDamage() {
+ return LightDamage;
}
- public int getDamage() {
- return damage;
+ public int getHeavyDamage()
+ {
+ return HeavyDamage;
}
public int getManaCost() {
diff --git a/Java-Knight/src/main/java/org/project/item/weapons/machete.java b/Java-Knight/src/main/java/org/project/item/weapons/machete.java
new file mode 100644
index 0000000..0525172
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/weapons/machete.java
@@ -0,0 +1,8 @@
+package org.project.item.weapons;
+
+public class machete extends Weapon{
+ public machete()
+ {
+ super(20,30,5);
+ }
+}
diff --git a/Java-Knight/src/main/java/org/project/item/weapons/wand.java b/Java-Knight/src/main/java/org/project/item/weapons/wand.java
new file mode 100644
index 0000000..74fbae7
--- /dev/null
+++ b/Java-Knight/src/main/java/org/project/item/weapons/wand.java
@@ -0,0 +1,9 @@
+package org.project.item.weapons;
+
+
+public class wand extends Weapon{
+ public wand()
+ {
+ super(10,75,30);
+ }
+}
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..641512a 100644
--- a/Java-Knight/src/main/java/org/project/location/Location.java
+++ b/Java-Knight/src/main/java/org/project/location/Location.java
@@ -1,28 +1,44 @@
package org.project.location;
-import org.project.entity.enemies.Enemy;
-
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Random;
public class Location {
- private String name;
-
- private ArrayList enemies;
-
- public Location(ArrayList locations, ArrayList enemies) {
- this.locations = locations;
- this.enemies = enemies;
+ private ArrayList locations;
+ private Random random;
+ ArrayList key=new ArrayList<>();
+
+ public Location() {
+ random = new Random();
+ locations = new ArrayList<>(Arrays.asList(
+ " Shire", " Rivendell", " LothlΓ³rien",
+ " Gondor", " Mordor", " Isengard",
+ " Moria", " Minas Morgul", " Paths of the Dead"
+ ));
+ for(int i=0; i<9; i++)
+ {
+ key.add(1);
+ }
}
- public String getName() {
- return name;
+ public Location(int i)
+ {
+ key.add(0);
}
-
- public ArrayList getLocations() {
- return locations;
+
+ public String chooseLocation() {
+ return locations.get(random.nextInt(locations.size()));
}
-
- public ArrayList getEnemies() {
- return enemies;
+
+ public boolean thereIsKey()
+ {
+ int i= random.nextInt(key.size()*2);
+ if (i