update
This commit is contained in:
@@ -17,7 +17,9 @@ public abstract class Enemy implements Entity {
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.maxHP = hp;
|
||||
this.mp = mp;
|
||||
this.maxMP = mp;
|
||||
this.weapon = weapon;
|
||||
}
|
||||
//implement this in Main
|
||||
@@ -31,18 +33,21 @@ public abstract class Enemy implements Entity {
|
||||
|
||||
@Override
|
||||
public void attack(Entity target, double multiplier) {
|
||||
if (checkTargetAbility((Player) target)){
|
||||
System.out.println("target is using special ability");
|
||||
return;
|
||||
}
|
||||
double damage = multiplier * weapon.getDamage();
|
||||
if (target.isDefending()) {
|
||||
target.takeDamage( (int) (damage * (1 - target.getDefendRate())));
|
||||
target.setDefending(false);
|
||||
}
|
||||
else {
|
||||
target.takeDamage((int) damage);
|
||||
if (getMP() >= weapon.getManaCost()) {
|
||||
if (checkTargetAbility((Player) target)) {
|
||||
System.out.println("target is using special ability");
|
||||
return;
|
||||
}
|
||||
double damage = multiplier * weapon.getDamage();
|
||||
if (target.isDefending()) {
|
||||
target.takeDamage((int) (damage * (1 - target.getDefendRate())));
|
||||
target.setDefending(false);
|
||||
} else {
|
||||
target.takeDamage((int) damage);
|
||||
}
|
||||
setMP(getMP() - weapon.getManaCost());
|
||||
}
|
||||
else System.out.println("not enough mana");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,13 +11,7 @@ public class Goblin extends Enemy{
|
||||
|
||||
@Override
|
||||
public void attack(Entity target, double multiplier) {
|
||||
if (getMP() > 5) {
|
||||
super.attack(target,2);
|
||||
setMP(getMP() - 5);
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
}
|
||||
super.attack(target,2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,13 +13,7 @@ public class Skeleton extends Enemy{
|
||||
|
||||
@Override
|
||||
public void attack(Entity target, double multiplier) {
|
||||
if (getMP() > 5) {
|
||||
super.attack(target,1);
|
||||
setMP(getMP() - 5);
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
}
|
||||
super.attack(target,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,14 +12,7 @@ public class Vampire extends Enemy{
|
||||
|
||||
@Override
|
||||
public void attack(Entity target, double multiplier) {
|
||||
if (getMP() > 5) {
|
||||
super.attack(target,1.5);
|
||||
setMP(getMP() - 5);
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
}
|
||||
|
||||
super.attack(target,1.5);
|
||||
double damage = weapon.getDamage() * multiplier;
|
||||
if (target.isDefending()) {
|
||||
heal( (int) (.3 * (damage * (1 - target.getDefendRate()))));
|
||||
|
||||
@@ -24,9 +24,9 @@ public class Assassin extends Player {
|
||||
setUsingSpecialAbility(false);
|
||||
}
|
||||
|
||||
else if (getMP() >= 8) {
|
||||
else if (getMP() >= weapon.getManaCost()) {
|
||||
attack(target, 2.5);
|
||||
setMP(getMP() - 8);
|
||||
setMP(getMP() - weapon.getManaCost());
|
||||
} else {
|
||||
System.out.println("Not enough MP");
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ public class Knight extends Player {
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMP() >= 8) {
|
||||
if (getMP() >= weapon.getManaCost()) {
|
||||
attack(target, 1.8);
|
||||
setMP(getMP() - 8);
|
||||
setMP(getMP() - weapon.getManaCost());
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
|
||||
@@ -20,8 +20,9 @@ public abstract class Player implements Entity, combatOptions {
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.maxHP = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.maxMP = mp;
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ public class Wizard extends Player{
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMP() >= 5) {
|
||||
if (getMP() >= weapon.getManaCost()) {
|
||||
attack(target, 1.6);
|
||||
setMP(getMP() - 5);
|
||||
setMP(getMP() - weapon.getManaCost());
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
|
||||
@@ -8,10 +8,6 @@ public abstract class Weapon implements Item {
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user