make code cleaner and update REDME.md
This commit is contained in:
@@ -264,7 +264,6 @@ public class Main {
|
||||
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() );
|
||||
@@ -333,7 +332,6 @@ public class Main {
|
||||
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())
|
||||
{
|
||||
@@ -384,7 +382,6 @@ public class Main {
|
||||
}
|
||||
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());
|
||||
@@ -432,7 +429,6 @@ public class Main {
|
||||
System.out.println("Good luck!");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,23 +24,7 @@ public abstract class Enemy implements Entity {
|
||||
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;
|
||||
}
|
||||
public abstract void dropKey(Player player);
|
||||
|
||||
@Override
|
||||
public boolean heal(int health) {
|
||||
@@ -52,11 +36,6 @@ public abstract class Enemy implements Entity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHp;
|
||||
}
|
||||
|
||||
public void bleed(AssassineWeapon aw)
|
||||
{
|
||||
if(haveBleed)
|
||||
@@ -74,6 +53,46 @@ public abstract class Enemy implements Entity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
|
||||
public int attack()
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@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 getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHp;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
if(hp > maxHp)
|
||||
{
|
||||
hp = maxHp;
|
||||
}
|
||||
}
|
||||
|
||||
public int getBleedingRound() {
|
||||
return bleedingRound;
|
||||
@@ -91,48 +110,17 @@ public abstract class Enemy implements Entity {
|
||||
this.haveBleed = haveBleed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
public void setConfuse(boolean confuse) {
|
||||
this.confuse = confuse;
|
||||
}
|
||||
|
||||
public int attack()
|
||||
public boolean isConfuse()
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public abstract void dropKey(Player player);
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
if(hp < 0)
|
||||
if(confuse)
|
||||
{
|
||||
hp = 0;
|
||||
confuse = false;
|
||||
return true;
|
||||
}
|
||||
System.out.printf("%s took " + Colors.RED + "%d" + Colors.RESET + " damage!\n",this.getClass().getSimpleName(), damage);
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
if(hp > maxHp)
|
||||
{
|
||||
hp = maxHp;
|
||||
}
|
||||
}
|
||||
// public int getMp() {
|
||||
// return mp;
|
||||
// }
|
||||
|
||||
// public Weapon getWeapon() {
|
||||
// return weapon;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -15,6 +15,58 @@ public class Assassin extends Player{
|
||||
super.setDamage(35);
|
||||
}
|
||||
|
||||
|
||||
@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 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 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 void levelUp() {
|
||||
if(super.getLevel() < 5) {
|
||||
@@ -77,61 +129,6 @@ public class Assassin extends Player{
|
||||
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
|
||||
|
||||
@@ -17,6 +17,20 @@ public class Knight extends Player {
|
||||
super.setDamage(40);
|
||||
}
|
||||
|
||||
@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 levelUp() {
|
||||
if(super.getLevel() < 5) {
|
||||
@@ -72,20 +86,6 @@ public class Knight extends Player {
|
||||
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();
|
||||
@@ -112,33 +112,6 @@ public class Knight extends Player {
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
@@ -28,22 +28,9 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
private Boolean goblinKey;
|
||||
private Boolean skeletonKey;
|
||||
private Boolean vampireKey;
|
||||
private int coin;// write it in constructor with right amount
|
||||
|
||||
private int coin;
|
||||
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;
|
||||
@@ -68,6 +55,64 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
target.takeDamage(damage);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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(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 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;
|
||||
}
|
||||
|
||||
public void addItem(Consumable c)
|
||||
{
|
||||
@@ -113,161 +158,10 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 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) {
|
||||
|
||||
//
|
||||
//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 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) {
|
||||
mp = maxMP;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -306,6 +200,66 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
|
||||
public void fillMana(int mana) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
mp = maxMP;
|
||||
}
|
||||
}
|
||||
|
||||
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 void addCoin(int amount)
|
||||
{
|
||||
@@ -331,6 +285,10 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
return coin;
|
||||
}
|
||||
|
||||
public void setCoin(int coin) {
|
||||
this.coin = coin;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -339,18 +297,34 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
}
|
||||
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
public void setMaxHP(int maxHP) {
|
||||
this.maxHP = maxHP;
|
||||
}
|
||||
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
}
|
||||
|
||||
public void setMp(int mp) {
|
||||
this.mp = mp;
|
||||
}
|
||||
|
||||
public void setMaxMP(int maxMP) {
|
||||
this.maxMP = maxMP;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
}
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
@@ -363,16 +337,20 @@ public abstract class Player implements Entity, ICombatActions {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(int baseDamage){this.damage = baseDamage;}
|
||||
|
||||
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 int getMaxDefense() {
|
||||
return maxDefense;
|
||||
}
|
||||
|
||||
public void setMaxDefense(int maxDefense) {
|
||||
this.maxDefense = maxDefense;
|
||||
}
|
||||
|
||||
public Boolean getSkeletonKey() {
|
||||
return skeletonKey;
|
||||
|
||||
@@ -15,6 +15,40 @@ public class Wizard extends Player{
|
||||
super.setMaxMP(super.getMp() + armor.getBonus(this));
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public void takeDamage(Entity attacker ,int damage) {
|
||||
super.takeDamage(damage);
|
||||
WizardArmor w = (WizardArmor) super.getArmor();
|
||||
w.reflect(attacker, damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void levelUp() {
|
||||
if(super.getLevel() < 5) {
|
||||
@@ -62,47 +96,11 @@ public class Wizard extends Player{
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
super.setHp(super.getMaxHP());
|
||||
super.fillMana(super.getMaxMP());
|
||||
super.getArmor().repair();
|
||||
System.out.println();
|
||||
showInf();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,37 +2,19 @@ package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
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 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;
|
||||
@@ -60,14 +42,6 @@ public abstract class Armor{
|
||||
return durability;
|
||||
}
|
||||
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
}
|
||||
|
||||
public void setBroke(boolean broke) {
|
||||
isBroke = broke;
|
||||
}
|
||||
|
||||
public void setDurability(int durability) {
|
||||
this.durability = durability;
|
||||
}
|
||||
@@ -83,6 +57,15 @@ public abstract class Armor{
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxDurability(int maxDurability)
|
||||
{
|
||||
this.maxDurability = maxDurability;
|
||||
}
|
||||
|
||||
public int getMaxDurability() {
|
||||
return maxDurability;
|
||||
}
|
||||
|
||||
public void setMaxPercentage(int maxPercentage) {
|
||||
this.maxPercentage = maxPercentage;
|
||||
}
|
||||
@@ -94,4 +77,12 @@ public abstract class Armor{
|
||||
public int getDefensePercentage() {
|
||||
return defensePercentage;
|
||||
}
|
||||
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
}
|
||||
|
||||
public void setBroke(boolean broke) {
|
||||
isBroke = broke;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,8 @@ 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;
|
||||
|
||||
@@ -8,12 +8,5 @@ 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
|
||||
}
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
|
||||
@@ -17,6 +16,19 @@ public class WizardArmor extends Armor{
|
||||
this.reflectPercent = 20;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public int getBonus(Wizard w)
|
||||
{
|
||||
return (bonusPercent*w.getMaxMP()) / 100;
|
||||
}
|
||||
|
||||
|
||||
public int getBonusPercent() {
|
||||
return bonusPercent;
|
||||
@@ -33,17 +45,4 @@ public class WizardArmor extends Armor{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public abstract class Consumable {
|
||||
private int value;
|
||||
int numberOf;
|
||||
private final String targetType;
|
||||
|
||||
public Consumable(String name, int value, String targetType) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
@@ -25,7 +26,6 @@ public abstract class Consumable {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public String getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public abstract class Consumable {
|
||||
{
|
||||
numberOf++;
|
||||
}
|
||||
|
||||
public void reduceOne(){numberOf--;}
|
||||
|
||||
public int getNumberOf() {
|
||||
|
||||
@@ -7,9 +7,6 @@ import org.project.entity.enemies.Enemy;
|
||||
public class GoblinGland extends Consumable{
|
||||
public GoblinGland() {
|
||||
super("Goblin Gland", 15, "Enemy");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,6 @@ public class HolyWater extends Consumable{
|
||||
|
||||
public HolyWater() {
|
||||
super("Holy Water", 40, "Enemy");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,10 +12,8 @@ public class AssassineWeapon extends Weapon{
|
||||
private int bleedDamage;
|
||||
private int bleedingRound;
|
||||
|
||||
|
||||
public AssassineWeapon() {
|
||||
super(45, 55);
|
||||
// this.silenceChance = 14;
|
||||
this.bleedChance = 30;
|
||||
this.bleedDamage = 10;
|
||||
this.bleedingRound = 1;
|
||||
@@ -28,14 +26,14 @@ public class AssassineWeapon extends Weapon{
|
||||
|
||||
public int criticalHit()
|
||||
{
|
||||
|
||||
return 3*super.getDamage();
|
||||
}
|
||||
|
||||
// public Boolean silence()
|
||||
// {
|
||||
// return new Random().nextInt(100) < 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);
|
||||
}
|
||||
|
||||
public int getBleedingRound() {
|
||||
return bleedingRound;
|
||||
@@ -60,20 +58,4 @@ public class AssassineWeapon extends Weapon{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ public class Sword extends Weapon {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
int abilityCharge;
|
||||
private int specialDamage;
|
||||
|
||||
public Sword() {
|
||||
|
||||
super(65, 50);
|
||||
@@ -19,6 +19,14 @@ public class Sword extends Weapon {
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
public int getSpecialDamage() {
|
||||
return specialDamage;
|
||||
@@ -27,12 +35,4 @@ public class Sword extends Weapon {
|
||||
public void setSpecialDamage(int specialDamage) {
|
||||
this.specialDamage = specialDamage;
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
target.takeDamage(getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,6 @@ public abstract class Weapon{
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
@@ -25,7 +22,6 @@ public abstract class Weapon{
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
|
||||
public void setManaCost(int manaCost) {
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
@@ -13,53 +13,14 @@ public class Location {
|
||||
private int skeleton = 0;
|
||||
private int vampire = 0;
|
||||
private int goblin = 0;
|
||||
|
||||
|
||||
|
||||
private ArrayList<Enemy> enemies;
|
||||
// private ArrayList<Location> locations;
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
@@ -103,14 +64,38 @@ public class Location {
|
||||
enemy.setBleedingRound(0);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
// public ArrayList<Location> getLocations() {
|
||||
// return locations;
|
||||
// }
|
||||
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 Boolean isDiscovered() {
|
||||
// return isDiscovered;
|
||||
|
||||
Reference in New Issue
Block a user