complete everything and last check

This commit is contained in:
2026-05-11 12:38:46 +03:30
parent 78d4bedb08
commit 1bdad87d02
18 changed files with 565 additions and 186 deletions
@@ -1,6 +1,6 @@
package org.project.entity;
public interface Entity {
/*public interface Entity {
void attack(Entity target);
void defend();
@@ -18,4 +18,72 @@ public interface Entity {
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
public abstract class Entity {
protected String name;
protected int hp;
protected int mp;
protected int maxHP;
protected int maxMP;
public Entity(String name, int hp, int mp) {
this.name = name;
this.hp = hp;
this.mp = mp;
this.maxHP = hp;
this.maxMP = mp;
}
public abstract void attack(Entity target);
public abstract void defend();
public abstract void heal(int health);
public void fillMana(int mana) {
mp += mana;
if (mp > maxMP) {
mp = maxMP;
}
}
public void takeDamage(int damage) {
hp -= damage;
if (hp < 0) {
hp = 0;
}
}
public boolean isAlive() {
return hp > 0;
}
public int getMaxHP() {
return maxHP;
}
public int getMaxMP() {
return maxMP;
}
public int getHp() {
return hp;
}
public int getMp() {
return mp;
}
public String getName() {
return name;
}
}