'Godot 3.4: Quest System Task Advancement
So I managed to solve my previous problem about not being able to modify a dictionary(stupid me), but now im more or less stuck on the concept of task advancement.
So I have a quest system(dictionary), with sub-dictionaries such as "tasks" I want a single function to advance the quest, and I'm thinking something like this:
if not all_tasks in Quest are complete:
find the first task that has a "completed" bool value of false
change bool value to true
else: (all tasks have "completed" value of true)
complete quest instead.
And I'm thinking it will have to be an array of tasks. But I'm not sure how to implement this and I keep getting stuck on the logic. It's way easier to write it out logically than to actually implement it in code.
So, what do you think? Is this a valid way of going about this? is there a better way? If this is a good way, how would I go about finding the first task in the array that is not complete, and then complete it?
Solution 1:[1]
func advanceQuest(questName: String):
if PlayerData.playerData.quests_active.has(questName):
var taskList = []
if PlayerData.playerData.quests_active.get(questName).get("taskType") == 0:
for task in PlayerData.playerData.quests_active.get(questName).get("tasks"):
if PlayerData.playerData.quests_active.get(questName).get("tasks").get(task).get("completed") == false:
taskList.append(task)
if taskList != []:
PlayerData.playerData.quests_active[questName]["tasks"][taskList[0]]["completed"] = true
else:
completeQuest(questName)
else:
#Syncronous Task Type
pass
else:
Got it!!!!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lunam Plays |
