implement Player class
This commit is contained in:
@@ -4,50 +4,35 @@ import org.project.entity.Entity;
|
|||||||
import org.project.item.armors.Armor;
|
import org.project.item.armors.Armor;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public abstract class Player {
|
public abstract class Player extends Entity{
|
||||||
protected String name;
|
protected String name;
|
||||||
Weapon weapon;
|
private Armor armor;
|
||||||
Armor armor;
|
|
||||||
private int hp;
|
|
||||||
private int maxHP;
|
|
||||||
private int mp;
|
private int mp;
|
||||||
private int maxMP;
|
private int maxMP;
|
||||||
|
private boolean defensing;
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
public Player(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
|
||||||
|
super(weapon, hp, maxHP);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.hp = hp;
|
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxMP = maxMP;
|
||||||
this.weapon = weapon;
|
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
|
|
||||||
|
defensing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void lightAttack(Entity target) {
|
||||||
public void attack(Entity target) {
|
target.takeDamage(super.getWeapon().getDamage());
|
||||||
target.takeDamage(weapon.getDamage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void defend() {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage - armor.getDefense();
|
if(!isDefensing()){
|
||||||
}
|
super.takeDamage(damage);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void heal(int health) {
|
|
||||||
hp += health;
|
|
||||||
if (hp > maxHP) {
|
|
||||||
hp = maxHP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fillMana(int mana) {
|
public void fillMana(int mana) {
|
||||||
mp += mana;
|
mp += mana;
|
||||||
if (mp > maxMP) {
|
if (mp > maxMP) {
|
||||||
@@ -55,35 +40,24 @@ public abstract class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean reduceMana(int amount) {
|
||||||
public String getName() {
|
if(mp - amount >= 0) {
|
||||||
return name;
|
mp -= amount;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHp() {
|
|
||||||
return hp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxHP() {
|
|
||||||
return maxHP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMp() {
|
public String getName() { return name; }
|
||||||
return mp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public int getMp() { return mp; }
|
||||||
public int getMaxMP() {
|
|
||||||
return maxMP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Weapon getWeapon() {
|
public int getMaxMP() { return maxMP; }
|
||||||
return weapon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Armor getArmor() {
|
public Armor getArmor() { return armor; }
|
||||||
return armor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public boolean isDefensing() { return defensing; }
|
||||||
|
public void setDefensing(boolean defensing) {this.defensing = defensing; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user