#pragma once

#include "quest/QuestTypes.h"
#include <string>
#include <unordered_map>
#include <vector>

namespace ZL::Quest {

class QuestJournal {
public:
	bool loadFromFile(const std::string& path, const std::string& zipFile = "");

	bool unlockQuest(const std::string& questId);
	bool startQuest(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 setActiveObjective(const std::string& questId, int objectiveIndex);

	QuestState* findQuest(const std::string& questId);
	const QuestState* findQuest(const std::string& questId) const;

	std::vector<QuestState*> getVisibleQuests();
	std::vector<const QuestState*> getVisibleQuests() const;

private:
	std::unordered_map<std::string, QuestState> quests;
	std::vector<std::string> questOrder;

	bool setStatus(const std::string& questId, QuestStatus status);
};

} // namespace ZL::Quest
