develop #2

Open
Fateme_Azizi wants to merge 21 commits from develop into main
Showing only changes of commit afc563822e - Show all commits
@@ -1,43 +1,32 @@
package org.project.entity; package org.project.entity;
import org.project.item.weapons.Weapon;
public abstract class Entity { public abstract class Entity {
private Weapon weapon;
private int hp; private int hp;
private int maxHP; private final int maxHP;
public Entity(Weapon weapon, int hp, int maxHP) { public Entity(int maxHP) {
this.weapon = weapon; this.hp = maxHP;
this.hp = hp;
this.maxHP = maxHP; this.maxHP = maxHP;
} }
public boolean isAlive() { public boolean isAlive() {
if(hp>0) return hp > 0;
return true;
return false;
} }
public abstract void attack(Entity target);
public void heal(int health) { public void heal(int health) {
hp += health; hp += health;
if (hp > maxHP) { if (hp > maxHP)
hp = maxHP; hp = maxHP;
} }
}
public void takeDamage(int damage) {hp -= weapon.getDamage();} public void takeDamage(int damage) {
hp -= damage;
if(hp<0) hp = 0;
}
public int getMaxHP() {return maxHP;} public int getMaxHP() {return maxHP;}
public int getHP() {return hp;} public int getHP() {return hp;}
public Weapon getWeapon() {return weapon;}
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
} }