123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- #pragma once
- #include <JSON.h>
- #include "QuestEvent.h"
- #include "QuestRequirement.h"
- #include "QuestReward.h"
- #include "TypeRegistry.h"
- class QuestRequirementStorageType;
- class QuestRequirementStorage : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Text requirementId;
- bool fulfilled;
- public:
- QuestRequirementStorage();
- void setFullfilled(bool fullfilled);
- bool isFullfilled() const;
- void setRequirementId(Framework::Text requirementId);
- const Framework::Text& getRequirementId() const;
- friend QuestRequirementStorageType;
- };
- class QuestRequirementStorageType : public TypeFactory<QuestRequirementStorage>
- {
- public:
- QuestRequirementStorageType();
- QuestRequirementStorage* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(QuestRequirementStorage* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(QuestRequirementStorage* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class QuestStorageType;
- class QuestStorage : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Text questId;
- bool finished;
- bool rewarded;
- bool visible;
- Framework::RCArray<QuestRequirementStorage> requirements;
- Framework::JSON::JSONObject* data;
- public:
- QuestStorage();
- ~QuestStorage();
- void setQuestFinished(bool finished);
- void setQuestRewarded(bool rewarded);
- bool isQuestFinished() const;
- bool isQuestRewarded() const;
- QuestRequirementStorage* zStorage(Framework::Text requirementId);
- void setQuestId(Framework::Text questId);
- const Framework::Text& getQuestId() const;
- bool isVisible() const;
- void setVisible(bool visible);
- void putValue(Framework::Text key, Framework::JSON::JSONValue* value);
- Framework::JSON::JSONValue* getValue(Framework::Text key) const;
- Framework::JSON::JSONValue* zValue(Framework::Text key) const;
- bool containsKey(Framework::Text key) const;
- friend QuestStorageType;
- };
- class QuestStorageType : public TypeFactory<QuestStorage>
- {
- public:
- QuestStorageType();
- QuestStorage* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(QuestStorage* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(QuestStorage* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class QuestPartyType;
- class QuestParty : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Array<int> memberEntityIds;
- Framework::RCArray<QuestStorage> questStorage;
- public:
- QuestParty();
- void addMember(int memberEntityId);
- void removeMember(int memberEntityId);
- bool isMember(int memberEntityId) const;
- bool isEmpty() const;
- QuestStorage* zQuestStorage(Framework::Text questId);
- QuestParty* clone() const;
- friend QuestPartyType;
- };
- class QuestPartyType : public TypeFactory<QuestParty>
- {
- public:
- QuestPartyType();
- QuestParty* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(
- QuestParty* zResult, Framework::JSON::JSONObject* zJson) const override;
- void toJson(QuestParty* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class QuestType;
- class QuestManager;
- class QuestDialog;
- class Quest : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Text questId;
- Framework::Text questName;
- Framework::Text description;
- Framework::Text imagePath;
- bool mainQuest;
- Framework::RCArray<Framework::Text> requiredQuestsIds;
- Framework::Array<int> requiredQuestsGroups;
- Framework::RCArray<QuestRequirement> requirements;
- Framework::RCArray<QuestReward> rewards;
- public:
- Quest();
- void processEvent(QuestEvent* zEvent, QuestStorage* zStorage);
- bool isVisible(QuestParty* zParty, QuestManager* zManager);
- bool isActive(QuestParty* zParty);
- void setQuestId(Framework::Text questId);
- const Framework::Text& getQuestId() const;
- void setVisible(bool visible, QuestParty* zParty, QuestManager* zManager);
- friend QuestType;
- friend QuestDialog;
- };
- class QuestType : public TypeFactory<Quest>
- {
- public:
- QuestType();
- Quest* createValue(Framework::JSON::JSONObject* zJson) const override;
- void fromJson(
- Quest* zResult, Framework::JSON::JSONObject* zJson) const override;
- void toJson(
- Quest* zObject, Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class QuestCollectionType;
- class QuestCollection : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Text name;
- Framework::RCArray<Quest> quests;
- public:
- QuestCollection();
- void processEvent(QuestEvent* zEvent, QuestParty* zParty);
- bool isVisible(QuestParty* zParty, QuestManager* zManager);
- void addQuest(Quest* zQuest);
- void setName(Framework::Text name);
- const Framework::Text& getName() const;
- void setQuestVisible(bool visible,
- Framework::Text questId,
- QuestParty* zParty,
- QuestManager* zManager);
- friend QuestCollectionType;
- friend QuestDialog;
- };
- class QuestCollectionType : public TypeFactory<QuestCollection>
- {
- public:
- QuestCollectionType();
- QuestCollection* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(QuestCollection* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(QuestCollection* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class QuestManager : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::RCArray<QuestCollection> questCollections;
- Framework::RCArray<QuestParty> parties;
- QuestParty* zParty(int entityId);
- QuestCollection* zCollection(Framework::Text collectionName);
- public:
- QuestManager();
- void loadQuests();
- void saveQuests();
- void processEvent(QuestEvent* event);
- void setQuestVisible(
- bool visible, Framework::Text questId, QuestParty* zParty);
- friend QuestDialog;
- };
|