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