ItemSkill.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <JSON.h>
  3. #include <ReferenceCounter.h>
  4. #include "Reader.h"
  5. class ItemType;
  6. class ItemSkill;
  7. class Block;
  8. class Entity;
  9. class Dimension;
  10. class Item;
  11. class ItemSkillLevelUpRule : public virtual Framework::ReferenceCounter
  12. {
  13. public:
  14. virtual void applyOn(ItemSkill* zSkill) = 0;
  15. };
  16. class ItemSkill : public virtual Framework::ReferenceCounter
  17. {
  18. private:
  19. const int itemTypeId;
  20. public:
  21. ItemSkill(int itemTypeId);
  22. virtual void use(Entity* zActor, Item* zUsedItem, Block* zTarget) = 0;
  23. virtual void use(Entity* zActor, Item* zUsedItem, Entity* zTarget) = 0;
  24. virtual void interact(Entity* zActor, Item* zUsedItem, Block* zTarget);
  25. virtual void interact(Entity* zActor, Item* zUsedItem, Entity* zTarget);
  26. const ItemType* zSkillType();
  27. int getTypeId();
  28. };
  29. class BasicItemSkill : public ItemSkill
  30. {
  31. protected:
  32. int level;
  33. float xp;
  34. float maxXP;
  35. float durabilityModifier;
  36. float speedModifier;
  37. float luckModifier;
  38. float staminaModifier;
  39. float hungerModifier;
  40. BasicItemSkill(int itemTypeId,
  41. float maxXp = 100.f,
  42. float durabilityModifier = 1.f,
  43. float speedModifier = 1.f,
  44. float luckModifier = 1.f,
  45. float staminaModifier = 1.f,
  46. float hungerModifier = 1.f,
  47. float xpIncrease = 1.1f);
  48. public:
  49. virtual void use(Entity* zActor, Item* zUsedItem, Block* zTarget) override;
  50. virtual void use(Entity* zActor, Item* zUsedItem, Entity* zTarget) override;
  51. virtual void interact(
  52. Entity* zActor, Item* zUsedItem, Block* zTarget) override;
  53. virtual void interact(
  54. Entity* zActor, Item* zUsedItem, Entity* zTarget) override;
  55. friend ItemType;
  56. };