implement Entity class
This commit is contained in:
@@ -1,19 +1,41 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
public interface Entity {
|
import org.project.item.weapons.Weapon;
|
||||||
void attack(Entity target);
|
|
||||||
|
|
||||||
void defend();
|
public abstract class Entity {
|
||||||
|
|
||||||
void heal(int health);
|
private Weapon weapon;
|
||||||
|
private int hp;
|
||||||
|
private int maxHP;
|
||||||
|
|
||||||
void fillMana(int mana);
|
|
||||||
|
|
||||||
void takeDamage(int damage);
|
public Entity(Weapon weapon, int hp, int maxHP) {
|
||||||
|
this.weapon = weapon;
|
||||||
|
this.hp = hp;
|
||||||
|
this.maxHP = maxHP;
|
||||||
|
}
|
||||||
|
|
||||||
int getMaxHP();
|
public boolean isAlive() {
|
||||||
|
if(hp>0)
|
||||||
|
return true;
|
||||||
|
|
||||||
int getMaxMP();
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void attack(Entity target);
|
||||||
|
|
||||||
|
public void heal(int health) {
|
||||||
|
hp += health;
|
||||||
|
if (hp > maxHP) {
|
||||||
|
hp = maxHP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void takeDamage(int damage) {hp -= weapon.getDamage();}
|
||||||
|
|
||||||
|
public int getMaxHP() {return maxHP;}
|
||||||
|
public int getHP() {return hp;}
|
||||||
|
public Weapon getWeapon() {return weapon;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
|
|||||||
Reference in New Issue
Block a user