HW 04
This commit is contained in:
Binary file not shown.
@@ -1,15 +1,907 @@
|
||||
package org.project;
|
||||
|
||||
import org.project.entity.enemies.*;
|
||||
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.item.armors.*;
|
||||
import org.project.item.potions.Potion;
|
||||
import org.project.item.potions.healthPotion;
|
||||
import org.project.item.potions.mixedPotion;
|
||||
import org.project.item.potions.strengthPotion;
|
||||
import org.project.item.weapons.*;
|
||||
import org.project.location.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.lang.foreign.PaddingLayout;
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
||||
List<Location> locations = new ArrayList<>();
|
||||
|
||||
// TODO: IMPLEMENT GAMEPLAY
|
||||
//color codes
|
||||
|
||||
public static final String RESET = "\u001B[0m";
|
||||
|
||||
public static final String ELECTRIC_PURPLE = "\033[38;5;93m";
|
||||
public static final String YELLOW_VIVID = "\033[38;5;226m";
|
||||
|
||||
//colorful characters
|
||||
|
||||
static String leftParanthese = ELECTRIC_PURPLE + "(" + RESET;
|
||||
static String rightParanthese = ELECTRIC_PURPLE + ")" + RESET;
|
||||
|
||||
// Locations
|
||||
|
||||
static String[] places = {"Abandoned Docks", "Crystal Caverns", "Lava Pit",
|
||||
"Cyber Alley", "Frozen Tundra", "Haunted Mill", "Sandstorm Gate",
|
||||
"Iron Fortress", "Neon Rooftops", "Rainy Jungle"};
|
||||
|
||||
// Menus
|
||||
|
||||
static String[] ForE = {"", "Fight", "Escape", "Main page"};
|
||||
static String[] ForM = {"", "Fight", "Main page"};
|
||||
static String[] UorEorR = {"", "Equip", "Upgrade", "Repair"};
|
||||
static String[] UorE = {"", "Equip", "Upgrade"}; //______________
|
||||
static String[] U = {"", "Upgrade"};
|
||||
|
||||
// Merchant items
|
||||
|
||||
static Dagger d1 = new Dagger();
|
||||
static Bow b1 = new Bow();
|
||||
static Sword s1 = new Sword();
|
||||
static Spear sp1 = new Spear();
|
||||
static Halberd ha1 = new Halberd();
|
||||
|
||||
static Armlet a1 = new Armlet();
|
||||
static Pauldron p1 = new Pauldron();
|
||||
static Helmet he1 = new Helmet();
|
||||
static Cuirass c1 = new Cuirass();
|
||||
|
||||
static healthPotion hP1 = new healthPotion(1, 15, 10);
|
||||
static healthPotion hP2 = new healthPotion(1, 25, 20);
|
||||
static strengthPotion sP1 = new strengthPotion(1, 20, 10);
|
||||
static strengthPotion sP2 = new strengthPotion(1, 30, 20);
|
||||
static mixedPotion mP1 = new mixedPotion(1, 18, 5, 5);
|
||||
static mixedPotion mP2 = new mixedPotion(1, 23, 10, 10);
|
||||
|
||||
// Lists of Items in merchant
|
||||
|
||||
static Weapon[] W1 = {d1, b1, s1, sp1, ha1};
|
||||
static Armor[] A1 = {a1, p1, he1, c1};
|
||||
static Potion[] Po1 = {hP1, hP2, sP1, sP2, mP1, mP2};
|
||||
|
||||
// Lists of menus
|
||||
|
||||
static String[] sections = {"Items: ", "Weapons", "Armors", "Potions", "Main page"};
|
||||
|
||||
static String[] weapons = {"Weapon | Base damage | Grade | Cost", "Dagger | 10 | 2 | 40",
|
||||
"Bow | 13 | 2 | 50", "Sword | 16 | 2 | 60",
|
||||
"Spear | 18 | 3 | 80", "Halberd | 20 | 3 | 100", "Sections"};
|
||||
|
||||
static String[] armors = {"Armor | Base defense | Base durability | Grade | Cost", "Armlet | 15 | 4 | 2 | 30",
|
||||
"pauldron | 17 | 5 | 2 | 40", "Helmet | 19 | 6 | 3 | 60",
|
||||
"Cuirass | 21 | 7 | 3 | 80", "Sections"};
|
||||
|
||||
static String[] potion = {"Potion | HP/Mana | Cost", "Health potion | 10 | 15",
|
||||
"Health potion | 20 | 25", "Strength potion | 10 | 20", "Strength potion | 20 | 30",
|
||||
"Mixed potion | 5,5 | 18", "Mixed potion | 10,10 | 23", "Sections"};
|
||||
|
||||
|
||||
public static void pressKeyToContinue() {
|
||||
System.out.println();
|
||||
System.out.println("Press any key _c_ to continue. ");
|
||||
Scanner in_ = new Scanner(System.in);
|
||||
String ___ = in_.next();
|
||||
}
|
||||
|
||||
public static void pressKeyToContinue(String str) {
|
||||
System.out.println();
|
||||
System.out.println(str);
|
||||
System.out.println();
|
||||
System.out.println("Press any key _c_ to continue. ");
|
||||
Scanner in_ = new Scanner(System.in);
|
||||
String ___ = in_.next();
|
||||
}
|
||||
|
||||
public static int menuMaker(String[] options, boolean horizontal) {
|
||||
if (horizontal) {
|
||||
System.out.println();
|
||||
for (int i = 0; i < options.length ; i++) {
|
||||
if (i == 0) {
|
||||
System.out.println(options[i]);
|
||||
}
|
||||
else {
|
||||
String ln = " " + ELECTRIC_PURPLE + String.valueOf(i) + "." + RESET + options[i];
|
||||
System.out.print(ln);
|
||||
if (i != options.length - 1) {
|
||||
System.out.print(ELECTRIC_PURPLE + " |" + RESET);
|
||||
} else {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
else {
|
||||
System.out.println();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (i == 0) {
|
||||
System.out.println(options[i]);
|
||||
} else {
|
||||
String ln = ELECTRIC_PURPLE + String.valueOf(i) + "." + RESET + options[i];
|
||||
System.out.println(ln);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
Scanner in1 = new Scanner(System.in);
|
||||
|
||||
int chosenOption;
|
||||
int a = 0;
|
||||
do {
|
||||
a = in1.nextInt();
|
||||
if (!(a > 0 && a < options.length)) {
|
||||
System.out.println("Enter a valid number. ");
|
||||
}
|
||||
} while (!(a > 0 && a < options.length));
|
||||
chosenOption = a;
|
||||
|
||||
return chosenOption;
|
||||
}
|
||||
|
||||
public static void home(Player player) {
|
||||
while (true) {
|
||||
int num8 = menuMaker(sections, false);
|
||||
switch (num8) {
|
||||
case 1: {
|
||||
List<Weapon> wLst = player.getWeaponsList();
|
||||
ArrayList<String> wLstNames = new ArrayList<String>();
|
||||
wLstNames.add("Weapons: ");
|
||||
for (Weapon w : wLst) {
|
||||
wLstNames.add(w.getClass().getSimpleName());
|
||||
}
|
||||
wLstNames.add("sections");
|
||||
String[] wArrayNames = wLstNames.toArray(new String[wLstNames.size()]);
|
||||
while (true) {
|
||||
int num9 = menuMaker(wArrayNames, false);
|
||||
if (num9 == wLst.size() + 1) {
|
||||
break;
|
||||
}
|
||||
if (wLst.get(num9 - 1).getClass() != player.getWeapon().getClass()) {
|
||||
int num10 = menuMaker(UorE, true);
|
||||
if (num10 == 1) {
|
||||
player.setWeapon(wLst.get(num9 - 1));
|
||||
pressKeyToContinue("Equipped with the weapon. ");
|
||||
} else if (num10 == 2) {
|
||||
boolean res = wLst.get(num9 - 1).upgrade(player);
|
||||
|
||||
if (res) {
|
||||
pressKeyToContinue("Upgraded the weapon. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int num10 = menuMaker(U, true);
|
||||
if (num10 == 1) {
|
||||
boolean res = player.getWeapon().upgrade(player);
|
||||
|
||||
if (res) {
|
||||
pressKeyToContinue("Upgraded the weapon. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
List<Armor> aLst = player.getArmorsList();
|
||||
ArrayList<String> aLstNames = new ArrayList<String>();
|
||||
aLstNames.add("Armors: ");
|
||||
for (Armor a : aLst) {
|
||||
aLstNames.add(a.getClass().getSimpleName());
|
||||
}
|
||||
aLstNames.add("sections");
|
||||
String[] aArrayNames = aLstNames.toArray(new String[aLstNames.size()]);
|
||||
while (true) {
|
||||
int num9 = menuMaker(aArrayNames, false);
|
||||
if (num9 == aLst.size() + 1) {
|
||||
break;
|
||||
}
|
||||
if (aLst.get(num9 - 1).getMaxDurability() != aLst.get(num9 - 1).getDurability()) {
|
||||
int num10 = menuMaker(UorEorR, true);
|
||||
if (num10 == 1) {
|
||||
player.setArmor(aLst.get(num9 - 1));
|
||||
pressKeyToContinue("Equipped with the armor. ");
|
||||
} else if (num10 == 2) {
|
||||
boolean res = aLst.get(num9 - 1).upgrade(player);
|
||||
|
||||
if (res) {
|
||||
pressKeyToContinue("Upgraded the armor. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
else if (num10 == 3) {
|
||||
boolean res = aLst.get(num9 - 1).repair(player);
|
||||
|
||||
if (res) {
|
||||
pressKeyToContinue("Repaired the armor. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (aLst.get(num9 - 1).getClass() != player.getArmor().getClass()) {
|
||||
int num10 = menuMaker(UorE, true);
|
||||
if (num10 == 1) {
|
||||
player.setArmor(aLst.get(num9));
|
||||
pressKeyToContinue("Equipped with the armor. ");
|
||||
} else if (num10 == 2) {
|
||||
boolean res = aLst.get(num9 - 1).upgrade(player);
|
||||
|
||||
if (res) {
|
||||
pressKeyToContinue("Upgraded the armor. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int num10 = menuMaker(U, true);
|
||||
if (num10 == 1) {
|
||||
boolean res = player.getArmor().upgrade(player);
|
||||
|
||||
if (res) {
|
||||
pressKeyToContinue("Upgraded the armor. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
List<Potion> pLst = player.getPotionsList();
|
||||
ArrayList<String> pLstNames = new ArrayList<String>();
|
||||
pLstNames.add("Potion | +HP | +Mana | Number");
|
||||
for (Potion p : pLst) {
|
||||
String pData = String.format("%s | %d | %d | %d", p.getClass().getSimpleName(),
|
||||
p.getExtraHP(), p.getExtraMP(), p.getNumber());
|
||||
pLstNames.add(pData);
|
||||
}
|
||||
for (int i = 0; i < pLstNames.size(); i++) {
|
||||
System.out.println(pLstNames.get(i));
|
||||
}
|
||||
pressKeyToContinue();
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void merchant(Player player) {
|
||||
|
||||
while (true) {
|
||||
int num6 = menuMaker(sections, false);
|
||||
switch (num6) {
|
||||
case 1: {
|
||||
while (true) {
|
||||
int num7 = menuMaker(weapons, false);
|
||||
if (num7 != 6) {
|
||||
boolean b = W1[num7 - 1].buy(player);
|
||||
if (b) {
|
||||
pressKeyToContinue("There you go, The weapon is added to your storage. ");
|
||||
} else {
|
||||
pressKeyToContinue("You either already have the weapon, or you don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
while (true) {
|
||||
int num7 = menuMaker(armors, false);
|
||||
if (num7 != 5) {
|
||||
boolean b = A1[num7 - 1].buy(player);
|
||||
if (b) {
|
||||
pressKeyToContinue("There you go, The Armor is added to your storage. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You either already have the armor, or you don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
while (true) {
|
||||
int num7 = menuMaker(potion, false);
|
||||
if (num7 != 7) {
|
||||
boolean res = Po1[num7 - 1].buy(player);
|
||||
if (res) {
|
||||
pressKeyToContinue("There you go, The potion is added to your storage. ");
|
||||
}
|
||||
else {
|
||||
pressKeyToContinue("You don't have enough coins. ");
|
||||
}
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//randomly drops a key from the enemy
|
||||
public static boolean isThereAKey() {
|
||||
Random rand = new Random();
|
||||
boolean res = 0.3 > rand.nextDouble();
|
||||
return res;
|
||||
}
|
||||
|
||||
//is used to randomly make an enemy in a random location
|
||||
public static int randomIndex(int size) {
|
||||
Random rnd = new Random();
|
||||
int num = rnd.nextInt(size);
|
||||
return num;
|
||||
}
|
||||
|
||||
public static boolean playersTurn(Player player, Enemy enemy, boolean usedPotion, ArrayList<String> combatActionsLst) {
|
||||
boolean usedPotionTemp = usedPotion;
|
||||
String eName = YELLOW_VIVID + enemy.getClass().getSimpleName() + RESET;
|
||||
String pName = ELECTRIC_PURPLE + player.getName() + RESET;
|
||||
if ((player.potionsNumber() != 0)&&(!usedPotionTemp)) {
|
||||
combatActionsLst.add("Use Potion " + leftParanthese + YELLOW_VIVID + "0" + RESET + " Mana" + rightParanthese);
|
||||
}
|
||||
|
||||
String[] combatActions = combatActionsLst.toArray(new String[combatActionsLst.size()]);
|
||||
while (true) {
|
||||
int num4 = menuMaker(combatActions, true);
|
||||
switch (num4) {
|
||||
case 1: {
|
||||
player.attack(enemy);
|
||||
|
||||
String no01 = String.format("%s (%s) used light attack! (0 Mana)",
|
||||
pName, player.getClass().getSimpleName());
|
||||
String no02 = String.format("%s has %d/%d HP remaining.",
|
||||
eName, enemy.getHP(), enemy.getMaxHP());
|
||||
String no03 = String.format("%s Mana: %d/%d",
|
||||
pName, player.getMP(), player.getMaxMP());
|
||||
|
||||
System.out.println("You chose to attack the enemy lightly. ");
|
||||
System.out.println();
|
||||
System.out.println(no01);
|
||||
System.out.println(no02);
|
||||
System.out.println(no03);
|
||||
pressKeyToContinue();
|
||||
return usedPotionTemp;
|
||||
}
|
||||
case 2: {
|
||||
boolean b2 = player.heavyAttack(enemy);
|
||||
if (b2) {
|
||||
String no01 = String.format("%s (%s) used heavy attack! (8 Mana)",
|
||||
pName, player.getClass().getSimpleName());
|
||||
String no02 = String.format("%s has %d/%d HP remaining.",
|
||||
eName, enemy.getHP(), enemy.getMaxHP());
|
||||
String no03 = String.format("%s Mana: %d/%d",
|
||||
pName, player.getMP(), player.getMaxMP());
|
||||
|
||||
System.out.println("You chose to attack the enemy heavily. ");
|
||||
System.out.println();
|
||||
System.out.println(no01);
|
||||
System.out.println(no02);
|
||||
System.out.println(no03);
|
||||
pressKeyToContinue();
|
||||
return usedPotionTemp;
|
||||
} else {
|
||||
pressKeyToContinue("You don't have enough Mana. ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (!(enemy instanceof Dragon)) {
|
||||
boolean b3 = player.defend(enemy);
|
||||
if (b3) {
|
||||
String no01 = String.format("%s (%s) used defending! (6 Mana)",
|
||||
pName, player.getClass().getSimpleName());
|
||||
String no02 = String.format("%s Mana: %d/%d",
|
||||
pName, player.getMP(), player.getMaxMP());
|
||||
|
||||
System.out.println("You chose to defend yourself. ");
|
||||
System.out.println();
|
||||
System.out.println(no01);
|
||||
System.out.println(no02);
|
||||
pressKeyToContinue();
|
||||
return usedPotionTemp;
|
||||
} else {
|
||||
pressKeyToContinue("You don't have enough Mana. ");
|
||||
}
|
||||
} else {
|
||||
pressKeyToContinue("Useless against the dragon. ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (player.getMP() >= 12) {
|
||||
player.spendMP(12);
|
||||
player.heal(enemy, 10);
|
||||
|
||||
String no01 = String.format("%s (%s) used healing! (12 Mana)",
|
||||
pName, player.getClass().getSimpleName());
|
||||
String no02 = String.format("%s took +10 HP", pName);
|
||||
String no03 = String.format("%s has %d HP now.", pName, player.getHP());
|
||||
String no04 = String.format("%s Mana: %d/%d",
|
||||
pName, player.getMP(), player.getMaxMP());
|
||||
|
||||
System.out.println("You chose to heal yourself. ");
|
||||
System.out.println();
|
||||
System.out.println(no01);
|
||||
System.out.println(no03);
|
||||
System.out.println(no02);
|
||||
System.out.println(no04);
|
||||
pressKeyToContinue();
|
||||
return usedPotionTemp;
|
||||
} else {
|
||||
pressKeyToContinue("You don't have enough Mana. ");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
boolean b5 = player.specialAbility(player, enemy);
|
||||
if (b5) {
|
||||
String specialAbility;
|
||||
if (player instanceof Knight) { specialAbility = "Shield Bash"; }
|
||||
else if (player instanceof Assassin) { specialAbility= "Turning Invisible"; }
|
||||
else { specialAbility = "Spell Casting"; }
|
||||
|
||||
String no01 = String.format("%s (%s) used %s! (15 Mana)",
|
||||
pName, player.getClass().getSimpleName(), specialAbility);
|
||||
String no02 = String.format("%s has %d/%d HP remaining.",
|
||||
eName, enemy.getHP(), enemy.getMaxHP());
|
||||
String no03 = String.format("%s Mana: %d/%d",
|
||||
pName, player.getMP(), player.getMaxMP());
|
||||
|
||||
System.out.println("You chose to use your special ability. ");
|
||||
System.out.println();
|
||||
System.out.println(no01);
|
||||
System.out.println(no02);
|
||||
System.out.println(no03);
|
||||
pressKeyToContinue();
|
||||
return usedPotionTemp;
|
||||
} else {
|
||||
pressKeyToContinue("You don't have enough Mana. ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if (player.getPotionsList() == null) {
|
||||
pressKeyToContinue("You have no potions. ");
|
||||
}
|
||||
else {
|
||||
ArrayList<String> potionsMenuLst = new ArrayList<String>();
|
||||
potionsMenuLst.add("Choose a potion: ");
|
||||
for (Potion e : player.getPotionsList()) {
|
||||
String potionName = e.getClass().getSimpleName();
|
||||
int extraHP = e.getExtraHP();
|
||||
int extraMP = e.getExtraMP();
|
||||
int number = e.getNumber();
|
||||
|
||||
String eData = String.format("%s +%d HP +%d Mana (%d)",
|
||||
potionName, extraHP, extraMP, number);
|
||||
potionsMenuLst.add(eData);
|
||||
}
|
||||
|
||||
String[] potionsMenu = potionsMenuLst.toArray(new String[potionsMenuLst.size()]);
|
||||
int num5 = menuMaker(potionsMenu, false);
|
||||
Potion p = player.getPotionsList().get(num5 - 1);
|
||||
p.consume(enemy, player);
|
||||
int n = p.getNumber();
|
||||
if (n <= 0) {
|
||||
player.removePotion(p);
|
||||
}
|
||||
|
||||
usedPotionTemp = true;
|
||||
combatActionsLst.removeLast();
|
||||
|
||||
String no01 = String.format("%s (%s) used a potion! (0 Mana)",
|
||||
pName, player.getClass().getSimpleName());
|
||||
String no04 = String.format("%s Mana: %d/%d HP: %d/%d",
|
||||
pName, player.getMP(), player.getMaxMP(), player.getHP(), player.getMaxHP());
|
||||
|
||||
System.out.println();
|
||||
System.out.println(no01);
|
||||
System.out.println(no04);
|
||||
pressKeyToContinue();
|
||||
|
||||
return usedPotionTemp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void fight(Player player, Enemy enemy) {
|
||||
Scanner in11 = new Scanner(System.in);
|
||||
|
||||
boolean hasntResurrectedBefore = true;
|
||||
|
||||
String eName = YELLOW_VIVID + enemy.getClass().getSimpleName() + RESET;
|
||||
String pName = ELECTRIC_PURPLE + player.getName() + RESET;
|
||||
|
||||
ArrayList<String> combatActionsLst = new ArrayList<String>();
|
||||
combatActionsLst.add("Your turn: ");
|
||||
combatActionsLst.add("Light attack " + leftParanthese + YELLOW_VIVID + "0" + RESET + " Mana" + rightParanthese);
|
||||
combatActionsLst.add("Heavy Attack " + leftParanthese + YELLOW_VIVID + "8" + RESET + " Mana" + rightParanthese);
|
||||
combatActionsLst.add("Defend " + leftParanthese + YELLOW_VIVID + "6" + RESET + " Mana" + rightParanthese);
|
||||
combatActionsLst.add("Heal " + leftParanthese + YELLOW_VIVID + "12" + RESET + " Mana" + rightParanthese);
|
||||
if (player instanceof Knight) { combatActionsLst.add("Shield Bash " + leftParanthese + YELLOW_VIVID + "15" + RESET + " Mana" + rightParanthese); }
|
||||
else if (player instanceof Assassin) { combatActionsLst.add("Turn invisible " + leftParanthese + YELLOW_VIVID + "15" + RESET + " Mana"+ rightParanthese); }
|
||||
else if (player instanceof Wizard) { combatActionsLst.add("Cast a spell " + leftParanthese + YELLOW_VIVID + "15" + RESET + " Mana" + rightParanthese); }
|
||||
|
||||
boolean usedPotion = false;
|
||||
|
||||
while (enemy.isAlive() && player.isAlive()) {
|
||||
|
||||
boolean bbb = playersTurn(player, enemy, usedPotion, combatActionsLst);
|
||||
|
||||
usedPotion = bbb;
|
||||
|
||||
if (enemy.isAlive()) {
|
||||
enemy.attack(player);
|
||||
|
||||
String no0 = String.format("%s's turn: ", eName);
|
||||
|
||||
String no6 = String.format("%s has %d/%d HP remaining.",
|
||||
pName, player.getHP(), player.getMaxHP());
|
||||
|
||||
System.out.println();
|
||||
System.out.println(no0);
|
||||
if (!(enemy.isStunned())) {
|
||||
if (enemy instanceof Goblin) {
|
||||
String ability1 = "Critical strike";
|
||||
String ability2 = "Critical hit";
|
||||
int damage3 = enemy.getWeapon().getDamage() + 5;
|
||||
|
||||
String no1 = String.format("%s used %s!", eName, ability1);
|
||||
String no2 = String.format("%s! %s took %d damage!", ability2, pName, damage3);
|
||||
|
||||
System.out.println(no1);
|
||||
System.out.println(no2);
|
||||
}
|
||||
else if (enemy instanceof Skeleton) {
|
||||
String ability1 = "Solid strike";
|
||||
String ability2 = "Solid hit";
|
||||
int damage3 = enemy.getWeapon().getDamage();
|
||||
String ability4 = "resurrection";
|
||||
|
||||
String no1 = String.format("%s used %s!", eName, ability1);
|
||||
String no2 = String.format("%s! %s took %d damage!", ability2, pName, damage3);
|
||||
|
||||
String no3 = String.format("%s used %s ability!", eName, ability4);
|
||||
String no4 = String.format("%s took some HP back!", eName);
|
||||
String no5 = String.format("%s has %d HP now.", eName, enemy.getHP());
|
||||
|
||||
System.out.println(no1);
|
||||
System.out.println(no2);
|
||||
if (enemy.getResurrectionStatus() && hasntResurrectedBefore) {
|
||||
System.out.println(no3);
|
||||
System.out.println(no4);
|
||||
System.out.println(no5);
|
||||
hasntResurrectedBefore = false;
|
||||
}
|
||||
}
|
||||
else if (enemy instanceof Vampire) {
|
||||
String ability1 = "Solid strike";
|
||||
String ability2 = "Solid hit";
|
||||
int damage3 = enemy.getWeapon().getDamage();
|
||||
String ability4 = "life_steal";
|
||||
|
||||
String no1 = String.format("%s used %s!", eName, ability1);
|
||||
String no2 = String.format("%s! %s took %d damage!", ability2, pName, damage3);
|
||||
|
||||
String no3 = String.format("%s used %s ability!", eName, ability4);
|
||||
String no4 = String.format("%s took some HP back!", eName);
|
||||
String no5 = String.format("%s has %d HP now.", eName, enemy.getHP());
|
||||
|
||||
System.out.println(no1);
|
||||
System.out.println(no2);
|
||||
System.out.println(no3);
|
||||
System.out.println(no4);
|
||||
System.out.println(no5);
|
||||
}
|
||||
else {
|
||||
String ability1 = "Fiery breath";
|
||||
String ability2 = "Severe injury";
|
||||
int damage3 = enemy.getDragonDamage();
|
||||
|
||||
String no1 = String.format("%s used %s!", eName, ability1);
|
||||
String no2 = String.format("%s! %s took %d damage!", ability2, pName, damage3);
|
||||
|
||||
System.out.println(no1);
|
||||
System.out.println(no2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println(eName + " is stunned!");
|
||||
enemy.toBeStunned(false);
|
||||
}
|
||||
System.out.println(no6);
|
||||
System.out.println();
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
System.out.println();
|
||||
System.out.println( ELECTRIC_PURPLE + "~" + RESET + YELLOW_VIVID + " Victory " + RESET + ELECTRIC_PURPLE + "~" + RESET);
|
||||
if (enemy instanceof Dragon) {
|
||||
System.out.println("Congratulations! You have defeated the dragon. ");
|
||||
System.out.println();
|
||||
System.out.println("Press key _c_ to go to main page. ");
|
||||
String __ = in11.next();
|
||||
System.out.println();
|
||||
}
|
||||
else {
|
||||
System.out.println("+" + enemy.getXpPrize() + " xp");
|
||||
System.out.println("+" + enemy.getCoinPrize() + " coins");
|
||||
player.victory(enemy);
|
||||
|
||||
if (!player.keyStatus(enemy)) {
|
||||
if (isThereAKey()) {
|
||||
player.grabTheKey(enemy);
|
||||
String grabTheKey = String.format("You've just got the %ss' key. ", enemy.getClass().getSimpleName());
|
||||
System.out.println();
|
||||
System.out.println(grabTheKey);
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Press _c_ key to go to main page. ");
|
||||
String __ = in11.next();
|
||||
System.out.println();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isAlive()) {
|
||||
System.out.println();
|
||||
System.out.println("Game over");
|
||||
System.out.println("You have to start from scratch. ");
|
||||
player.failure();
|
||||
System.out.println();
|
||||
System.out.println("Press _c_ key to go to main page. ");
|
||||
String __ = in11.next();
|
||||
System.out.println();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void fightTheDragon(Player player) {
|
||||
Dragon dragon = new Dragon();
|
||||
Location finalLoc = new Location("The Castle", dragon);
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Location: " + finalLoc.getName() + " Enemy: " + finalLoc.getEnemy().getClass().getSimpleName());
|
||||
System.out.println();
|
||||
|
||||
int num3 = menuMaker(ForM, true);
|
||||
switch (num3) {
|
||||
case 1: {
|
||||
System.out.println();
|
||||
System.out.println("You chose to fight the dragon. ");
|
||||
System.out.println();
|
||||
fight(player, dragon);
|
||||
return;
|
||||
}
|
||||
case 2:
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void play(Player player) {
|
||||
|
||||
while (true) {
|
||||
int[] hps = {40, 45, 50};
|
||||
int rnd1 = randomIndex(3);
|
||||
int EHP = hps[rnd1];
|
||||
|
||||
Weapon EWeapon;
|
||||
int rnd2 = randomIndex(5);
|
||||
switch (rnd2) {
|
||||
case 0: {
|
||||
EWeapon = new Sword();
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
EWeapon = new Bow();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
EWeapon = new Spear();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
EWeapon = new Halberd();
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
EWeapon = new Dagger();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
EWeapon = new Sword();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Enemy enemy;
|
||||
int rnd3 = randomIndex(3);
|
||||
switch (rnd3) {
|
||||
case 0: {
|
||||
enemy = new Goblin(EHP, EWeapon);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
enemy = new Skeleton(EHP, EWeapon);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
enemy = new Vampire(EHP, EWeapon);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
enemy = new Goblin(EHP, EWeapon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int rnd4 = randomIndex(places.length);
|
||||
String place = places[rnd4];
|
||||
|
||||
Location loc = new Location(place, enemy);
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Location: " + loc.getName() + " Enemy: " + loc.getEnemy().getClass().getSimpleName());
|
||||
System.out.println();
|
||||
|
||||
int num3 = menuMaker(ForE, true);
|
||||
switch (num3) {
|
||||
case 1: {
|
||||
String intro1 = String.format("[%s - %d/%d HP | %d/%d Mana]",
|
||||
player.getName(), player.getHP(), player.getMaxHP(),
|
||||
player.getMP(), player.getMaxMP());
|
||||
String intro2 = String.format("[%s - %d/%d HP]",
|
||||
enemy.getClass().getSimpleName(), enemy.getHP(), enemy.getMaxHP());
|
||||
|
||||
System.out.println();
|
||||
System.out.println("You chose to fight ");
|
||||
System.out.println();
|
||||
System.out.println(intro1);
|
||||
System.out.println(intro2);
|
||||
System.out.println();
|
||||
System.out.println("---");
|
||||
System.out.println();
|
||||
|
||||
fight(player, enemy);
|
||||
return;
|
||||
}
|
||||
case 2:
|
||||
break;
|
||||
case 3: {
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void mainMenu(Player player) {
|
||||
|
||||
ArrayList<String> MainMenuLst = new ArrayList<>();
|
||||
MainMenuLst.add("");
|
||||
MainMenuLst.add("Home");
|
||||
MainMenuLst.add("Merchant");
|
||||
MainMenuLst.add("Play");
|
||||
if (player.threeKeys()) {
|
||||
MainMenuLst.add("Fight THe Dragon");
|
||||
}
|
||||
|
||||
String[] MainMenu = MainMenuLst.toArray(new String[MainMenuLst.size()]);
|
||||
while (true) {
|
||||
System.out.println("Level " + ELECTRIC_PURPLE + player.getLevel() + RESET);
|
||||
System.out.println("XP " + ELECTRIC_PURPLE + player.getXP() + RESET + "/" + ELECTRIC_PURPLE + player.getMaxXP() + RESET);
|
||||
System.out.println("Coins: " + ELECTRIC_PURPLE + player.getCoins() + RESET);
|
||||
int num2 = menuMaker(MainMenu, true);
|
||||
switch (num2) {
|
||||
case 1: {
|
||||
home(player);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
merchant(player);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
play(player);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
fightTheDragon(player);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
System.out.println("Enter a valid number. ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Scanner in2 = new Scanner(System.in);
|
||||
|
||||
System.out.println(ELECTRIC_PURPLE + "~" + RESET + " KNIGHT GAME " + ELECTRIC_PURPLE + "~" + RESET);
|
||||
System.out.println();
|
||||
System.out.println("Enter your name: ");
|
||||
String name = in2.nextLine();
|
||||
String[] characters = {"Choose a character:", "Knight", "Assassin", "Wizard"};
|
||||
int num1 = menuMaker(characters, true);
|
||||
pressKeyToContinue("You have chosen to be a(an) " + characters[num1]);
|
||||
|
||||
Player player;
|
||||
Armlet armlet = new Armlet();
|
||||
switch (num1) {
|
||||
case 1: {
|
||||
Sword PSword = new Sword();
|
||||
player = new Knight(name, PSword, armlet);
|
||||
mainMenu(player);
|
||||
}
|
||||
case 2: {
|
||||
Dagger PDagger = new Dagger();
|
||||
player = new Assassin(name, PDagger, armlet);
|
||||
mainMenu(player);
|
||||
}
|
||||
case 3: {
|
||||
Bow PBow = new Bow();
|
||||
player = new Wizard(name, PBow, armlet);
|
||||
mainMenu(player);
|
||||
}
|
||||
default: {
|
||||
System.out.println("Enter a valid number. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,21 +1,12 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
|
||||
void attack(Entity target);
|
||||
|
||||
void defend();
|
||||
|
||||
void heal(int health);
|
||||
|
||||
void fillMana(int mana);
|
||||
|
||||
void takeDamage(int damage);
|
||||
|
||||
int getMaxHP();
|
||||
int getHP();
|
||||
|
||||
int getMaxMP();
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
boolean isAlive();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Dragon extends Enemy{
|
||||
|
||||
private static int hp = 100;
|
||||
|
||||
public Dragon() {
|
||||
super(hp, null, 0, 0);
|
||||
}
|
||||
|
||||
//attacks the player while dealing random damages
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
int[] Damage = {20, 23, 26, 29};
|
||||
Random rand = new Random();
|
||||
int randNum = rand.nextInt(Damage.length);
|
||||
setDragonDamage(Damage[randNum]);
|
||||
//checks if the player has stunned them
|
||||
if (!isStunned()) {
|
||||
target.takeDamage(getDragonDamage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1,34 +1,75 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Enemy {
|
||||
Weapon weapon;
|
||||
public abstract class Enemy implements Entity {
|
||||
|
||||
private int dragonDamage;
|
||||
private boolean resurrection = false;
|
||||
|
||||
private Weapon weapon;
|
||||
private int hp;
|
||||
private int mp;
|
||||
private int maxHP;
|
||||
private boolean isStunned = false;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
private int xpPrize;
|
||||
private int coinPrize;
|
||||
|
||||
public Enemy(int maxHP, Weapon weapon, int xpPrize, int coinPrize) {
|
||||
this.maxHP = maxHP;
|
||||
this.hp = maxHP;
|
||||
this.weapon = weapon;
|
||||
this.xpPrize = xpPrize;
|
||||
this.coinPrize = coinPrize;
|
||||
}
|
||||
|
||||
public void toBeStunned(boolean t) {
|
||||
isStunned = t;
|
||||
}
|
||||
|
||||
public boolean isStunned() {
|
||||
return isStunned;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
if (hp <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHP() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
public int getMaxHP() { return maxHP; }
|
||||
|
||||
public void addHP(int HP) {
|
||||
hp += HP;
|
||||
}
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public int getXpPrize() { return xpPrize; }
|
||||
|
||||
public int getCoinPrize() { return coinPrize; }
|
||||
|
||||
public int getDragonDamage() { return dragonDamage; }
|
||||
|
||||
public void setDragonDamage(int d) { dragonDamage = d; }
|
||||
|
||||
public boolean getResurrectionStatus() { return resurrection; }
|
||||
|
||||
public void setResurrectionStatus(boolean t) { resurrection = t; }
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Goblin extends Enemy{
|
||||
|
||||
public Goblin(int hp, Weapon weapon) {
|
||||
super(hp - 10, weapon, 15, 10);
|
||||
}
|
||||
|
||||
//attacks the player while dealing higher damage than its weapon has
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
//checks if the player has stunned them
|
||||
if (!(isStunned())) {
|
||||
target.takeDamage(getWeapon().getDamage() + 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,6 +1,35 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Skeleton {
|
||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Skeleton extends Enemy{
|
||||
|
||||
private int initialHP;
|
||||
|
||||
public Skeleton(int hp, Weapon weapon) {
|
||||
this.initialHP = hp;
|
||||
super(hp, weapon, 20, 12);
|
||||
}
|
||||
|
||||
//attacks the player and resurrects (increases HP) once per battle
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
//checks if the player has stunned them
|
||||
if (!isStunned()) {
|
||||
if ((getHP() <= 10) && !getResurrectionStatus()) {
|
||||
int addedHP;
|
||||
|
||||
if (initialHP % 2 == 0) { addedHP = initialHP / 2; }
|
||||
else { addedHP = (initialHP - 1) / 2; }
|
||||
|
||||
addHP(addedHP);
|
||||
|
||||
setResurrectionStatus(true);
|
||||
}
|
||||
target.takeDamage(getWeapon().getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
import javax.xml.transform.stax.StAXResult;
|
||||
|
||||
public class Vampire extends Enemy{
|
||||
private int addadHP;
|
||||
|
||||
public Vampire(int hp, Weapon weapon) {
|
||||
if (weapon.getDamage() % 3 == 0){ this.addadHP = weapon.getDamage() / 3; }
|
||||
else if (weapon.getDamage() % 3 == 1){ this.addadHP = (weapon.getDamage() - 1) / 3; }
|
||||
else { this.addadHP = (weapon.getDamage() - 2) / 3; }
|
||||
super(hp, weapon, 25, 14);
|
||||
}
|
||||
|
||||
//attacks the player and increases HP as much as a portion (almost 1/3) of the damage it deals
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
//checks if the player has stunned them
|
||||
if (!isStunned()) {
|
||||
target.takeDamage(getWeapon().getDamage());
|
||||
addHP(addadHP);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Assassin extends Player{
|
||||
public Assassin(String name, Weapon weapon, Armor armor) {
|
||||
super(name, 40, 50, weapon, armor, 40, 50);
|
||||
}
|
||||
|
||||
//turns invisible and saves an attack for the next turn
|
||||
@Override
|
||||
public boolean specialAbility(Player player, Enemy target) {
|
||||
//checks if player has enough mana
|
||||
if (player.getMP() >= 15) {
|
||||
spendMP(15);
|
||||
//checks if the former move was to use the special ability
|
||||
if (isCHitOnNextTurn()) {
|
||||
target.takeDamage(player.getWeapon().getDamage() + 5);
|
||||
CHitOnNextTurn(false);
|
||||
}
|
||||
turnInvisible();
|
||||
CHitOnNextTurn(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,6 +1,40 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Knight {
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Knight extends Player{
|
||||
|
||||
public Knight(String name, Weapon weapon, Armor armor) {
|
||||
super(name, 40, 40, weapon, armor, 40, 40);
|
||||
}
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean heavyAttack(Entity target) {
|
||||
if (getMP() >= 8) {
|
||||
spendMP(8);
|
||||
target.takeDamage(weapon.getDamage() + 5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//attacks the enemy and stuns it
|
||||
@Override
|
||||
public boolean specialAbility(Player player, Enemy target) {
|
||||
//checks if player has enough mana
|
||||
if (getMP() >= 15) {
|
||||
spendMP(15);
|
||||
target.toBeStunned(true);
|
||||
target.takeDamage(player.getWeapon().getDamage() + 5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,53 +1,170 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.enemies.Goblin;
|
||||
import org.project.entity.enemies.Skeleton;
|
||||
import org.project.entity.enemies.Vampire;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.potions.Potion;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Player implements Entity{
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
|
||||
private ArrayList<Potion> potions = new ArrayList<Potion>();
|
||||
private ArrayList<Weapon> weapons = new ArrayList<Weapon>();
|
||||
private ArrayList<Armor> armors = new ArrayList<Armor>();
|
||||
|
||||
private int hp;
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
private boolean isDefending;
|
||||
private boolean isInvisible;
|
||||
private boolean CHitOnNextTurn;
|
||||
|
||||
private int coins;
|
||||
|
||||
private int xp;
|
||||
private static int maxXP = 70;
|
||||
private int level;
|
||||
|
||||
private boolean goblinKey;
|
||||
private boolean skeletonKey;
|
||||
private boolean vampireKey;
|
||||
private boolean threeKeys;
|
||||
|
||||
private static int heavyAttackMana = 8;
|
||||
private static int defendMana = 6;
|
||||
private static int healMana = 12;
|
||||
private static int specialAbilityMana = 15;
|
||||
|
||||
public Player(String name, int hp, int mp,
|
||||
Weapon weapon, Armor armor,
|
||||
int maxHP, int maxMP) {
|
||||
this.weapons.add(weapon);
|
||||
this.armors.add(armor);
|
||||
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
|
||||
this.maxMP = maxMP;
|
||||
this.maxHP = maxHP;
|
||||
this.coins = 0;
|
||||
}
|
||||
|
||||
public void earnCoins(int extraCoins) { coins += extraCoins; }
|
||||
|
||||
public void grabTheKey(Enemy enemy) {
|
||||
if (enemy instanceof Goblin) { goblinKey = true; }
|
||||
else if (enemy instanceof Skeleton) { skeletonKey = true; }
|
||||
else if (enemy instanceof Vampire) { vampireKey = true; }
|
||||
|
||||
if (goblinKey && skeletonKey && vampireKey) { threeKeys = true; }
|
||||
}
|
||||
|
||||
public boolean keyStatus(Enemy enemy) {
|
||||
if (enemy instanceof Goblin) { return goblinKey; }
|
||||
else if (enemy instanceof Skeleton) { return skeletonKey; }
|
||||
else if (enemy instanceof Vampire) { return vampireKey; }
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean threeKeys() { return threeKeys; }
|
||||
|
||||
public void levelUp() {
|
||||
maxHP += 10;
|
||||
maxMP += 10;
|
||||
}
|
||||
public void increaseXP(int addedXP) {
|
||||
if (addedXP + xp >= maxXP) {
|
||||
level++;
|
||||
levelUp();
|
||||
xp += addedXP - maxXP;
|
||||
}
|
||||
else {
|
||||
xp += addedXP;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
target.takeDamage(7);
|
||||
if (CHitOnNextTurn) {
|
||||
target.takeDamage(15);
|
||||
CHitOnNextTurn = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
public boolean heavyAttack(Entity target) {
|
||||
if (mp >= 8) {
|
||||
mp -= 8;
|
||||
target.takeDamage(weapon.getDamage());
|
||||
if (CHitOnNextTurn) {
|
||||
target.takeDamage(weapon.getDamage() + 5);
|
||||
CHitOnNextTurn = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public boolean defend(Entity target) {
|
||||
if (mp >= 6) {
|
||||
mp -= 6;
|
||||
if (CHitOnNextTurn) {
|
||||
target.takeDamage(weapon.getDamage() + 5);
|
||||
CHitOnNextTurn = false;
|
||||
}
|
||||
isDefending = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
if (isInvisible) {
|
||||
isInvisible = false;
|
||||
return;
|
||||
}
|
||||
if (isDefending) {
|
||||
if (damage > armor.getDefense()) {
|
||||
hp -= damage - armor.getDefense();
|
||||
armor.decreaseDurability();
|
||||
armor.checkBreak();
|
||||
isDefending = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hp -= damage;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
public void heal(Enemy target, int health) {
|
||||
if (CHitOnNextTurn) {
|
||||
target.takeDamage(weapon.getDamage() + 5);
|
||||
CHitOnNextTurn = false;
|
||||
}
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialAbility(Player player, Enemy target) { return false; }
|
||||
|
||||
public void fillMana(int mana) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
@@ -55,35 +172,108 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
if (hp <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
@Override
|
||||
public int getHP() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
public void victory(Enemy enemy) {
|
||||
increaseXP(enemy.getXpPrize());
|
||||
earnCoins(enemy.getCoinPrize());
|
||||
hp = maxHP;
|
||||
mp = maxMP;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
public void failure() {
|
||||
level = 0;
|
||||
xp = 0;
|
||||
mp = maxMP;
|
||||
hp = maxHP;
|
||||
goblinKey = false;
|
||||
skeletonKey = false;
|
||||
vampireKey = false;
|
||||
threeKeys = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
public boolean pay(int cost) {
|
||||
if (cost <= coins) {
|
||||
coins -= cost;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
public void removePotion(Potion p) { potions.remove(p); }
|
||||
|
||||
public int potionsNumber() { return potions.size(); }
|
||||
|
||||
public boolean addItem(Potion p, int cost) {
|
||||
boolean res = pay(cost);
|
||||
if (res) {
|
||||
potions.add(p);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Armor getArmor() {
|
||||
return armor;
|
||||
public boolean addItem(Weapon w, int cost) {
|
||||
boolean res = pay(cost);
|
||||
if (res) {
|
||||
weapons.add(w);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean addItem(Armor a, int cost) {
|
||||
boolean res = pay(cost);
|
||||
if (res) {
|
||||
armors.add(a);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void setWeapon(Weapon w) { weapon = w; }
|
||||
|
||||
public void setArmor(Armor a) { armor = a; }
|
||||
|
||||
public void spendMP(int MP) { mp -= MP; }
|
||||
|
||||
public String getName() { return name; }
|
||||
|
||||
public int getMaxHP() { return maxHP; }
|
||||
|
||||
public int getMP() { return mp; }
|
||||
|
||||
public int getMaxMP() { return maxMP; }
|
||||
|
||||
public Weapon getWeapon() { return weapon; }
|
||||
|
||||
public Armor getArmor() { return armor; }
|
||||
|
||||
public int getLevel() { return level; }
|
||||
|
||||
public int getXP() { return xp; }
|
||||
|
||||
public int getMaxXP() { return maxXP; }
|
||||
|
||||
public int getCoins() { return coins; }
|
||||
|
||||
public List<Potion> getPotionsList() { return potions; }
|
||||
|
||||
public List<Weapon> getWeaponsList() { return weapons; }
|
||||
|
||||
public List<Armor> getArmorsList() { return armors; }
|
||||
|
||||
public void turnInvisible() { isInvisible = true; }
|
||||
|
||||
public void CHitOnNextTurn(boolean t) { CHitOnNextTurn = t; }
|
||||
|
||||
public boolean isCHitOnNextTurn() { return CHitOnNextTurn; }
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Wizard extends Player{
|
||||
public Wizard(String name, Weapon weapon, Armor armor) {
|
||||
super(name,50, 40, weapon, armor, 50, 40);
|
||||
}
|
||||
|
||||
//attacks the enemy and increases HP
|
||||
@Override
|
||||
public boolean specialAbility(Player player, Enemy target){
|
||||
//checks if player has enough mana
|
||||
if (getMP() >= 15) {
|
||||
spendMP(15);
|
||||
heal(target, 7);
|
||||
target.takeDamage(player.getWeapon().getDamage());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1,11 +1,10 @@
|
||||
package org.project.item;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
public interface Item {
|
||||
void use(Entity target);
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
boolean buy(Player player);
|
||||
|
||||
int getCost();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
public class Armlet extends Armor{
|
||||
public Armlet() {
|
||||
super(15, 4, 30, 2);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,42 +1,86 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Armor {
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.Item;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Armor implements Item {
|
||||
private int defense;
|
||||
private int maxDefense;
|
||||
private int durability;
|
||||
private int maxDurability;
|
||||
|
||||
private boolean isBroke;
|
||||
private static int upgradeCost = 2;
|
||||
private int cost;
|
||||
private int x;
|
||||
|
||||
public Armor(int defense, int durability) {
|
||||
private boolean isBroken;
|
||||
|
||||
public Armor(int defense, int initialDrb, int cost, int x) {
|
||||
this.defense = defense;
|
||||
this.durability = durability;
|
||||
this.durability = initialDrb;
|
||||
this.maxDurability = initialDrb;
|
||||
this.cost = cost;
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buy(Player player) {
|
||||
List<Armor> A = player.getArmorsList();
|
||||
for (Armor a : A) {
|
||||
if (a.getClass() == this.getClass()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean res = player.addItem(this, cost);
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean upgrade(Player player) {
|
||||
boolean res = player.pay(upgradeCost);
|
||||
if (res) {
|
||||
upgradeCost *= x;
|
||||
maxDurability += 1;
|
||||
defense += x;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void checkBreak() {
|
||||
if (durability <= 0) {
|
||||
isBroke = true;
|
||||
isBroken = true;
|
||||
defense = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||
public void repair() {
|
||||
isBroke = false;
|
||||
defense = maxDefense;
|
||||
durability = maxDurability;
|
||||
public boolean repair(Player player) {
|
||||
boolean res = player.pay(maxDurability - durability);
|
||||
if (res) {
|
||||
isBroken = false;
|
||||
durability = maxDurability;
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() { return cost; }
|
||||
|
||||
public int getDefense() {
|
||||
return defense;
|
||||
}
|
||||
|
||||
public int getDurability() {
|
||||
return durability;
|
||||
public int getMaxDurability() {
|
||||
return maxDurability;
|
||||
}
|
||||
|
||||
public int getDurability() { return durability; }
|
||||
|
||||
public void decreaseDurability() { durability --; }
|
||||
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
return isBroken;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
public class Cuirass extends Armor{
|
||||
public Cuirass() {
|
||||
super(21, 7, 80, 3);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
+5
-1
@@ -1,6 +1,10 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
public class Helmet extends Armor {
|
||||
|
||||
public Helmet() {
|
||||
super(19, 6, 60, 3);
|
||||
}
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
public class Pauldron extends Armor {
|
||||
public Pauldron() {
|
||||
super(17, 5, 40, 2);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,55 @@
|
||||
package org.project.item.potions;
|
||||
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Potion implements Item {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
|
||||
private int number;
|
||||
private int cost;
|
||||
private int extraHP;
|
||||
private int extraMP;
|
||||
|
||||
private boolean isBought;
|
||||
|
||||
public Potion(int number, int cost, int extraHP, int extraMP) {
|
||||
this.number = number;
|
||||
this.cost = cost;
|
||||
this.extraHP = extraHP;
|
||||
this.extraMP = extraMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buy(Player player) {
|
||||
boolean res;
|
||||
if (isBought) {
|
||||
number++;
|
||||
res = player.pay(cost);
|
||||
}
|
||||
else {
|
||||
isBought = true;
|
||||
res = player.addItem(this, cost);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void consume(Enemy target, Player player) {}
|
||||
|
||||
public void decreaseNum(int num){
|
||||
number -= num;
|
||||
}
|
||||
|
||||
public int getNumber() { return number; }
|
||||
|
||||
@Override
|
||||
public int getCost() { return cost; }
|
||||
|
||||
public int getExtraHP() { return extraHP; }
|
||||
|
||||
public int getExtraMP() { return extraMP; }
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
package org.project.item.potions;
|
||||
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
public class healthPotion extends Potion {
|
||||
public healthPotion(int number, int cost, int extraHP) {
|
||||
super(number, cost, extraHP, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(Enemy target, Player player) {
|
||||
if (player.isCHitOnNextTurn()) {
|
||||
target.takeDamage(player.getWeapon().getDamage() + 5);
|
||||
player.CHitOnNextTurn(false);
|
||||
}
|
||||
player.heal(target, getExtraHP());
|
||||
decreaseNum(1);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
package org.project.item.potions;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
public class mixedPotion extends Potion{
|
||||
|
||||
public mixedPotion(int number, int cost, int extraHP, int extraMP) {
|
||||
super(number, cost, extraHP, extraMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(Enemy target, Player player) {
|
||||
if (player.isCHitOnNextTurn()) {
|
||||
target.takeDamage(player.getWeapon().getDamage() + 5);
|
||||
player.CHitOnNextTurn(false);
|
||||
}
|
||||
player.fillMana(getExtraMP());
|
||||
player.heal(target, getExtraHP());
|
||||
decreaseNum(1);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
package org.project.item.potions;
|
||||
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
import java.security.DrbgParameters;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class strengthPotion extends Potion {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||
*/
|
||||
|
||||
// TODO: UPDATE USE METHOD
|
||||
//@Override
|
||||
//public void use(Player target) {
|
||||
// target.heal(target.getMaxHP() / 10);
|
||||
//}
|
||||
|
||||
|
||||
public strengthPotion(int number, int cost, int extraMP) {
|
||||
super(number, cost, 0, extraMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(Enemy target, Player player) {
|
||||
if (player.isCHitOnNextTurn()) {
|
||||
target.takeDamage(player.getWeapon().getDamage() + 5);
|
||||
player.CHitOnNextTurn(false);
|
||||
}
|
||||
player.fillMana(getExtraMP());
|
||||
decreaseNum(1);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Bow extends Weapon {
|
||||
public Bow() {
|
||||
super(13, 50, 2);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Dagger extends Weapon {
|
||||
public Dagger() {
|
||||
super(10, 40, 2);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Halberd extends Weapon {
|
||||
public Halberd() {
|
||||
super(20, 100, 3);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Spear extends Weapon {
|
||||
public Spear() {
|
||||
super(18, 80, 3);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,26 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
int abilityCharge;
|
||||
|
||||
public class Sword extends Weapon {
|
||||
public Sword() {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
target.takeDamage(getDamage());
|
||||
}
|
||||
super(16, 60, 2);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,35 +1,51 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Weapon {
|
||||
import java.lang.foreign.PaddingLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Weapon implements Item {
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
private static int upgradeCost = 2;
|
||||
private int cost;
|
||||
private int x;
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
public Weapon(int damage, int cost, int x) {
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
this.cost = cost;
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
target.takeDamage(damage);
|
||||
public boolean buy(Player player) {
|
||||
List<Weapon> W = player.getWeaponsList();
|
||||
for (Weapon w : W) {
|
||||
if (w.getClass() == this.getClass()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean res = player.addItem(this, cost);
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean upgrade(Player player) {
|
||||
boolean res = player.pay(upgradeCost);
|
||||
if (res) {
|
||||
upgradeCost *= x;
|
||||
damage += x;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public int getManaCost() {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
@Override
|
||||
public int getCost() { return cost; }
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,24 +5,21 @@ import org.project.entity.enemies.Enemy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Location {
|
||||
|
||||
private String name;
|
||||
|
||||
private ArrayList<Enemy> enemies;
|
||||
private Enemy enemy;
|
||||
|
||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||
this.locations = locations;
|
||||
this.enemies = enemies;
|
||||
public Location(String name, Enemy enemy) {
|
||||
this.name = name;
|
||||
this.enemy = enemy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<Location> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public ArrayList<Enemy> getEnemies() {
|
||||
return enemies;
|
||||
public Enemy getEnemy() {
|
||||
return enemy;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user