More work on states, added bot
This commit is contained in:
1 parent
66e93d46f4
commit
5e9a663812
25 files changed
+1595
-740
No files matched your search
+24
-13
@@ -6,10 +6,27 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace FRG::Quest {
|
||||
|
||||
enum class QuestEventType {
|
||||
Unlocked,
|
||||
Completed,
|
||||
Failed,
|
||||
ObjectiveCompleted
|
||||
};
|
||||
|
||||
struct QuestEvent {
|
||||
QuestEventType type;
|
||||
std::string questId;
|
||||
std::string objectiveId;
|
||||
};
|
||||
|
||||
struct QuestMutationResult {
|
||||
bool success = false;
|
||||
std::vector<QuestEvent> events;
|
||||
};
|
||||
|
||||
class QuestJournal : public FRG::ISaveable {
|
||||
public:
|
||||
bool loadFromFile(const std::string& path, const std::string& zipFile = "");
|
||||
@@ -22,19 +39,13 @@ public:
|
||||
void save(nlohmann::json& out) const override;
|
||||
void load(const nlohmann::json& in) override;
|
||||
|
||||
// Event callbacks — set by the owner (MenuManager) to receive notifications.
|
||||
std::function<void(const std::string& questId)> onQuestUnlocked;
|
||||
std::function<void(const std::string& questId)> onQuestCompleted;
|
||||
std::function<void(const std::string& questId)> onQuestFailed;
|
||||
std::function<void(const std::string& questId, const std::string& objectiveId)> onObjectiveCompleted;
|
||||
QuestMutationResult unlockQuest(const std::string& questId);
|
||||
QuestMutationResult completeQuest(const std::string& questId);
|
||||
QuestMutationResult failQuest(const std::string& questId);
|
||||
|
||||
bool unlockQuest(const std::string& questId);
|
||||
bool completeQuest(const std::string& questId);
|
||||
bool failQuest(const std::string& questId);
|
||||
|
||||
bool setObjectiveCompleted(const std::string& questId, const std::string& objectiveId, bool completed = true);
|
||||
bool setObjectiveVisible(const std::string& questId, const std::string& objectiveId, bool visible = true);
|
||||
bool setActiveObjective(const std::string& questId, int objectiveIndex);
|
||||
QuestMutationResult setObjectiveCompleted(const std::string& questId, const std::string& objectiveId, bool completed = true);
|
||||
QuestMutationResult setObjectiveVisible(const std::string& questId, const std::string& objectiveId, bool visible = true);
|
||||
QuestMutationResult setActiveObjective(const std::string& questId, int objectiveIndex);
|
||||
|
||||
QuestState* findQuest(const std::string& questId);
|
||||
const QuestState* findQuest(const std::string& questId) const;
|
||||
|
||||
Reference in new issue
Block a user