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