ItemSkill.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. const ItemType* zSkillType();
  25. int getTypeId();
  26. };
  27. class BasicItemSkill : public ItemSkill
  28. {
  29. protected:
  30. int level;
  31. float xp;
  32. float maxXP;
  33. float durabilityModifier;
  34. float speedModifier;
  35. float luckModifier;
  36. float staminaModifier;
  37. float hungerModifier;
  38. BasicItemSkill(int itemTypeId,
  39. float maxXp = 100.f,
  40. float durabilityModifier = 1.f,
  41. float speedModifier = 1.f,
  42. float luckModifier = 1.f,
  43. float staminaModifier = 1.f,
  44. float hungerModifier = 1.f,
  45. float xpIncrease = 1.1f);
  46. public:
  47. virtual void use(Entity* zActor, Item* zUsedItem, Block* zTarget) override;
  48. virtual void use(Entity* zActor, Item* zUsedItem, Entity* zTarget) override;
  49. friend ItemType;
  50. };