#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 class QuestRequirementFactoryBase : public SubTypeFactory { public: QuestRequirementFactoryBase() : SubTypeFactory() {} S* fromJson(Framework::JSON::JSONObject* zJson) const override { S* result = createValue(zJson); QuestRequirement* zRequirement = dynamic_cast(result); zRequirement->setRequirementId( zJson->zValue("id")->asString()->getString()); zRequirement->setDescription( zJson->zValue("description")->asString()->getString()); return result; } Framework::JSON::JSONObject* toJsonObject(S* zObject) const override { Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject(); QuestRequirement* zRequirement = dynamic_cast(zObject); result->addValue("id", new Framework::JSON::JSONString(zRequirement->getRequirementId())); result->addValue("description", new Framework::JSON::JSONString(zRequirement->getDescription())); return result; } JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override { return builder->withRequiredString("id") ->finishString() ->withRequiredString("description") ->finishString(); } protected: virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0; }; 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 { public: QuestRequirementOpenDialogType(); QuestRequirementOpenDialog* createValue( Framework::JSON::JSONObject* zJson) const override; QuestRequirementOpenDialog* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( QuestRequirementOpenDialog* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class QuestRequirementBlockBreak : public QuestRequirement {}; class QuestRequirementBlockPlace : public QuestRequirement {}; class QuestRequirementBlockInteract : public QuestRequirement {}; class QuestRequirementCraft : public QuestRequirement {}; class QuestRequirementItemInInventory : public QuestRequirement {};