develop #1
@@ -1,7 +1,7 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
void attack(Entity target);
|
||||
void attack(Entity target, double multiplier);
|
||||
|
||||
void defend();
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface Entity {
|
||||
|
||||
int getMaxMP();
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
boolean isDefending();
|
||||
|
||||
void setDefending(boolean defending);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
|
||||
public abstract class Player implements Entity, combatOptions {
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
@@ -13,6 +13,8 @@ public abstract class Player {
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
private boolean defending = false;
|
||||
private double defendRate;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
@@ -24,15 +26,37 @@ public abstract class Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
public void attack(Entity target,double multiplier) {
|
||||
double finalDamage = multiplier * weapon.getDamage();
|
||||
if (target.isDefending()) {
|
||||
target.takeDamage((int) ( finalDamage * defendRate));
|
||||
target.setDefending(false);
|
||||
}
|
||||
else {
|
||||
target.takeDamage((int) ( finalDamage ));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lightAttack(Entity target){
|
||||
attack(target,1);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target){
|
||||
attack(target,2);
|
||||
mp -= weapon.getManaCost();
|
||||
};
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
setDefending(true);
|
||||
mp -= 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAbility(){};
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
@@ -45,6 +69,8 @@ public abstract class Player {
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
|
||||
mp -= 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,4 +112,10 @@ public abstract class Player {
|
||||
return armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefending() { return defending; }
|
||||
|
||||
@Override
|
||||
public void setDefending(boolean defending) { this.defending = defending; }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user