123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- #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(Framework::Text requirementId);
- void setFullfilled(bool fullfilled);
- bool isFullfilled() const;
- const Framework::Text& getRequirementId() const;
- friend QuestRequirementStorageType;
- };
- class QuestRequirementStorageType : public TypeFactory<QuestRequirementStorage>
- {
- public:
- QuestRequirementStorageType();
- QuestRequirementStorage* fromJson(
- Framework::JSON::JSONValue* zJson) const override;
- Framework::JSON::JSONValue* toJson(
- QuestRequirementStorage* zObject) const override;
- Framework::JSON::Validator::JSONValidator* getValidator() 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(Framework::Text questId);
- ~QuestStorage();
- void setQuestFinished(bool finished);
- void setQuestRewarded(bool rewarded);
- bool isQuestFinished() const;
- bool isQuestRewarded() const;
- QuestRequirementStorage* zStorage(Framework::Text requirementId);
- 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* fromJson(Framework::JSON::JSONValue* zJson) const override;
- Framework::JSON::JSONValue* toJson(QuestStorage* zObject) const override;
- Framework::JSON::Validator::JSONValidator* getValidator() 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* fromJson(Framework::JSON::JSONValue* zJson) const override;
- Framework::JSON::JSONValue* toJson(QuestParty* zObject) const override;
- Framework::JSON::Validator::JSONValidator* getValidator() 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(Framework::Text questId);
- void processEvent(QuestEvent* zEvent, QuestStorage* zStorage);
- bool isVisible(QuestParty* zParty, QuestManager* zManager);
- bool isActive(QuestParty* zParty);
- 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* fromJson(Framework::JSON::JSONValue* zJson) const override;
- Framework::JSON::JSONValue* toJson(Quest* zObject) const override;
- Framework::JSON::Validator::JSONValidator* getValidator() const override;
- };
- class QuestCollectionType;
- class QuestCollection : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Text name;
- Framework::RCArray<Quest> quests;
- public:
- QuestCollection(Framework::Text name);
- void processEvent(QuestEvent* zEvent, QuestParty* zParty);
- bool isVisible(QuestParty* zParty, QuestManager* zManager);
- void addQuest(Quest* zQuest);
- 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* fromJson(Framework::JSON::JSONValue* zJson) const override;
- Framework::JSON::JSONValue* toJson(QuestCollection* zObject) const override;
- Framework::JSON::Validator::JSONValidator* getValidator() 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;
- };
|