QuestReward.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "TypeRegistry.h"
  3. class Entity;
  4. class Item;
  5. class QuestReward : public virtual Framework::ReferenceCounter
  6. {
  7. protected:
  8. Framework::Text rewardId;
  9. public:
  10. QuestReward(Framework::Text rewardId);
  11. virtual void giveReward(Entity* zTargetEntity) = 0;
  12. virtual Framework::Text getRewardUIML() = 0;
  13. const Framework::Text& getRewardId() const;
  14. };
  15. class ItemStackInfo : public virtual Framework::ReferenceCounter
  16. {
  17. private:
  18. Item* item;
  19. int count;
  20. public:
  21. ItemStackInfo(Item* item, int count);
  22. ~ItemStackInfo();
  23. Item* zItem() const;
  24. int getCount() const;
  25. };
  26. class ItemStackInfoType : public TypeFactory<ItemStackInfo>
  27. {
  28. public:
  29. ItemStackInfoType();
  30. ItemStackInfo* fromJson(Framework::JSON::JSONValue* zJson) const override;
  31. Framework::JSON::JSONValue* toJson(ItemStackInfo* zObject) const override;
  32. Framework::JSON::Validator::JSONValidator* getValidator() const override;
  33. };
  34. class QuestRewardGiveItemsType;
  35. class QuestRewardGiveItems : public QuestReward
  36. {
  37. private:
  38. Framework::RCArray<ItemStackInfo> items;
  39. public:
  40. QuestRewardGiveItems(Framework::Text rewardId);
  41. void giveReward(Entity* zTargetEntity) override;
  42. Framework::Text getRewardUIML() override;
  43. friend QuestRewardGiveItemsType;
  44. };
  45. class QuestRewardGiveItemsType
  46. : public SubTypeFactory<QuestReward, QuestRewardGiveItems>
  47. {
  48. public:
  49. QuestRewardGiveItemsType();
  50. QuestRewardGiveItems* fromJson(
  51. Framework::JSON::JSONObject* zJson) const override;
  52. Framework::JSON::JSONObject* toJson(
  53. QuestRewardGiveItems* zObject) const override;
  54. Framework::JSON::Validator::JSONValidator* getValidator(
  55. Framework::JSON::Validator::ObjectValidationBuilder<
  56. Framework::JSON::Validator::JSONValidator>* builder) const override;
  57. Framework::Text getTypeToken() const override;
  58. };