QuestReward.h 2.3 KB

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