change to trackedQuestId, add currentQuestId

This commit is contained in:
Kae 2024-10-21 16:54:10 +11:00
parent 99f78c3912
commit 5c669f4b3a
3 changed files with 16 additions and 2 deletions

View File

@ -273,6 +273,10 @@ List<QuestPtr> QuestManager::listFailedQuests() const {
return result;
}
Maybe<String> QuestManager::currentQuestId() const {
return m_trackedQuestId;
}
Maybe<QuestPtr> QuestManager::currentQuest() const {
auto questId = m_onWorldQuestId.orMaybe(m_trackedQuestId);
if (questId && isActive(*questId)) {
@ -283,6 +287,10 @@ Maybe<QuestPtr> QuestManager::currentQuest() const {
return {};
}
Maybe<String> QuestManager::trackedQuestId() const {
return m_trackedQuestId;
}
Maybe<QuestPtr> QuestManager::trackedQuest() const {
if (m_trackedQuestId && isActive(*m_trackedQuestId)) {
auto current = getQuest(*m_trackedQuestId);

View File

@ -52,7 +52,9 @@ public:
List<QuestPtr> listCompletedQuests() const;
List<QuestPtr> listFailedQuests() const;
Maybe<String> currentQuestId() const;
Maybe<QuestPtr> currentQuest() const;
Maybe<String> trackedQuestId() const;
Maybe<QuestPtr> trackedQuest() const;
Maybe<QuestIndicator> getQuestIndicator(EntityPtr const& entity) const;

View File

@ -484,8 +484,8 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) {
return player->questManager()->hasCompleted(questId);
});
callbacks.registerCallback("trackedQuest", [player]() {
return player->questManager()->trackedQuest();
callbacks.registerCallback("trackedQuestId", [player]() {
return player->questManager()->trackedQuestId();
});
callbacks.registerCallback("setTrackedQuest", [player](Maybe<String> const& questId) {
@ -496,6 +496,10 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) {
return player->questManager()->canTurnIn(questId);
});
callbacks.registerCallback("currentQuestId", [player]() {
return player->questManager()->currentQuestId();
});
callbacks.registerCallback("currentQuest", [player]() -> Json {
auto maybeQuest = player->questManager()->currentQuest();
if (maybeQuest) {