123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #pragma once
- #include "TypeRegistry.h"
- class Entity;
- class Item;
- class QuestStorage;
- class QuestReward : public virtual Framework::ReferenceCounter
- {
- protected:
- Framework::Text rewardId;
- public:
- QuestReward();
- virtual void giveReward(Framework::XML::Element* zParent,
- QuestStorage* zStorage,
- Entity* zTargetEntity)
- = 0;
- virtual void addRewardUIML(Framework::XML::Element* zParent,
- QuestStorage* zStorage,
- Framework::Text onClickPrefix)
- = 0;
- virtual bool validateSettings(
- Framework::XML::Element* zParent, QuestStorage* zStorage);
- virtual void api(Framework::StreamReader* message,
- Framework::XML::Element* zParent,
- QuestStorage* zStorage);
- void setRewardId(Framework::Text rewardId);
- const Framework::Text& getRewardId() const;
- };
- template<typename S> class QuestRewardFactoryBase
- : public SubTypeFactory<QuestReward, S>
- {
- public:
- QuestRewardFactoryBase()
- : SubTypeFactory<QuestReward, S>()
- {}
- void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
- {
- QuestReward* zRequirement = dynamic_cast<QuestReward*>(zResult);
- zRequirement->setRewardId(zJson->zValue("rewardId")->asString()->getString());
- }
- void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
- {
- QuestReward* zRequirement = dynamic_cast<QuestReward*>(zObject);
- zResult->addValue(
- "rewardId", new Framework::JSON::JSONString(zRequirement->getRewardId()));
- }
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override
- {
- return builder->withRequiredString("rewardId")->finishString();
- }
- };
- class ItemStackInfo : public virtual Framework::ReferenceCounter
- {
- private:
- Item* item;
- int count;
- public:
- ItemStackInfo();
- ~ItemStackInfo();
- void setItem(Item* item);
- Item* zItem() const;
- void setCount(int count);
- int getCount() const;
- };
- class ItemStackInfoType : public TypeFactory<ItemStackInfo>
- {
- public:
- ItemStackInfoType();
- ItemStackInfo* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(ItemStackInfo* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(ItemStackInfo* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class QuestRewardGiveItemsType;
- class QuestRewardGiveItems : public QuestReward
- {
- private:
- Framework::RCArray<ItemStackInfo> items;
- public:
- QuestRewardGiveItems();
- void giveReward(Framework::XML::Element* zParent,
- QuestStorage* zStorage,
- Entity* zTargetEntity) override;
- void addRewardUIML(Framework::XML::Element* zParent,
- QuestStorage* zStorage,
- Framework::Text onClickPrefix) override;
- friend QuestRewardGiveItemsType;
- };
- class QuestRewardGiveItemsType
- : public QuestRewardFactoryBase<QuestRewardGiveItems>
- {
- public:
- QuestRewardGiveItemsType();
- QuestRewardGiveItems* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(QuestRewardGiveItems* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(QuestRewardGiveItems* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
|