implement Java-Knight gameplay
This commit is contained in:
@@ -0,0 +1,439 @@
|
||||
import org.project.Colors;
|
||||
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.AssassineArmor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.armors.WizardArmor;
|
||||
import org.project.item.consumables.*;
|
||||
import org.project.item.weapons.AssassineWeapon;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.WizardWeapon;
|
||||
import org.project.location.Location;
|
||||
|
||||
import javax.swing.plaf.metal.MetalRootPaneUI;
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
||||
List<Location> locations = new ArrayList<>();
|
||||
Location loc1 = new Location("Darkmire Hollow");
|
||||
loc1.addEnemy(new Goblin());
|
||||
|
||||
Location loc2 = new Location("Grave of the Fallen");
|
||||
loc2.addEnemy(new Skeleton());
|
||||
Location loc3 = new Location("Goblin Warrens");
|
||||
loc3.addEnemy(new Goblin());
|
||||
|
||||
Location loc4 = new Location("Vampire's Embrace");
|
||||
loc4.addEnemy(new Vampire());
|
||||
|
||||
|
||||
Location loc5 = new Location("Blightmoor Cave");
|
||||
loc5.addEnemy(new Goblin());
|
||||
loc5.addEnemy(new Skeleton());
|
||||
|
||||
Location loc6 = new Location("Crypt of Bleeding Bones");
|
||||
loc6.addEnemy(new Vampire());
|
||||
loc6.addEnemy(new Skeleton());
|
||||
|
||||
Location loc7 = new Location("Cackling Caverns");
|
||||
loc7.addEnemy(new Goblin());
|
||||
loc7.addEnemy(new Goblin());
|
||||
loc7.addEnemy(new Goblin());
|
||||
|
||||
Collections.addAll(locations, loc1, loc2, loc3, loc4, loc5, loc6, loc7);
|
||||
List<Consumable> allItems = new ArrayList<>();
|
||||
Collections.addAll(allItems, new CursedDagger(), new ElixirOfLife(), new GoblinGland(), new HealthPotion(), new HolyWater(), new ManaPotion());
|
||||
|
||||
// TODO: IMPLEMENT GAMEPLAY
|
||||
System.out.print(Colors.RESET + "enter your name: ");
|
||||
Scanner in = new Scanner(System.in);
|
||||
String name = in.next();
|
||||
System.out.println("Choos your character: ");
|
||||
System.out.println("1.Knight: ");
|
||||
System.out.println("2.Assassine");
|
||||
System.out.println("3.Wizard");
|
||||
Player player = null;
|
||||
int input2 = in.nextInt();
|
||||
while (input2 > 3 || input2 < 1)
|
||||
{
|
||||
System.out.println("invalid input!");
|
||||
System.out.println("Choos your character: ");
|
||||
System.out.println("1.Knight");
|
||||
System.out.println("2.Assassine");
|
||||
System.out.println("3.Wizard");
|
||||
input2 = in.nextInt();
|
||||
}
|
||||
switch (input2)
|
||||
{
|
||||
case (1):
|
||||
{
|
||||
player = new Knight(name, new Sword(), new KnightArmor());
|
||||
break;
|
||||
}
|
||||
case(2):
|
||||
{
|
||||
player = new Assassin(name, new AssassineWeapon(), new AssassineArmor());
|
||||
break;
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
player = new Wizard(name, new WizardWeapon(), new WizardArmor());
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.showInf();
|
||||
System.out.println(Colors.YELLO + "WELCOME\n" + Colors.RESET);
|
||||
|
||||
boolean running = true;
|
||||
while (running)
|
||||
{
|
||||
Location randomLoc = locations.get(new Random().nextInt(7));
|
||||
// while (randomLoc.isDiscovered())
|
||||
// {
|
||||
// randomLoc = locations.get(new Random().nextInt());
|
||||
// }
|
||||
System.out.println(randomLoc);
|
||||
System.out.println("1.Fight the enemies");
|
||||
System.out.println("2.Move to another location");
|
||||
System.out.println("3.Visit Merchant");
|
||||
|
||||
boolean hasKeys = player.getGoblinKey() && player.getSkeletonKey() && player.getVampireKey();
|
||||
if(hasKeys)
|
||||
{
|
||||
System.out.println("4.Go to the Castle to fight the Dragon");
|
||||
}
|
||||
|
||||
|
||||
int input = in.nextInt();
|
||||
while((input > 4 || input < 1))
|
||||
{
|
||||
System.out.println("input is invalid!");
|
||||
System.out.println(randomLoc);
|
||||
System.out.println("1.Fight the enemies");
|
||||
System.out.println("2.Move to another location");
|
||||
System.out.println("3.Visit Merchant");
|
||||
|
||||
if(hasKeys)
|
||||
{
|
||||
System.out.println("4.Go to the Castle to fight the Dragon");
|
||||
}
|
||||
in.next();
|
||||
input = in.nextInt();
|
||||
}
|
||||
switch (input)
|
||||
{
|
||||
case (1):
|
||||
{
|
||||
if(randomLoc.getEnemies().size() > 1)
|
||||
{
|
||||
System.out.println("You have to fight with " + randomLoc.getEnemies().size() + " enemies!");
|
||||
System.out.println("How Brave you are!");
|
||||
System.out.println(Colors.YELLO + "Have luck" + Colors.RESET);
|
||||
}
|
||||
//or && running?
|
||||
while (randomLoc.checkLives() && player.isAlive())
|
||||
{
|
||||
for (int i = 0; i < randomLoc.getEnemies().size(); i++) {
|
||||
Enemy currentEnemy = randomLoc.getEnemies().get(i);
|
||||
System.out.println("You know have to fight with " + currentEnemy.getClass().getSimpleName());
|
||||
if (combat(player, currentEnemy))
|
||||
{
|
||||
// randomLoc.defeatEnemy(currentEnemy);
|
||||
if (player.needLevelUp()) {
|
||||
player.levelUp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(player.isAlive())
|
||||
{
|
||||
player.setHp(player.getMaxHP());
|
||||
player.fillMana(player.getMaxMP());
|
||||
player.getArmor().repair();
|
||||
randomLoc.resetLives();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(2):
|
||||
{
|
||||
break;
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
System.out.println(Colors.WELCOME + "Welcome, traveler!" + Colors.RESET);
|
||||
int input4;
|
||||
do
|
||||
{
|
||||
for (int i = 0; i < allItems.size(); i++) {
|
||||
System.out.println((i + 1) + "." + allItems.get(i));
|
||||
}
|
||||
System.out.println(Colors.ORANGE + "[" + Colors.RESET + "Your coins: " + Colors.COIN + player.getCoin() + Colors.ORANGE + "]" + Colors.RESET);
|
||||
System.out.println("Which one do you want to buy?");
|
||||
System.out.println("enter your choice(write 0 to back): ");
|
||||
input4 = in.nextInt();
|
||||
if(input4 < 0 || input4 > allItems.size())
|
||||
{
|
||||
System.out.println("invalid input!");
|
||||
continue;
|
||||
}
|
||||
switch (input4) {
|
||||
case (0): {
|
||||
break;
|
||||
}
|
||||
case (1): {
|
||||
if (allItems.get(0).getValue() <= player.getCoin()) {
|
||||
player.addItem(allItems.get(0));
|
||||
player.setCoin(player.getCoin() - allItems.get(0).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
case (2): {
|
||||
if (allItems.get(1).getValue() <= player.getCoin()) {
|
||||
player.addItem(allItems.get(1));
|
||||
player.setCoin(player.getCoin() - allItems.get(1).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
case (3): {
|
||||
if (allItems.get(2).getValue() <= player.getCoin()) {
|
||||
player.addItem(allItems.get(2));
|
||||
player.setCoin(player.getCoin() - allItems.get(2).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
case (4): {
|
||||
if (allItems.get(3).getValue() <= player.getCoin()) {
|
||||
player.addItem(allItems.get(3));
|
||||
player.setCoin(player.getCoin() - allItems.get(3).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
case (5): {
|
||||
if (allItems.get(4).getValue() <= player.getCoin()) {
|
||||
player.addItem(allItems.get(4));
|
||||
player.setCoin(player.getCoin() - allItems.get(4).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
case (6): {
|
||||
if (allItems.get(5).getValue() <= player.getCoin()) {
|
||||
player.addItem(allItems.get(5));
|
||||
player.setCoin(player.getCoin() - allItems.get(5).getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
default: {
|
||||
System.out.println("You don't have enough coin!");
|
||||
}
|
||||
}
|
||||
}while (input4 != 0 );
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
if(hasKeys)
|
||||
{
|
||||
if (combat(player, new Dragon()))
|
||||
{
|
||||
System.out.println(Colors.PINK + "VICTORY!!!!!!!");
|
||||
running = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static boolean combat(Player p, Enemy e)
|
||||
{
|
||||
int round = 0;
|
||||
while (p.isAlive() && e.isAlive())
|
||||
{
|
||||
// System.out.println("You choos to fight with " + e.getClass().getSimpleName());
|
||||
System.out.printf(Colors.ORANGE + "[" + Colors.RESET + p.getName() + " - " +"%d/%d HP | %d/%d Mana" + Colors.ORANGE + "]\n" ,
|
||||
p.getHp(), p.getMaxHP(), p.getMp(), p.getMaxMP());
|
||||
System.out.printf(Colors.ORANGE + "[" + Colors.RESET + e.getClass().getSimpleName() + " - " +"%d/%d HP" + Colors.ORANGE + "]\n" + Colors.RESET, e.getHp(), e.getMaxHP() );
|
||||
System.out.println("Your turn:");
|
||||
switch (p) {
|
||||
case Knight knight ->
|
||||
System.out.println("1.Light Attack | 2.Heavy Attack " + Colors.ORANGE + "(" + Colors.RESET + "-50 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 3.Defend " + Colors.ORANGE + "(" + Colors.RESET + "-40 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 4.Heal" + Colors.ORANGE + "(" + Colors.RESET + "-45 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 5.Shield Bash " + Colors.ORANGE + "(" + Colors.RESET + "-65 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")\n" + Colors.RESET);
|
||||
case Assassin assassin ->
|
||||
System.out.println("1.Light Attack | 2.Heavy Attack " + Colors.ORANGE + "(" + Colors.RESET + "-55 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 3.Defend " + Colors.ORANGE + "(" + Colors.RESET + "-40 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 4.Heal" + Colors.ORANGE + "(" + Colors.RESET + "-45 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 5.Shadow Strike " + Colors.ORANGE + "(" + Colors.RESET + "-80 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")\n" + Colors.RESET);
|
||||
case Wizard wizard ->
|
||||
System.out.println("1.Light Attack | 2.Heavy Attack " + Colors.ORANGE + "(" + Colors.RESET + "-65 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 3.Defend " + Colors.ORANGE + "(" + Colors.RESET + "-40 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 4.Heal" + Colors.ORANGE + "(" + Colors.RESET + "-45 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")" +
|
||||
Colors.RESET + " | 5.Blood Burn " + Colors.ORANGE + "(" + Colors.RESET + "-75 " + Colors.BLUE + "Mana" + Colors.ORANGE + ")\n" + Colors.RESET);
|
||||
default -> {
|
||||
|
||||
}
|
||||
}
|
||||
if(!p.getItems().isEmpty())
|
||||
{
|
||||
System.out.println("press 6 to see your items.");
|
||||
}
|
||||
Scanner input = new Scanner(System.in);
|
||||
int input3 = input.nextInt();
|
||||
switch (input3)
|
||||
{
|
||||
case(1):
|
||||
{
|
||||
p.lightAttack(e);
|
||||
break;
|
||||
}
|
||||
case(2):
|
||||
{
|
||||
if(!p.heavyAttack(e))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
if(!p.heal(p.getMaxHP()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(5):
|
||||
{
|
||||
if(!p.specialAbility(e))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(6):
|
||||
{
|
||||
if(!p.getItems().isEmpty())
|
||||
{
|
||||
p.showItems();
|
||||
System.out.println("What do you want to use: ");
|
||||
System.out.println("press 0 to back.");
|
||||
// System.out.println(p);
|
||||
int input5 = input.nextInt();
|
||||
while (input5 < 0 || input5 > p.getItems().size())
|
||||
{
|
||||
System.out.println("invalid input!");
|
||||
p.showItems();
|
||||
System.out.println("What do you want to use: ");
|
||||
System.out.println("press 0 to back.");
|
||||
input5 =input.nextInt();
|
||||
}
|
||||
if(input5 == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p.getItems().get(input5 - 1).getTargetType().equals("Player"))
|
||||
{
|
||||
p.getItems().get(input5 - 1).use(p);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p.getItems().get(input5 - 1) instanceof GoblinGland)
|
||||
{
|
||||
p.getItems().get(input5 - 1).use(e);
|
||||
continue;
|
||||
}
|
||||
p.getItems().get(input5 - 1).use(e);
|
||||
}
|
||||
p.useItem(p.getItems().get(input5 - 1));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(e.isAlive())
|
||||
{
|
||||
|
||||
if(e.isConfuse())
|
||||
{
|
||||
System.out.println("Enemy lost its turn cause of confusion");
|
||||
continue;
|
||||
}
|
||||
if (input3 == 5 && p instanceof Knight)
|
||||
{
|
||||
System.out.printf("%s couldn't do anything in his round\n", e.getClass().getSimpleName());
|
||||
continue;
|
||||
}
|
||||
if(e.HaveBleed())
|
||||
{
|
||||
// System.out.println(e.getClass().getSimpleName() + " is " + Colors.RED + "Bleeding!\n" + Colors.RESET);
|
||||
e.bleed((AssassineWeapon) p.getWeapon());
|
||||
}
|
||||
System.out.printf("%s" + "'s turn:\n", e.getClass().getSimpleName());
|
||||
if (input3 == 3) {
|
||||
p.defend(e.attack());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(e instanceof Dragon)
|
||||
{
|
||||
p.takeDamage((Dragon) e);
|
||||
|
||||
}
|
||||
else if(p instanceof Wizard w) {
|
||||
w.takeDamage(e ,e.attack());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.takeDamage(e.attack());
|
||||
}
|
||||
}
|
||||
if(!p.isAlive())
|
||||
{
|
||||
System.out.println("You " + Colors.RED + "Died" + Colors.BLUE + ":(");
|
||||
return false;
|
||||
}
|
||||
round++;
|
||||
if(round == 2)
|
||||
{
|
||||
round = 0;
|
||||
if (p instanceof Knight) {
|
||||
p.fillMana(p.getMaxMP() / 5);
|
||||
} else {
|
||||
p.fillMana(p.getMaxMP() / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("You defeat the " + e.getClass().getSimpleName());
|
||||
p.addXp(e);
|
||||
p.addCoin(e);
|
||||
e.dropKey(p);
|
||||
System.out.println("Keep moving forward!");
|
||||
System.out.println("Good luck!");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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.AssassineArmor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.armors.WizardArmor;
|
||||
import org.project.item.weapons.AssassineWeapon;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.WizardWeapon;
|
||||
import org.project.location.Location;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Colors {
|
||||
public static final String RED = "\u001b[38;5;124m";
|
||||
public static final String LIGHTRED = "\u001b[38;5;160m";
|
||||
public static final String ORANGE = "\u001b[38;5;202m";
|
||||
public static final String FIRE = "\u001b[38;5;208m";
|
||||
public static final String BLUE = "\u001b[38;5;33m";
|
||||
public static final String KEY = "\u001b[38;5;14m";
|
||||
public static final String LIGHTBLUE = "\u001b[38;5;68m";
|
||||
public static final String RESET = "\u001b[38;5;15m";
|
||||
public static final String YELLO = "\u001b[38;5;226m";
|
||||
public static final String COIN = "\u001b[38;5;214m";
|
||||
public static final String PURPLE = "\u001b[38;5;164m";
|
||||
public static final String PINK = "\u001b[38;5;205m";
|
||||
public static final String HEAL = "\u001b[38;5;203m";
|
||||
public static final String WELCOME = "\u001b[38;5;65m";
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.project;
|
||||
|
||||
import org.project.location.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
||||
List<Location> locations = new ArrayList<>();
|
||||
|
||||
// TODO: IMPLEMENT GAMEPLAY
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
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 getMaxMP();
|
||||
boolean heal(int health);
|
||||
|
||||
boolean isAlive();
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface ICombatActions {
|
||||
void lightAttack(Entity target);
|
||||
|
||||
boolean heavyAttack(Entity target);
|
||||
|
||||
boolean specialAbility(Entity target);
|
||||
|
||||
boolean defend(int damage);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Dragon extends Enemy{
|
||||
public Dragon() {
|
||||
super(250, 58);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attack() {
|
||||
if(new Random().nextInt(100) < 35)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
return super.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropKey(Player player) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,138 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.weapons.AssassineWeapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Enemy {
|
||||
Weapon weapon;
|
||||
public abstract class Enemy implements Entity {
|
||||
private final int maxHp;
|
||||
private int hp;
|
||||
private int mp;
|
||||
private Boolean haveBleed;
|
||||
private int bleedingRound;
|
||||
private final int damage;
|
||||
public boolean confuse;//for Goblin Gland
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.weapon = weapon;
|
||||
public Enemy(int maxHp, int damage) {
|
||||
this.maxHp = maxHp;
|
||||
this.hp = maxHp;
|
||||
this.damage = damage;
|
||||
this.haveBleed = false;
|
||||
this.bleedingRound = 0;
|
||||
this.confuse = false;
|
||||
}
|
||||
|
||||
public void setConfuse(boolean confuse) {
|
||||
this.confuse = confuse;
|
||||
}
|
||||
|
||||
public boolean isConfuse()
|
||||
{
|
||||
if(confuse)
|
||||
{
|
||||
confuse = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean heal(int health) {
|
||||
System.out.printf("%s healed for " + Colors.LIGHTRED + "%d" + Colors.RESET +" HP\n", this.getClass().getSimpleName(), health);
|
||||
hp += health;
|
||||
if (hp > maxHp) {
|
||||
hp = maxHp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHp;
|
||||
}
|
||||
|
||||
public void bleed(AssassineWeapon aw)
|
||||
{
|
||||
if(haveBleed)
|
||||
{
|
||||
if(bleedingRound > 0)
|
||||
{
|
||||
System.out.printf("%s Bleeds out!."+ Colors.RED + "-%d" +Colors.RESET + " HP\n", this.getClass().getSimpleName(), aw.getBleedDamage());
|
||||
hp -= aw.getBleedDamage();
|
||||
this.bleedingRound--;
|
||||
}
|
||||
if(bleedingRound == 0)
|
||||
{
|
||||
this.haveBleed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getBleedingRound() {
|
||||
return bleedingRound;
|
||||
}
|
||||
|
||||
public void setBleedingRound(int bleedingRound) {
|
||||
this.bleedingRound = bleedingRound;
|
||||
}
|
||||
|
||||
public Boolean HaveBleed() {
|
||||
return haveBleed;
|
||||
}
|
||||
|
||||
public void setHaveBleed(Boolean haveBleed) {
|
||||
this.haveBleed = haveBleed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
|
||||
public int attack()
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public abstract void dropKey(Player player);
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
if(hp < 0)
|
||||
{
|
||||
hp = 0;
|
||||
}
|
||||
System.out.printf("%s took " + Colors.RED + "%d" + Colors.RESET + " damage!\n",this.getClass().getSimpleName(), damage);
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
if(hp > maxHp)
|
||||
{
|
||||
hp = maxHp;
|
||||
}
|
||||
}
|
||||
// public int getMp() {
|
||||
// return mp;
|
||||
// }
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
// public Weapon getWeapon() {
|
||||
// return weapon;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Goblin extends Enemy{
|
||||
|
||||
private int hitChance;
|
||||
|
||||
public Goblin() {
|
||||
|
||||
super(50, 25);
|
||||
this.hitChance = 20;
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
@Override
|
||||
public int attack() {
|
||||
if(rand.nextInt(100) < hitChance)
|
||||
{
|
||||
System.out.println("Goblin used Critical Strike!");
|
||||
hitChance -= 5;
|
||||
return 45;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Goblin attacked");
|
||||
return super.getDamage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropKey(Player player) {
|
||||
if(!player.getGoblinKey())
|
||||
{
|
||||
if (new Random().nextInt(100) < 50) {
|
||||
System.out.println("Goblin dropped a " + Colors.KEY +"KEY" +Colors.RESET +"!");
|
||||
player.setGoblinKey(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,53 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Skeleton {
|
||||
public class Skeleton extends Enemy {
|
||||
|
||||
private int lifeChance;
|
||||
|
||||
public Skeleton() {
|
||||
super(60, 30);
|
||||
this.lifeChance = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
if(super.getHp() <= 0)
|
||||
{
|
||||
if(lifeChance >= 1)
|
||||
{
|
||||
lifeChance--;
|
||||
super.setHp(30);
|
||||
System.out.println("Skeleton rises again with 50% of HP (current HP: 30)");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropKey(Player player) {
|
||||
if(!player.getSkeletonKey())
|
||||
{
|
||||
if (new Random().nextInt(100) < 35) {
|
||||
System.out.println("Skeleton dropped a " + Colors.KEY +"KEY" +Colors.RESET +"!");
|
||||
player.setSkeletonKey(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Vampire extends Enemy{
|
||||
public Vampire() {
|
||||
super(75, 35);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean heal(int health) {
|
||||
super.setHp(super.getHp() + health);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attack() {
|
||||
|
||||
System.out.println("Your HP is know VAMPIRE's HP!");
|
||||
super.heal(super.getDamage() / 2);
|
||||
return super.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropKey(Player player) {
|
||||
if(!player.getVampireKey())
|
||||
{
|
||||
if (new Random().nextInt(100) < 40) {
|
||||
System.out.println("Vampire dropped a " + Colors.KEY +"KEY" +Colors.RESET +"!");
|
||||
player.setVampireKey(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.AssassineArmor;
|
||||
import org.project.item.weapons.AssassineWeapon;
|
||||
|
||||
public class Assassin extends Player{
|
||||
|
||||
|
||||
|
||||
public Assassin(String name, AssassineWeapon weapon, AssassineArmor armor) {
|
||||
super(name, 65, 120, weapon, armor, 70);
|
||||
super.setDamage(35);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void levelUp() {
|
||||
if(super.getLevel() < 5) {
|
||||
addLevel();
|
||||
System.out.printf("You leveled up! " +Colors.ORANGE +"(" +Colors.RESET +"your level: " + Colors.LIGHTBLUE + "%d" + Colors.ORANGE +")\n" + Colors.RESET, super.getLevel());
|
||||
switch (super.getLevel())
|
||||
{
|
||||
case (2):
|
||||
{
|
||||
|
||||
super.setMaxHP(super.getMaxHP() + ((20*super.getMaxHP()) / 100 ));
|
||||
System.out.println("Your maximum HP is know 20% higher");
|
||||
super.setDamage(super.getDamage() + ((20*super.getMaxHP()) / 100 ));
|
||||
System.out.println("Your base damage is know 20% higher");
|
||||
break;
|
||||
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
AssassineArmor asA = (AssassineArmor) super.getArmor();
|
||||
asA.setDodgeChance(asA.getDodgeChance() + asA.getDodgeChance()/2);
|
||||
System.out.println("Your dodge chance is know " + asA.getDodgeChance());
|
||||
asA.setMaxPercentage(2*asA.getMaxPercentage());
|
||||
System.out.println("Your defend percentage is know " + asA.getDefensePercentage());
|
||||
break;
|
||||
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
|
||||
super.setDamage(super.getDamage() + super.getDamage()/ 2);
|
||||
System.out.println("Your base damage is know 50% higher");
|
||||
AssassineWeapon aw = (AssassineWeapon) super.getWeapon();
|
||||
aw.setBleedingRound(aw.getBleedingRound() + 1);
|
||||
System.out.println("Bleed duration on the enemy increased to two rounds (up from one)");
|
||||
aw.setBleedChance(2*aw.getBleedChance());
|
||||
System.out.println("Your bleed chance is know " + aw.getBleedChance());
|
||||
break;
|
||||
|
||||
}
|
||||
case (5):
|
||||
{
|
||||
super.setMaxHP(super.getMaxHP() + ((30*super.getMaxHP()) / 100 ));
|
||||
System.out.println("Your maximum HP is know 20% higher");
|
||||
super.setMaxMP(super.getMaxMP() + ((10*super.getMaxMP()) / 100 ));
|
||||
System.out.println("Your maximum Mana is know 10% higher");
|
||||
super.getWeapon().setDamage(super.getWeapon().getDamage() + ((30*super.getWeapon().getDamage()) / 100 ));
|
||||
System.out.println("Your Weapon damage is know 30% higher");
|
||||
super.setMaxDefense(super.getMaxDefense() + ((20*super.getMaxDefense()) / 100 ));
|
||||
System.out.println("Your maximum defence is know 20% higher");
|
||||
AssassineWeapon aw = (AssassineWeapon) super.getWeapon();
|
||||
aw.setBleedingRound(aw.getBleedingRound() + 1);
|
||||
System.out.println("Bleed duration on the enemy increased to three rounds (up from two)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.setHp(super.getMaxHP());
|
||||
super.fillMana(super.getMaxMP());
|
||||
super.getArmor().repair();
|
||||
System.out.println();
|
||||
showInf();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean heavyAttack(Entity target) {
|
||||
if(super.getMp() >= super.getWeapon().getManaCost()) {
|
||||
super.setMp(super.getMp() - super.getWeapon().getManaCost());
|
||||
System.out.printf("%s (%s) uses heavy attack.\n", name, this.getClass().getSimpleName());
|
||||
target.takeDamage(super.getWeapon().getDamage());
|
||||
AssassineWeapon aw = (AssassineWeapon) super.getWeapon();
|
||||
aw.manaGain(this, aw.getDamage() / 4);
|
||||
if(target instanceof Enemy enemy)
|
||||
{
|
||||
enemy.setHaveBleed(aw.bleed());
|
||||
if(enemy.HaveBleed())
|
||||
{
|
||||
enemy.setBleedingRound(aw.getBleedingRound());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " for heavy attack.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
AssassineArmor asA = (AssassineArmor) super.getArmor();
|
||||
int defence = asA.getDefense(damage);
|
||||
if(defence == damage)
|
||||
{
|
||||
System.out.printf("%s (Assassin) dodged the attack.\n", super.name);
|
||||
}
|
||||
else {
|
||||
super.takeDamage(damage - defence);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialAbility(Entity target) {
|
||||
if(super.getMp() > 80) {
|
||||
super.setMp(super.getMp() - 80);
|
||||
System.out.printf("%s (Assassin) uses special ability.\n", super.name);
|
||||
System.out.println("Assassin dodged the " + Colors.RED + "attack" + Colors.RESET);
|
||||
AssassineWeapon aw = (AssassineWeapon) super.getWeapon();
|
||||
System.out.printf("%s (Assassin) used Critical Strike!\n", super.name);
|
||||
target.takeDamage(aw.criticalHit());
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " for your special ability.");
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInf() {
|
||||
AssassineArmor asA = (AssassineArmor) super.getArmor();
|
||||
AssassineWeapon aw = (AssassineWeapon) super.getWeapon();
|
||||
System.out.println("Your information:");
|
||||
System.out.printf("""
|
||||
Level: %d
|
||||
HP: %d
|
||||
MP: %d
|
||||
Coin: %d
|
||||
Maximum defence: %d
|
||||
|
||||
Armor:
|
||||
Durability: %d
|
||||
DefensePercentage: %d
|
||||
Dodge chance: %d
|
||||
|
||||
Weapon:
|
||||
Damage: %d
|
||||
Mana cost: %d
|
||||
|
||||
Bleed chance: %d
|
||||
Bleed damage: %d
|
||||
Bleeding round: %d
|
||||
|
||||
Critical hit: %d
|
||||
|
||||
""", super.getLevel(), super.getHp(), super.getMp(), super.getCoin(), super.getMaxDefense(),
|
||||
super.getArmor().getDurability(), super.getArmor().getDefensePercentage(),
|
||||
asA.getDodgeChance(), aw.getDamage(), aw.getManaCost() ,aw.getBleedChance(),
|
||||
aw.getBleedDamage(), aw.getBleedingRound(), 3*aw.getDamage() );
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,144 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Knight {
|
||||
public class Knight extends Player {
|
||||
|
||||
|
||||
public Knight(String name,Sword weapon, KnightArmor armor) {
|
||||
//although hp is low but armor is wow.
|
||||
super(name, 60, 70, weapon, armor, 65);
|
||||
super.setDamage(40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void levelUp() {
|
||||
if(super.getLevel() < 5) {
|
||||
addLevel();
|
||||
System.out.printf("You leveled up! " +Colors.ORANGE +"(" +Colors.RESET +"your level: " + Colors.LIGHTBLUE + "%d" + Colors.ORANGE +")\n" + Colors.RESET, super.getLevel());
|
||||
switch (super.getLevel())
|
||||
{
|
||||
case (2):
|
||||
{
|
||||
|
||||
super.setMaxHP(super.getMaxHP() + ((15*super.getMaxHP()) / 100 ));
|
||||
System.out.println("Your maximum HP is know 15% higher");
|
||||
super.setMaxMP(super.getMaxMP() + ((10*super.getMaxMP()) / 100 ));
|
||||
System.out.println("Your maximum Mana is know 10% higher");
|
||||
break;
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
super.getArmor().setMaxDurability(super.getArmor().getMaxDurability() + ((10 * super.getArmor().getMaxDurability()) / 100));
|
||||
System.out.println("Your armor's maximum durability is know 10% higher");
|
||||
break;
|
||||
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
super.setMaxHP(super.getMaxHP() + ((40*super.getMaxHP()) / 100 ));
|
||||
System.out.println("Your maximum HP is know 40% higher");
|
||||
Sword sword = (Sword) super.getWeapon();
|
||||
sword.setSpecialDamage(sword.getSpecialDamage() + (10*sword.getSpecialDamage() / 100 ));
|
||||
System.out.println("Your sword special damage is know 10% higher");
|
||||
super.setDamage(super.getDamage() + ((20*super.getDamage()) / 100 ));
|
||||
System.out.println("Your base damage is know 20% higher");
|
||||
super.getWeapon().setManaCost(super.getWeapon().getManaCost() - ((10*super.getWeapon().getManaCost()) / 100 ));
|
||||
System.out.println("Your weapon mana cost decreased by 10%");
|
||||
break;
|
||||
}
|
||||
case (5):
|
||||
{
|
||||
super.setMaxMP(super.getMaxMP() + ((20*super.getMaxMP()) / 100 ));
|
||||
System.out.println("Your maximum mana is know 20% higher");
|
||||
super.setMaxDefense(super.getMaxDefense() + ((20*super.getMaxDefense()) / 100 ));
|
||||
System.out.println("Your maximum defence is know 20% higher");
|
||||
super.getWeapon().setDamage(super.getWeapon().getDamage() + ((10*super.getWeapon().getDamage()) / 100 ));
|
||||
System.out.println("Your sword damage is know 10% higher");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.setHp(super.getMaxHP());
|
||||
super.fillMana(super.getMaxMP());
|
||||
super.getArmor().repair();
|
||||
System.out.println();
|
||||
showInf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialAbility(Entity target) {
|
||||
if(super.getMp() > 65) {
|
||||
super.setMp(super.getMp() - 65);
|
||||
System.out.printf("%s (Knight) uses special ability.\n", super.name);
|
||||
Sword sword = (Sword) super.getWeapon();
|
||||
target.takeDamage(sword.getSpecialDamage());
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " for your special ability.");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInf() {
|
||||
Sword sword = (Sword) super.getWeapon();
|
||||
System.out.println("Your information:");
|
||||
System.out.printf("""
|
||||
level: %d
|
||||
HP: %d
|
||||
MP: %d
|
||||
Coin: %d
|
||||
Maximum defence: %d
|
||||
|
||||
|
||||
armor:
|
||||
durability: %d
|
||||
defensePercentage: %d
|
||||
|
||||
|
||||
Sword:
|
||||
damage: %d
|
||||
mana cost: %d
|
||||
Special damage: %d
|
||||
|
||||
""", super.getLevel(), super.getHp(), super.getMp(), super.getCoin(), super.getMaxDefense(),
|
||||
super.getArmor().getDurability(), super.getArmor().getDefensePercentage(),
|
||||
sword.getDamage(),sword.getManaCost() ,sword.getSpecialDamage());
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public void defend(int damage) {
|
||||
//
|
||||
// if(damage > 60)
|
||||
// {
|
||||
// int defense = (80 * damage) / 100;
|
||||
// this.takeDamage(damage - defense);
|
||||
// System.out.printf("You took " + Colors.BLUE + "%d" + Colors.RESET + "damage!" + Colors.YELLO + "(%d damage was defended)\n" + Colors.RESET, damage, damage - defense);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// System.out.println("The enemy hit defended!");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public void takeDamage(int damage) {
|
||||
// super.takeDamage(damage);
|
||||
// System.out.printf("%s (Knight) took" + Colors.RED + "%d" + Colors.RESET + "damage!\n",super.name, damage - armor.getDefense(damage) );
|
||||
// }
|
||||
|
||||
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
|
||||
}
|
||||
|
||||
@@ -1,53 +1,195 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.ICombatActions;
|
||||
import org.project.entity.enemies.*;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.consumables.Consumable;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static java.lang.Math.*;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
public abstract class Player implements Entity, ICombatActions {
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
private Weapon weapon;
|
||||
private Armor armor;
|
||||
private ArrayList<Consumable> items;
|
||||
private int hp;
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
private int damage;
|
||||
private int level;
|
||||
private int xp;
|
||||
private Boolean goblinKey;
|
||||
private Boolean skeletonKey;
|
||||
private Boolean vampireKey;
|
||||
private int coin;// write it in constructor with right amount
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
private int maxDefense;
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
public int getMaxDefense() {
|
||||
return maxDefense;
|
||||
}
|
||||
|
||||
public void setMaxDefense(int maxDefense) {
|
||||
this.maxDefense = maxDefense;
|
||||
}
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor, int maxDefense) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.maxHP = hp;
|
||||
this.maxMP = mp;
|
||||
this.mp = mp;
|
||||
|
||||
this.level = 1;
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
this.maxDefense = maxDefense;
|
||||
this.goblinKey = false;
|
||||
this.skeletonKey = false;
|
||||
this.vampireKey = false;
|
||||
this.coin = 0;
|
||||
this.items = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
public void lightAttack(Entity target)
|
||||
{
|
||||
System.out.printf("%s (%s) used light attack\n", name, this.getClass().getSimpleName());
|
||||
target.takeDamage(damage);
|
||||
}
|
||||
|
||||
|
||||
public void addItem(Consumable c)
|
||||
{
|
||||
if(items.contains(c))
|
||||
{
|
||||
items.get(items.indexOf(c)).addOne();
|
||||
}
|
||||
else
|
||||
{
|
||||
items.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Consumable> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void useItem(Consumable c)
|
||||
{
|
||||
if(items.get(items.indexOf(c)).getNumberOf() > 1)
|
||||
{
|
||||
items.get(items.indexOf(c)).reduceOne();
|
||||
if(items.get(items.indexOf(c)).getNumberOf() == 0)
|
||||
{
|
||||
items.remove(c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
items.remove(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showItems()
|
||||
{
|
||||
if(!items.isEmpty())
|
||||
{
|
||||
System.out.println("Your items: ");
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
System.out.println((i + 1) + "." + items.get(i).getClass().getSimpleName() + ": " + items.get(i).getNumberOf());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setCoin(int coin) {
|
||||
this.coin = coin;
|
||||
}
|
||||
@Override
|
||||
public boolean heavyAttack(Entity target) {
|
||||
if(mp >= weapon.getManaCost()) {
|
||||
System.out.printf("%s (%s) uses heavy attack\n", name, this.getClass().getSimpleName());
|
||||
target.takeDamage(weapon.getDamage());
|
||||
mp -= weapon.getManaCost();
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " for heavy attack.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void setMp(int mp) {
|
||||
this.mp = mp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
public boolean defend(int damage) {
|
||||
if(mp > 40)
|
||||
{
|
||||
mp -= 40;
|
||||
if (damage > maxDefense) {
|
||||
int defense = (80 * damage) / 100;
|
||||
this.takeDamage(damage - defense);
|
||||
System.out.printf("You took " + Colors.BLUE + "%d" + Colors.RESET + "damage!" + Colors.YELLO + "(%d damage was defended)\n" + Colors.RESET, damage, damage - defense);
|
||||
} else {
|
||||
System.out.println("The enemy hit defended!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " to defend.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
|
||||
//
|
||||
//max(0 ,damage - armor.getDefense(damage))
|
||||
hp -= (damage - armor.getDefense(damage));
|
||||
System.out.printf("%s (%s) took " + Colors.RED + "%d" + Colors.RESET + " damage!\n",name, this.getClass().getSimpleName(), damage - armor.getDefense(damage) );
|
||||
}
|
||||
public void takeDamage(Dragon dragon)
|
||||
{
|
||||
hp -= dragon.getDamage();
|
||||
System.out.println("you can't defeat dragon " + Colors.FIRE + "Fire" + Colors.RESET + "!");
|
||||
System.out.printf("%s (%s) took " + Colors.RED + "%d" + Colors.RESET + " damage!\n",name, this.getClass().getSimpleName(), dragon.getDamage());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
public boolean heal(int health) {
|
||||
if(mp > 45)
|
||||
{
|
||||
mp -= 45;
|
||||
System.out.printf("%s (%s) healed for " +Colors.HEAL +"%d" +Colors.RESET+ " HP.\n", name, this.getClass().getSimpleName(), health);
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " to heal.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
|
||||
public void fillMana(int mana) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
@@ -55,6 +197,139 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void levelUp();
|
||||
/*
|
||||
(maximum level of every character must be 5)
|
||||
maxDefense++
|
||||
damage++
|
||||
hp++
|
||||
mp++
|
||||
level++
|
||||
(mabe open new items in shop)
|
||||
|
||||
*/
|
||||
|
||||
public void showInf()
|
||||
{
|
||||
System.out.printf("""
|
||||
level: %d
|
||||
HP: %d
|
||||
MP: %d
|
||||
Maximum defence: %d
|
||||
|
||||
armor:
|
||||
durability: %d
|
||||
defensePercentage: %d
|
||||
|
||||
weapon:
|
||||
damage: %d
|
||||
mana cost: %d
|
||||
|
||||
""", getLevel(), getHp(), getMp(), getMaxDefense(), armor.getDurability(), armor.getDefensePercentage(), weapon.getDamage(), weapon.getManaCost());
|
||||
}
|
||||
|
||||
public void setMaxMP(int maxMP) {
|
||||
this.maxMP = maxMP;
|
||||
}
|
||||
|
||||
public void setMaxHP(int maxHP) {
|
||||
this.maxHP = maxHP;
|
||||
}
|
||||
|
||||
public void addLevel(){level++;}
|
||||
|
||||
public void addXp(int XP)
|
||||
{
|
||||
if(xp < 600)
|
||||
{
|
||||
this.xp += XP;
|
||||
System.out.printf("You received %d Xp " + Colors.ORANGE +
|
||||
"[" + Colors.RESET + "Your Xp: %d" + Colors.ORANGE + "]\n", XP, this.xp);
|
||||
}
|
||||
}
|
||||
public void addXp(Enemy e)
|
||||
{
|
||||
if(xp < 600)
|
||||
{
|
||||
int amount = 0;
|
||||
if (e instanceof Goblin) {
|
||||
amount = 50;
|
||||
} else if (e instanceof Skeleton) {
|
||||
amount = 70;
|
||||
} else if (e instanceof Vampire) {
|
||||
amount = 90;
|
||||
|
||||
}
|
||||
this.xp += amount;
|
||||
System.out.printf("You received %d Xp " + Colors.ORANGE +
|
||||
"[" + Colors.RESET + "Your Xp: %d" + Colors.ORANGE + "]\n" + Colors.RESET, amount, this.xp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Boolean needLevelUp()
|
||||
{
|
||||
switch (this.level)
|
||||
{
|
||||
case (1): {
|
||||
if (xp >= 50) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (2):
|
||||
{
|
||||
if(xp >= 150)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (3):
|
||||
{
|
||||
if(xp >= 300)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (4):
|
||||
{
|
||||
if(xp > 500)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void addCoin(int amount)
|
||||
{
|
||||
this.coin += amount;
|
||||
System.out.println(Colors.COIN + "+" + amount + " coins!" + Colors.RESET);
|
||||
}
|
||||
|
||||
public void addCoin(Enemy e)
|
||||
{
|
||||
int amount = 0;
|
||||
if (e instanceof Goblin) {
|
||||
amount = 10;
|
||||
} else if (e instanceof Skeleton) {
|
||||
amount = 25;
|
||||
} else if (e instanceof Vampire) {
|
||||
amount = 60;
|
||||
}
|
||||
this.coin += amount;
|
||||
System.out.println("You gained " + Colors.COIN + amount + " coins" + Colors.RESET + ".");
|
||||
}
|
||||
|
||||
public int getCoin() {
|
||||
return coin;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -64,7 +339,6 @@ public abstract class Player {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
@@ -73,7 +347,6 @@ public abstract class Player {
|
||||
return mp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
}
|
||||
@@ -86,4 +359,42 @@ public abstract class Player {
|
||||
return armor;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public int getXp(){return xp;}
|
||||
|
||||
public int getLevel(){return level;}
|
||||
|
||||
public void setDamage(int baseDamage){this.damage = baseDamage;}
|
||||
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getSkeletonKey() {
|
||||
return skeletonKey;
|
||||
}
|
||||
|
||||
public void setSkeletonKey(Boolean skeletonKey) {
|
||||
this.skeletonKey = skeletonKey;
|
||||
}
|
||||
|
||||
public Boolean getVampireKey() {
|
||||
return vampireKey;
|
||||
}
|
||||
|
||||
public void setVampireKey(Boolean vampireKey) {
|
||||
this.vampireKey = vampireKey;
|
||||
}
|
||||
|
||||
public Boolean getGoblinKey() {
|
||||
return goblinKey;
|
||||
}
|
||||
|
||||
public void setGoblinKey(Boolean goblinKey) {
|
||||
this.goblinKey = goblinKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.WizardArmor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.item.weapons.WizardWeapon;
|
||||
|
||||
public class Wizard extends Player{
|
||||
|
||||
public Wizard(String name, Weapon weapon, WizardArmor armor) {
|
||||
super(name, 80, 80, weapon, armor,50 );
|
||||
super.setDamage(35);
|
||||
super.setMp(super.getMp() + armor.getBonus(this));
|
||||
super.setMaxMP(super.getMp() + armor.getBonus(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void levelUp() {
|
||||
if(super.getLevel() < 5) {
|
||||
addLevel();
|
||||
System.out.printf("You leveled up! " +Colors.ORANGE +"(" +Colors.RESET +"your level: " + Colors.LIGHTBLUE + "%d" + Colors.ORANGE +")\n" + Colors.RESET, super.getLevel());
|
||||
switch (getLevel())
|
||||
{
|
||||
case (2):
|
||||
{
|
||||
super.setMaxDefense(super.getMaxDefense() + ((30*super.getMaxDefense()) / 100));
|
||||
System.out.println("Your maximum defence is know 30% higher");
|
||||
super.setMaxHP(super.getMaxHP() + ((10*super.getMaxHP()) / 100));
|
||||
System.out.println("Your maximum HP is know 10% higher");
|
||||
break;
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
WizardArmor wizardArmor = (WizardArmor) super.getArmor();
|
||||
wizardArmor.setBonusPercent(2*wizardArmor.getBonusPercent());
|
||||
System.out.println("Bonus percentage has doubled");
|
||||
wizardArmor.setReflectPercent(wizardArmor.getReflectPercent() + ((30*wizardArmor.getReflectPercent()) / 100));
|
||||
System.out.println("Reflect percentage increased");
|
||||
break;
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
super.setMaxHP(super.getMaxMP() + ((30*super.getMaxMP()) / 100 ));
|
||||
System.out.println("Your maximum HP is know 30% higher");
|
||||
WizardWeapon wizardWeapon = (WizardWeapon) super.getWeapon();
|
||||
wizardWeapon.setManaCost(wizardWeapon.getManaCost() - ((35* wizardWeapon.getManaCost()) / 100 ));
|
||||
System.out.println("Your weapon mana cost decreased by 35%");
|
||||
super.setDamage(super.getDamage() + ((50*super.getDamage()) / 100 ));
|
||||
System.out.println("Your base damage is know 50% higher");
|
||||
break;
|
||||
}
|
||||
case (5):
|
||||
{
|
||||
super.setMaxMP(super.getMaxMP() + ((50*super.getMaxMP()) / 100 ));
|
||||
System.out.println("Your maximum mana is know 50% higher");
|
||||
super.setMaxHP(super.getMaxHP() + ((40*super.getMaxHP()) / 100 ));
|
||||
System.out.println("Your maximum HP is know 40% higher");
|
||||
super.setMaxDefense(super.getMaxDefense() + ((50*super.getMaxDefense()) / 100));
|
||||
System.out.println("Your maximum defence is know 50% higher");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.setHp(super.getMaxHP());
|
||||
super.fillMana(super.getMaxMP());
|
||||
super.getArmor().repair();
|
||||
System.out.println();
|
||||
showInf();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void takeDamage(Entity attacker ,int damage) {
|
||||
super.takeDamage(damage);
|
||||
WizardArmor w = (WizardArmor) super.getArmor();
|
||||
w.reflect(attacker, damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean heavyAttack(Entity target) {
|
||||
if(super.getMp() > super.getWeapon().getManaCost()) {
|
||||
super.setMp(super.getMp() - super.getWeapon().getManaCost());
|
||||
System.out.printf("%s (Wizard) performed a triple attack!\n", super.name);
|
||||
WizardWeapon wp = (WizardWeapon) super.getWeapon();
|
||||
target.takeDamage(wp.tripleAttack());
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " for heavy attack.");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialAbility(Entity target) {
|
||||
if(super.getMp() > 75) {
|
||||
super.setMp(super.getMp() - 75);
|
||||
System.out.printf("%s (Wizard) uses special ability.\n", super.name);
|
||||
WizardWeapon w = (WizardWeapon) super.getWeapon();
|
||||
target.takeDamage(4*w.getDamage());
|
||||
super.setHp(super.getHp() + ((6 * super.getMaxHP()) / 10));
|
||||
return true;
|
||||
}
|
||||
System.out.println("You don't have enough " + Colors.BLUE + "Mana" + Colors.RESET + " for your special ability.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInf() {
|
||||
WizardArmor w = (WizardArmor) super.getArmor();
|
||||
System.out.println("Your information:");
|
||||
System.out.printf("""
|
||||
level: %d
|
||||
HP: %d
|
||||
MP: %d
|
||||
Coin: %d
|
||||
Maximum defence: %d
|
||||
Special damage(in special attack): %d
|
||||
|
||||
armor:
|
||||
durability: %d
|
||||
defensePercentage: %d
|
||||
Bonus percentage: %d
|
||||
Reflect percent: %d
|
||||
|
||||
weapon:
|
||||
damage: %d
|
||||
mana cost: %d
|
||||
|
||||
""", super.getLevel(), super.getHp(), super.getMp(), super.getCoin(), super.getMaxDefense(),
|
||||
4*super.getWeapon().getDamage(), w.getDurability(), w.getDefensePercentage(),
|
||||
w.getBonusPercent(), w.getReflectPercent(), super.getWeapon().getDamage(), super.getWeapon().getManaCost());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.project.item;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public interface Item {
|
||||
void use(Entity target);
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
@@ -1,35 +1,59 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Armor {
|
||||
private int defense;
|
||||
private int maxDefense;
|
||||
public abstract class Armor{
|
||||
// private int defense;
|
||||
// private final int maxDefense;
|
||||
private int defensePercentage;
|
||||
private int maxPercentage;
|
||||
private int durability;
|
||||
private int maxDurability;
|
||||
|
||||
|
||||
private boolean isBroke;
|
||||
|
||||
public Armor(int defense, int durability) {
|
||||
this.defense = defense;
|
||||
this.durability = durability;
|
||||
public Armor(int maxPercentage, int maxDurability) {
|
||||
// this.maxDefense = maxDefense;
|
||||
// this.defense = maxDefense;
|
||||
this.maxPercentage = maxPercentage;
|
||||
this.defensePercentage = maxPercentage;
|
||||
this.maxDurability = maxDurability;
|
||||
this.durability = maxDurability;
|
||||
}
|
||||
|
||||
|
||||
public void setMaxDurability(int maxDurability)
|
||||
{
|
||||
this.maxDurability = maxDurability;
|
||||
}
|
||||
|
||||
public int getMaxDurability() {
|
||||
return maxDurability;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void checkBreak() {
|
||||
if (durability <= 0) {
|
||||
isBroke = true;
|
||||
defense = 0;
|
||||
defensePercentage = 0;
|
||||
System.out.println("Your armor broke!");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||
public void repair() {
|
||||
isBroke = false;
|
||||
defense = maxDefense;
|
||||
defensePercentage = maxPercentage;
|
||||
durability = maxDurability;
|
||||
}
|
||||
|
||||
public int getDefense() {
|
||||
public int getDefense(int damage) {
|
||||
int defense = (defensePercentage * damage) / 100;
|
||||
this.defensePercentage -= (10 * this.defensePercentage) / 100;
|
||||
reduceDurability(15);
|
||||
return defense;
|
||||
|
||||
}
|
||||
|
||||
public int getDurability() {
|
||||
@@ -39,4 +63,35 @@ public abstract class Armor {
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
}
|
||||
|
||||
public void setBroke(boolean broke) {
|
||||
isBroke = broke;
|
||||
}
|
||||
|
||||
public void setDurability(int durability) {
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
public void reduceDurability(int percentage)
|
||||
{
|
||||
if(durability < percentage)
|
||||
{
|
||||
this.durability = 0;
|
||||
}
|
||||
else {
|
||||
this.durability -= (percentage * this.durability) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxPercentage(int maxPercentage) {
|
||||
this.maxPercentage = maxPercentage;
|
||||
}
|
||||
|
||||
public int getMaxPercentage() {
|
||||
return maxPercentage;
|
||||
}
|
||||
|
||||
public int getDefensePercentage() {
|
||||
return defensePercentage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class AssassineArmor extends Armor{
|
||||
|
||||
private int dodgeChance;
|
||||
|
||||
|
||||
|
||||
|
||||
public AssassineArmor() {
|
||||
super(12, 100);
|
||||
this.dodgeChance = 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefense(int damage) {
|
||||
if(new Random().nextInt(100) < dodgeChance)
|
||||
{
|
||||
System.out.println("Assassin dodged the Hit!");
|
||||
super.reduceDurability(20);
|
||||
return damage;
|
||||
}
|
||||
else {
|
||||
return super.getDefense(damage);
|
||||
}
|
||||
}
|
||||
|
||||
public int getDodgeChance() {
|
||||
return dodgeChance;
|
||||
}
|
||||
|
||||
public void setDodgeChance(int dodgeChance) {
|
||||
this.dodgeChance = dodgeChance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
public class KnightArmor extends Armor {
|
||||
|
||||
public KnightArmor() {
|
||||
super(80, 100);
|
||||
}
|
||||
|
||||
// public void useAsWeapon(Entity target) {
|
||||
// //it will useAsWeapon the Knight armor as weapon
|
||||
// target.takeDamage(super.getDurability());
|
||||
// super.setBroke(true);
|
||||
// }
|
||||
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Wizard;
|
||||
|
||||
public class WizardArmor extends Armor{
|
||||
//Reflects enemy attacks back to itself.
|
||||
//you get mana bonus
|
||||
|
||||
private int bonusPercent;
|
||||
private int reflectPercent;
|
||||
|
||||
public WizardArmor() {
|
||||
super(10, 75);
|
||||
this.bonusPercent = 15;
|
||||
this.reflectPercent = 20;
|
||||
}
|
||||
|
||||
|
||||
public int getBonusPercent() {
|
||||
return bonusPercent;
|
||||
}
|
||||
|
||||
public void setBonusPercent(int bonusPercent) {
|
||||
this.bonusPercent = bonusPercent;
|
||||
}
|
||||
|
||||
public int getReflectPercent() {
|
||||
return reflectPercent;
|
||||
}
|
||||
|
||||
public void setReflectPercent(int reflectPercent) {
|
||||
this.reflectPercent = reflectPercent;
|
||||
}
|
||||
|
||||
public int getBonus(Wizard w)
|
||||
{
|
||||
return (bonusPercent*w.getMaxMP()) / 100;
|
||||
}
|
||||
|
||||
public void reflect(Entity attacker, int damage)
|
||||
{
|
||||
|
||||
System.out.printf( Colors.ORANGE + "%d" + Colors.RESET + " of damage reflected.\n", (reflectPercent*damage) / 100);
|
||||
attacker.takeDamage((reflectPercent*damage) / 100);
|
||||
super.reduceDurability(12);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,46 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Consumable {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
private String name;
|
||||
private int value;
|
||||
int numberOf;
|
||||
private final String targetType;
|
||||
public Consumable(String name, int value, String targetType) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.targetType = targetType;
|
||||
this.numberOf = 1;
|
||||
}
|
||||
|
||||
public abstract void use(Entity entity);
|
||||
public abstract String toString();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public String getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
public void addOne()
|
||||
{
|
||||
numberOf++;
|
||||
}
|
||||
public void reduceOne(){numberOf--;}
|
||||
|
||||
public int getNumberOf() {
|
||||
return numberOf;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Dragon;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
public class CursedDagger extends Consumable{
|
||||
|
||||
public CursedDagger() {
|
||||
super("Cursed Dagger", 80, "Enemy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity entity) {
|
||||
Enemy e = (Enemy) entity;
|
||||
if(!(entity instanceof Dragon))
|
||||
{
|
||||
if (new Random().nextInt(100) < 30) {
|
||||
System.out.println("Cursed Dagger strikes true!");
|
||||
System.out.println("Enemy " + Colors.RED + "died" + Colors.RESET + "instantly.");
|
||||
e.setHp(0);
|
||||
} else {
|
||||
System.out.println("Cursed dagger fails.");
|
||||
e.takeDamage(10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Cursed Dagger has no effect on Dragon");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cursed Dagger:\n" + Colors.COIN + "80 coins" +Colors.RESET +"\n30% chance to instantly kill a enemy(do not work for dragon). if it fails, deals 10 damage.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class ElixirOfLife extends Consumable{
|
||||
|
||||
|
||||
public ElixirOfLife() {
|
||||
super("Elixir Of Life", 100, "Player");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity entity) {
|
||||
System.out.println(Colors.RED +"Life" +Colors.RESET+ " and " + Colors.BLUE+ "Mana"+ Colors.RESET+ "restored.");
|
||||
Player p = (Player) entity;
|
||||
p.setHp(p.getMaxHP());
|
||||
p.setMp(p.getMaxMP());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Elixir Of Life:\n" + Colors.COIN + "100 coins" +Colors.RESET +"\nFully restores HP and Mana.";
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
|
||||
public class GoblinGland extends Consumable{
|
||||
public GoblinGland() {
|
||||
super("Goblin Gland", 15, "Enemy");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity entity) {
|
||||
System.out.println("Enemy is confused!");
|
||||
Enemy e = (Enemy) entity;
|
||||
e.setConfuse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Goblin Gland:\n" + Colors.COIN + "15 coins" +Colors.RESET +"\nThrow to confuse an enemy for 1 turn(They miss their attack).";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
public class HealthPotion extends Consumable{
|
||||
|
||||
public HealthPotion() {
|
||||
super("Health Potion", 20, "Player");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity entity) {
|
||||
System.out.println("You drink The potion. +20 " + Colors.HEAL + "HP" + Colors.RESET + ".");
|
||||
Player p = (Player) entity;
|
||||
p.setHp(p.getHp() + 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Health Potion:\n" + Colors.COIN + "20 coins" +Colors.RESET +"\nRestores 30 HP instantly.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Skeleton;
|
||||
import org.project.entity.enemies.Vampire;
|
||||
|
||||
public class HolyWater extends Consumable{
|
||||
|
||||
public HolyWater() {
|
||||
super("Holy Water", 40, "Enemy");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity entity) {
|
||||
if(entity instanceof Skeleton || entity instanceof Vampire)
|
||||
{
|
||||
System.out.println("Holy water burns the enemy!");
|
||||
entity.takeDamage(50);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("You can't use Holy Water on non-Skeleton|Vampire enemy!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Holy water:\n" + Colors.COIN + "40 coins" +Colors.RESET + "\nDeals 50 holy damage to undead(Skeleton, Vampire).";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
public class ManaPotion extends Consumable{
|
||||
public ManaPotion() {
|
||||
super("Mana Potion", 20, "Player");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity entity) {
|
||||
Player p = (Player) entity;
|
||||
System.out.println("You drink The potion. +20 " + Colors.BLUE + "Mana" + Colors.RESET + ".");
|
||||
p.setMp(p.getMp() + 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Mana Potion:\n" +Colors.COIN + "20 coins" +Colors.RESET +"\nRestores 20 MP instantly";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.Colors;
|
||||
import org.project.entity.players.Assassin;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class AssassineWeapon extends Weapon{
|
||||
|
||||
private int silenceChance;
|
||||
private int bleedChance;
|
||||
private int bleedDamage;
|
||||
private int bleedingRound;
|
||||
|
||||
|
||||
public AssassineWeapon() {
|
||||
super(45, 55);
|
||||
// this.silenceChance = 14;
|
||||
this.bleedChance = 30;
|
||||
this.bleedDamage = 10;
|
||||
this.bleedingRound = 1;
|
||||
}
|
||||
|
||||
public Boolean bleed()
|
||||
{
|
||||
return new Random().nextInt(100) < bleedChance;
|
||||
}
|
||||
|
||||
public int criticalHit()
|
||||
{
|
||||
|
||||
return 3*super.getDamage();
|
||||
}
|
||||
|
||||
// public Boolean silence()
|
||||
// {
|
||||
// return new Random().nextInt(100) < silenceChance;
|
||||
// }
|
||||
|
||||
public int getBleedingRound() {
|
||||
return bleedingRound;
|
||||
}
|
||||
|
||||
public void setBleedingRound(int bleedingRound) {
|
||||
this.bleedingRound = bleedingRound;
|
||||
}
|
||||
|
||||
public int getBleedChance() {
|
||||
return bleedChance;
|
||||
}
|
||||
|
||||
public void setBleedChance(int bleedChance) {
|
||||
this.bleedChance = bleedChance;
|
||||
}
|
||||
|
||||
public int getBleedDamage() {
|
||||
return bleedDamage;
|
||||
}
|
||||
|
||||
public void setBleedDamage(int bleedDamage) {
|
||||
this.bleedDamage = bleedDamage;
|
||||
}
|
||||
//
|
||||
// public int getSilenceChance() {
|
||||
// return silenceChance;
|
||||
// }
|
||||
//
|
||||
// public void setSilenceChance(int silenceChance) {
|
||||
// this.silenceChance = silenceChance;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public void manaGain(Assassin assassin, int amount)
|
||||
{
|
||||
System.out.printf("%d of damage gained as " + Colors.BLUE + "Mana.\n" + Colors.RESET, amount);
|
||||
assassin.fillMana(amount);
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,29 @@ import org.project.entity.Entity;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
public class Sword extends Weapon {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
int abilityCharge;
|
||||
|
||||
private int specialDamage;
|
||||
public Sword() {
|
||||
|
||||
super(65, 50);
|
||||
this.specialDamage = 85;
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
|
||||
|
||||
public int getSpecialDamage() {
|
||||
return specialDamage;
|
||||
}
|
||||
|
||||
public void setSpecialDamage(int specialDamage) {
|
||||
this.specialDamage = specialDamage;
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Weapon {
|
||||
public abstract class Weapon{
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
@@ -16,15 +14,22 @@ public abstract class Weapon {
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
target.takeDamage(damage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
|
||||
public void setManaCost(int manaCost) {
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
public int getManaCost() {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public class WizardWeapon extends Weapon{
|
||||
public WizardWeapon() {
|
||||
super(35, 65);
|
||||
}
|
||||
|
||||
public int tripleAttack()
|
||||
{
|
||||
return 3*super.getDamage();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,124 @@
|
||||
package org.project.location;
|
||||
|
||||
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 java.util.ArrayList;
|
||||
|
||||
public class Location {
|
||||
private String name;
|
||||
// private Boolean isDiscovered;
|
||||
private int skeleton = 0;
|
||||
private int vampire = 0;
|
||||
private int goblin = 0;
|
||||
|
||||
|
||||
|
||||
private ArrayList<Enemy> enemies;
|
||||
// private ArrayList<Location> locations;
|
||||
|
||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||
this.locations = locations;
|
||||
this.enemies = enemies;
|
||||
|
||||
|
||||
// ArrayList<Location> locations
|
||||
public Location(String name) {
|
||||
// this.locations = locations;
|
||||
this.name = name;
|
||||
this.enemies = new ArrayList<>();
|
||||
// this.isDiscovered = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getGoblin() {
|
||||
return goblin;
|
||||
}
|
||||
|
||||
public int getVampire() {
|
||||
return vampire;
|
||||
}
|
||||
|
||||
public int getSkeleton() {
|
||||
return skeleton;
|
||||
}
|
||||
|
||||
public void addEnemy(Enemy enemy)
|
||||
{
|
||||
enemies.add(enemy);
|
||||
if(enemy instanceof Skeleton)
|
||||
{
|
||||
skeleton++;
|
||||
} else if (enemy instanceof Vampire)
|
||||
{
|
||||
vampire++;
|
||||
}
|
||||
else if(enemy instanceof Goblin)
|
||||
{
|
||||
goblin++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void defeatEnemy(Enemy enemy)
|
||||
{
|
||||
enemies.remove(enemy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(name).append("\n").append("Enemies: \n");
|
||||
if(skeleton > 0)
|
||||
{
|
||||
s.append("Skeleton: ").append(skeleton).append("\n");
|
||||
}
|
||||
if(vampire > 0)
|
||||
{
|
||||
s.append("Vampire: ").append(vampire).append("\n");
|
||||
}
|
||||
if(goblin > 0)
|
||||
{
|
||||
s.append("Goblin: ").append(goblin).append("\n");
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public boolean checkLives()
|
||||
{
|
||||
for (Enemy enemy : enemies) {
|
||||
if (enemy.isAlive()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetLives()
|
||||
{
|
||||
for (Enemy enemy : enemies) {
|
||||
enemy.setHp(enemy.getMaxHP());
|
||||
enemy.setHaveBleed(false);
|
||||
enemy.setBleedingRound(0);
|
||||
}
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<Location> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
// public ArrayList<Location> getLocations() {
|
||||
// return locations;
|
||||
// }
|
||||
|
||||
|
||||
// public Boolean isDiscovered() {
|
||||
// return isDiscovered;
|
||||
// }
|
||||
//
|
||||
// public void setDiscovered(Boolean discovered) {
|
||||
// isDiscovered = discovered;
|
||||
// }
|
||||
|
||||
public ArrayList<Enemy> getEnemies() {
|
||||
return enemies;
|
||||
|
||||
Reference in New Issue
Block a user