update Player and Knight class
This commit is contained in:
@@ -1,6 +1,66 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public class Knight {
|
import org.project.entity.Entity;
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
public class Knight extends Player {
|
||||||
|
|
||||||
|
public Knight(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||||
|
super(name, hp, mp, weapon, armor);
|
||||||
|
setDefendRate(.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lightAttack(Entity target) {
|
||||||
|
attack(target, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heavyAttack(Entity target) {
|
||||||
|
if (getMp() >= 8) {
|
||||||
|
attack(target, 1.8);
|
||||||
|
setMp(getMp() - 8);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough MP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void defend() {
|
||||||
|
if (getMp() >= 4) {
|
||||||
|
super.defend();
|
||||||
|
setMp(getMp() - 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough MP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void specialAbility(Entity target) {
|
||||||
|
if (getMp() >= 20) {
|
||||||
|
attack(target, 2);
|
||||||
|
setMp(getMp() - 20);
|
||||||
|
//incomplete
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough MP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
if (getMp() >= 5) {
|
||||||
|
super.heal(health);
|
||||||
|
setMp(getMp() - 5);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough MP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,36 +26,30 @@ public abstract class Player implements Entity, combatOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attack(Entity target,double multiplier) {
|
public void attack(Entity target, double multiplier) {
|
||||||
double finalDamage = multiplier * weapon.getDamage();
|
double damage = multiplier * weapon.getDamage();
|
||||||
if (target.isDefending()) {
|
if (target.isDefending()) {
|
||||||
target.takeDamage((int) ( finalDamage * defendRate));
|
target.takeDamage( (int) (damage * (1 - getDefendRate())));
|
||||||
target.setDefending(false);
|
target.setDefending(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target.takeDamage((int) ( finalDamage ));
|
target.takeDamage((int) damage);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void lightAttack(Entity target){
|
|
||||||
attack(target,1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heavyAttack(Entity target){
|
public abstract void lightAttack(Entity target);
|
||||||
attack(target,2);
|
|
||||||
mp -= weapon.getManaCost();
|
@Override
|
||||||
|
public abstract void heavyAttack(Entity target);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void defend(){
|
||||||
|
setDefending(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defend() {
|
public abstract void specialAbility(Entity target);
|
||||||
setDefending(true);
|
|
||||||
mp -= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void specialAbility(){};
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,8 +63,6 @@ public abstract class Player implements Entity, combatOptions {
|
|||||||
if (hp > maxHP) {
|
if (hp > maxHP) {
|
||||||
hp = maxHP;
|
hp = maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp -= 20;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,6 +91,10 @@ public abstract class Player implements Entity, combatOptions {
|
|||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMp(int mp) {
|
||||||
|
this.mp = mp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
return maxMP;
|
return maxMP;
|
||||||
@@ -118,4 +114,8 @@ public abstract class Player implements Entity, combatOptions {
|
|||||||
@Override
|
@Override
|
||||||
public void setDefending(boolean defending) { this.defending = defending; }
|
public void setDefending(boolean defending) { this.defending = defending; }
|
||||||
|
|
||||||
|
public double getDefendRate() { return defendRate; }
|
||||||
|
|
||||||
|
public void setDefendRate(double defendRate) { this.defendRate = defendRate; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ public interface combatOptions {
|
|||||||
void lightAttack(Entity target);
|
void lightAttack(Entity target);
|
||||||
void heavyAttack(Entity target);
|
void heavyAttack(Entity target);
|
||||||
void defend();
|
void defend();
|
||||||
void heal();
|
void heal(int health);
|
||||||
void specialAbility();
|
void specialAbility(Entity target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package org.project.item.weapons;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public abstract class Weapon {
|
public abstract class Weapon implements Item {
|
||||||
private int damage;
|
private int damage;
|
||||||
private int manaCost;
|
private int manaCost;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user