Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. package sk.tuke.oop.game.actors;
  2.  
  3. import java.lang.reflect.Array;
  4. import java.util.List;
  5.  
  6. public class Health {
  7.  
  8. @FunctionalInterface
  9. public interface ExhaustionEffect {
  10. void apply();
  11. }
  12.  
  13. private int curHealth;
  14. private int maxHealth;
  15. private List list;
  16. public void onExhaustion(ExhaustionEffect callback){
  17. list.add(callback);
  18.  
  19. }
  20. public Health(int curHealth, int maxHealth){
  21. this.curHealth = curHealth;
  22. this.maxHealth = maxHealth;
  23.  
  24. }
  25. public Health(int health){
  26. this.curHealth = health;
  27. this.maxHealth = health;
  28. }
  29. public int getValue(){
  30. return this.curHealth;
  31. }
  32. public void refill(int amount){
  33. this.curHealth += amount;
  34. if(this.curHealth > this.maxHealth){
  35. this.curHealth = this.maxHealth;
  36. }
  37. }
  38. public void restore(){
  39. this.curHealth = this.maxHealth;
  40. }
  41.  
  42.  
  43. public void drain(int amount){
  44. this.curHealth -= amount;
  45. if(this.curHealth < 0){
  46. this.curHealth = 0;
  47. }
  48.  
  49. }
  50. for(ExhaustionEffect callback : list){
  51.  
  52. }
  53. public void exhaust(){
  54. this.curHealth = 0;
  55. }
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement