BasicItems.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "ItemType.h"
  3. class BasicItemType : public ItemType
  4. {
  5. private:
  6. Framework::Text itemName;
  7. float hp;
  8. float durability;
  9. bool solid;
  10. float hungerRecoveryPerHp;
  11. float thirstRecoveryPerHp;
  12. public:
  13. BasicItemType();
  14. Item* createItem() const override;
  15. void setItemName(Framework::Text itemName);
  16. Framework::Text getItemName() const;
  17. void setHp(float hp);
  18. float getHp() const;
  19. void setDurability(float durability);
  20. float getDurability() const;
  21. void setSolid(bool solid);
  22. bool isSolid() const;
  23. void setHungerRecoveryPerHp(float hungerRecoveryPerHp);
  24. float getHungerRecoveryPerHp() const;
  25. void setThirstRecoveryPerHp(float thirstRecoveryPerHp);
  26. float getThirstRecoveryPerHp() const;
  27. };
  28. class BasicItemTypeFactory : public ItemTypeFactoryBase<BasicItemType>
  29. {
  30. public:
  31. BasicItemTypeFactory();
  32. BasicItemType* createValue(
  33. Framework::JSON::JSONObject* zJson) const override;
  34. void fromJson(BasicItemType* zResult,
  35. Framework::JSON::JSONObject* zJson) const override;
  36. void toJson(BasicItemType* zObject,
  37. Framework::JSON::JSONObject* zResult) const override;
  38. JSONObjectValidationBuilder* addToValidator(
  39. JSONObjectValidationBuilder* builder) const override;
  40. Framework::Text getTypeToken() const override;
  41. };