Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sk.tuke.oop.game.actors;
- import java.lang.reflect.Array;
- import java.util.List;
- public class Health {
- @FunctionalInterface
- public interface ExhaustionEffect {
- void apply();
- }
- private int curHealth;
- private int maxHealth;
- private List list;
- public void onExhaustion(ExhaustionEffect callback){
- list.add(callback);
- }
- public Health(int curHealth, int maxHealth){
- this.curHealth = curHealth;
- this.maxHealth = maxHealth;
- }
- public Health(int health){
- this.curHealth = health;
- this.maxHealth = health;
- }
- public int getValue(){
- return this.curHealth;
- }
- public void refill(int amount){
- this.curHealth += amount;
- if(this.curHealth > this.maxHealth){
- this.curHealth = this.maxHealth;
- }
- }
- public void restore(){
- this.curHealth = this.maxHealth;
- }
- public void drain(int amount){
- this.curHealth -= amount;
- if(this.curHealth < 0){
- this.curHealth = 0;
- }
- }
- for(ExhaustionEffect callback : list){
- }
- public void exhaust(){
- this.curHealth = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement