QuestReward.h 2.4 KB

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