Complete other classes
This commit is contained in:
Generated
+3
@@ -9,5 +9,8 @@
|
||||
<module name="Java-Knight" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="README" target="25" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+2
@@ -3,5 +3,7 @@
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/Java-Knight/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/Java-Knight/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/README/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/README/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -5,8 +5,14 @@
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/Java-Knight/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/README/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredFiles">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/README/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
|
||||
@@ -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<Location> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.project.item;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public interface Item {
|
||||
void use(Entity target);
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Consumable {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
target.takeDamage(getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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("");
|
||||
}
|
||||
}
|
||||
@@ -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<Location> locations = new ArrayList<>();
|
||||
|
||||
public GameEngine(Player player)
|
||||
{
|
||||
this.player = player;
|
||||
createLocations();
|
||||
}
|
||||
|
||||
public void runGame()
|
||||
{
|
||||
Location dragonLoc = locations.get(locations.size() - 1);
|
||||
|
||||
List<Location> 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<Enemy> 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<Enemy> goblins = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
goblins.add(new Goblin(10, 10, "Goblin👹"));
|
||||
}
|
||||
|
||||
List<Enemy> skeletons = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
skeletons.add(new Skeleton(20, 20, "Skeleton💀"));
|
||||
}
|
||||
|
||||
List<Enemy> vampires = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
vampires.add(new Vampire(30, 30, "Vampire🧛♂️"));
|
||||
}
|
||||
|
||||
List<Enemy> 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));
|
||||
}
|
||||
}
|
||||
@@ -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<Enemy> enemies;
|
||||
private List<Enemy> enemies;
|
||||
|
||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||
this.locations = locations;
|
||||
public Location(String name,List<Enemy> enemies)
|
||||
{
|
||||
this.name = name;
|
||||
this.enemies = enemies;
|
||||
}
|
||||
|
||||
@@ -17,11 +19,7 @@ public class Location {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<Location> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public ArrayList<Enemy> getEnemies() {
|
||||
public List<Enemy> getEnemies() {
|
||||
return enemies;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user