This commit is contained in:
2026-05-06 23:57:00 +03:30
parent d6d2bdc24f
commit 0a6c6034a3
28 changed files with 27 additions and 44 deletions
@@ -17,7 +17,9 @@ public abstract class Enemy implements Entity {
public Enemy(int hp, int mp, Weapon weapon) { public Enemy(int hp, int mp, Weapon weapon) {
this.hp = hp; this.hp = hp;
this.maxHP = hp;
this.mp = mp; this.mp = mp;
this.maxMP = mp;
this.weapon = weapon; this.weapon = weapon;
} }
//implement this in Main //implement this in Main
@@ -31,18 +33,21 @@ public abstract class Enemy implements Entity {
@Override @Override
public void attack(Entity target, double multiplier) { public void attack(Entity target, double multiplier) {
if (checkTargetAbility((Player) target)){ if (getMP() >= weapon.getManaCost()) {
System.out.println("target is using special ability"); if (checkTargetAbility((Player) target)) {
return; System.out.println("target is using special ability");
} return;
double damage = multiplier * weapon.getDamage(); }
if (target.isDefending()) { double damage = multiplier * weapon.getDamage();
target.takeDamage( (int) (damage * (1 - target.getDefendRate()))); if (target.isDefending()) {
target.setDefending(false); target.takeDamage((int) (damage * (1 - target.getDefendRate())));
} target.setDefending(false);
else { } else {
target.takeDamage((int) damage); target.takeDamage((int) damage);
}
setMP(getMP() - weapon.getManaCost());
} }
else System.out.println("not enough mana");
} }
@Override @Override
@@ -11,13 +11,7 @@ public class Goblin extends Enemy{
@Override @Override
public void attack(Entity target, double multiplier) { public void attack(Entity target, double multiplier) {
if (getMP() > 5) { super.attack(target,2);
super.attack(target,2);
setMP(getMP() - 5);
}
else {
System.out.println("Not enough MP");
}
} }
@Override @Override
@@ -13,13 +13,7 @@ public class Skeleton extends Enemy{
@Override @Override
public void attack(Entity target, double multiplier) { public void attack(Entity target, double multiplier) {
if (getMP() > 5) { super.attack(target,1);
super.attack(target,1);
setMP(getMP() - 5);
}
else {
System.out.println("Not enough MP");
}
} }
@Override @Override
@@ -12,14 +12,7 @@ public class Vampire extends Enemy{
@Override @Override
public void attack(Entity target, double multiplier) { public void attack(Entity target, double multiplier) {
if (getMP() > 5) { super.attack(target,1.5);
super.attack(target,1.5);
setMP(getMP() - 5);
}
else {
System.out.println("Not enough MP");
}
double damage = weapon.getDamage() * multiplier; double damage = weapon.getDamage() * multiplier;
if (target.isDefending()) { if (target.isDefending()) {
heal( (int) (.3 * (damage * (1 - target.getDefendRate())))); heal( (int) (.3 * (damage * (1 - target.getDefendRate()))));
@@ -24,9 +24,9 @@ public class Assassin extends Player {
setUsingSpecialAbility(false); setUsingSpecialAbility(false);
} }
else if (getMP() >= 8) { else if (getMP() >= weapon.getManaCost()) {
attack(target, 2.5); attack(target, 2.5);
setMP(getMP() - 8); setMP(getMP() - weapon.getManaCost());
} else { } else {
System.out.println("Not enough MP"); System.out.println("Not enough MP");
} }
@@ -19,9 +19,9 @@ public class Knight extends Player {
@Override @Override
public void heavyAttack(Entity target) { public void heavyAttack(Entity target) {
if (getMP() >= 8) { if (getMP() >= weapon.getManaCost()) {
attack(target, 1.8); attack(target, 1.8);
setMP(getMP() - 8); setMP(getMP() - weapon.getManaCost());
} }
else { else {
System.out.println("Not enough MP"); 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) { public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
this.name = name; this.name = name;
this.hp = hp; this.hp = hp;
this.maxHP = hp;
this.mp = mp; this.mp = mp;
this.maxMP = mp;
this.weapon = weapon; this.weapon = weapon;
this.armor = armor; this.armor = armor;
} }
@@ -18,9 +18,9 @@ public class Wizard extends Player{
@Override @Override
public void heavyAttack(Entity target) { public void heavyAttack(Entity target) {
if (getMP() >= 5) { if (getMP() >= weapon.getManaCost()) {
attack(target, 1.6); attack(target, 1.6);
setMP(getMP() - 5); setMP(getMP() - weapon.getManaCost());
} }
else { else {
System.out.println("Not enough MP"); System.out.println("Not enough MP");
@@ -8,10 +8,6 @@ public abstract class Weapon implements Item {
private int damage; private int damage;
private int manaCost; private int manaCost;
/*
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
*/
public Weapon(int damage, int manaCost) { public Weapon(int damage, int manaCost) {
this.damage = damage; this.damage = damage;
this.manaCost = manaCost; this.manaCost = manaCost;
Binary file not shown.