123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #pragma once
- #include "QuestEvent.h"
- #include "TypeRegistry.h"
- class QuestStorage;
- class QuestRequirement : public virtual Framework::ReferenceCounter
- {
- protected:
- Framework::Text id;
- Framework::Text description;
- public:
- QuestRequirement();
- virtual void processEvent(QuestEvent* zEvent, QuestStorage* zStorage) = 0;
- virtual void addRequirementUIML(QuestStorage* zStorage,
- Framework::XML::Element* zParent,
- Framework::Text onClickPrefix)
- = 0;
- virtual void api(Framework::StreamReader* message,
- Framework::XML::Element* zParent,
- QuestStorage* zStorage);
- void setRequirementId(Framework::Text id);
- const Framework::Text& getRequirementId() const;
- void setDescription(Framework::Text description);
- const Framework::Text& getDescription() const;
- };
- template<typename S> class QuestRequirementFactoryBase
- : public SubTypeFactory<QuestRequirement, S>
- {
- public:
- QuestRequirementFactoryBase()
- : SubTypeFactory<QuestRequirement, S>()
- {}
- void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
- {
- QuestRequirement* zRequirement
- = dynamic_cast<QuestRequirement*>(zResult);
- zRequirement->setRequirementId(
- zJson->zValue("id")->asString()->getString());
- zRequirement->setDescription(
- zJson->zValue("description")->asString()->getString());
- }
- void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
- {
- QuestRequirement* zRequirement
- = dynamic_cast<QuestRequirement*>(zObject);
- zResult->addValue("id",
- new Framework::JSON::JSONString(zRequirement->getRequirementId()));
- zResult->addValue("description",
- new Framework::JSON::JSONString(zRequirement->getDescription()));
- }
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override
- {
- return builder->withRequiredString("id")
- ->finishString()
- ->withRequiredString("description")
- ->finishString();
- }
- };
- class QuestRequirementOpenDialogType;
- class QuestRequirementOpenDialog : public QuestRequirement
- {
- private:
- Framework::Text dialogId;
- public:
- QuestRequirementOpenDialog();
- void processEvent(QuestEvent* zEvent, QuestStorage* zStorage) override;
- void addRequirementUIML(QuestStorage* zStorage,
- Framework::XML::Element* zParent,
- Framework::Text onClickPrefix) override;
- void setDialogId(Framework::Text dialogId);
- const Framework::Text& getDialogId() const;
- friend QuestRequirementOpenDialogType;
- };
- class QuestRequirementOpenDialogType
- : public QuestRequirementFactoryBase<QuestRequirementOpenDialog>
- {
- public:
- QuestRequirementOpenDialogType();
- QuestRequirementOpenDialog* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(QuestRequirementOpenDialog* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(QuestRequirementOpenDialog* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class QuestRequirementBlockBreak : public QuestRequirement
- {};
- class QuestRequirementBlockPlace : public QuestRequirement
- {};
- class QuestRequirementBlockInteract : public QuestRequirement
- {};
- class QuestRequirementCraft : public QuestRequirement
- {};
- class QuestRequirementItemInInventory : public QuestRequirement
- {};
|