update players project
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Knight;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Enemy {
|
||||
|
||||
public abstract class Enemy implements Entity {
|
||||
Weapon weapon;
|
||||
private int hp;
|
||||
private int mp;
|
||||
@@ -31,4 +34,13 @@ public abstract class Enemy {
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
private boolean checkTargetAbility(Player target) {
|
||||
if (target instanceof Knight) {
|
||||
boolean check = target.getUsingSpecialAbility();
|
||||
return check;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,18 @@ public class Assassin extends Player {
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMP() >= 8) {
|
||||
attack(target, 2.5);
|
||||
setMP(getMP() - 8);
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
if (getUsingSpecialAbility()) {
|
||||
attack(target, 3);
|
||||
setUsingSpecialAbility(false);
|
||||
}
|
||||
|
||||
else if (getMP() >= 8) {
|
||||
attack(target, 2.5);
|
||||
setMP(getMP() - 8);
|
||||
} else {
|
||||
System.out.println("Not enough MP");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,10 +47,9 @@ public class Assassin extends Player {
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
if (getMP() >= 20) {
|
||||
setDefendRate(1);
|
||||
defend();
|
||||
setUsingSpecialAbility(true);
|
||||
System.out.println("your next heavy-attack will be free!");
|
||||
setMP(getMP() - 20);
|
||||
//incomplete
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
@@ -63,5 +67,13 @@ public class Assassin extends Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
if (getUsingSpecialAbility()) {
|
||||
System.out.println("player using special ability");
|
||||
}
|
||||
else super.takeDamage(damage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ public class Knight extends Player {
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
if (getMP() >= 20) {
|
||||
setUsingSpecialAbility(true);
|
||||
attack(target, 2);
|
||||
setMP(getMP() - 20);
|
||||
//incomplete
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
|
||||
@@ -15,6 +15,7 @@ public abstract class Player implements Entity, combatOptions {
|
||||
private int maxMP;
|
||||
private boolean defending = false;
|
||||
private double defendRate;
|
||||
private boolean isUsingSpecialAbility = false;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
@@ -56,7 +57,7 @@ public abstract class Player implements Entity, combatOptions {
|
||||
public void takeDamage(int damage) {
|
||||
|
||||
int finalDamage = damage - armor.getDefense();
|
||||
setHP(-finalDamage);
|
||||
setHP(getHP() - finalDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,4 +143,8 @@ public abstract class Player implements Entity, combatOptions {
|
||||
@Override
|
||||
public void setDefendRate(double defendRate) { this.defendRate = defendRate; }
|
||||
|
||||
public boolean getUsingSpecialAbility() { return isUsingSpecialAbility; }
|
||||
|
||||
public void setUsingSpecialAbility(boolean isUsingSpecialAbility) { this.isUsingSpecialAbility = isUsingSpecialAbility; }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user