因此,我设法解决了之前的问题,无法修改字典(愚蠢的我),但现在我或多或少地停留在任务推进的概念上。
因此,我有一个任务系统(字典),附带诸如“任务”之类的子词典,我希望有一个函数来推进这个任务,我正在想这样的事情:
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.我认为这必须是一系列的任务。但我不知道如何实现这一点,我一直被困在逻辑上。逻辑地写出它比在代码中实际实现它要容易得多。
那么,你怎么看?这是一种有效的方法吗?有更好的办法吗?如果这是一种很好的方法,我将如何找到数组中尚未完成的第一个任务,然后完成它呢?
发布于 2022-02-12 16:05:33
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:明白了!
https://stackoverflow.com/questions/71093382
复制相似问题