aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2024-03-12 17:46:44 +0000
committerLeonardo Bishop <me@leonardobishop.com>2024-03-12 17:46:44 +0000
commit8664ad155c89d47affd94f8b0385ebf39841f1f8 (patch)
treeb1f6c33a2666a483e39093fa310ea3483b655c62 /lib
parentcc2f3987c3f6386da140fefcb1998cb1eef18839 (diff)
Add YAML modal
Diffstat (limited to 'lib')
-rw-r--r--lib/questsLoader.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/questsLoader.ts b/lib/questsLoader.ts
index 0623f04..a4ea64f 100644
--- a/lib/questsLoader.ts
+++ b/lib/questsLoader.ts
@@ -66,3 +66,45 @@ export function loadCategoriesFromJson(config: any): EditorCategory[] {
};
});
}
+
+//TODO don't write fields if they're unchanged
+export function mapJsonQuestToYamlObject(quest: EditorQuest): any {
+ return {
+ tasks: Object.fromEntries(Object.keys(quest.tasks).map((taskId: string) => {
+ return [taskId, quest.tasks[taskId].config]
+ })),
+ display: {
+ name: quest.display.name,
+ "lore-normal": quest.display.lore.normal,
+ "lore-started": quest.display.lore.started,
+ type: quest.display.type
+ },
+ rewards: quest.rewards,
+ ...(quest.startCommands && { startcommands: quest.startCommands }),
+ ...(quest.startString && { startstring: quest.startString }),
+ ...(quest.rewardString && { rewardstring: quest.rewardString }),
+ ...(quest.placeholders && { placeholders: quest.placeholders }),
+ options: {
+ category: quest.options.category,
+ requires: quest.options.requirements,
+ "permission-required": quest.options.permissionRequired,
+ cancellable: quest.options.cancellable,
+ "counts-towards-limit": quest.options.countsTowardsLimit,
+ repeatable: quest.options.repeatable,
+ cooldown: {
+ enabled: quest.options.cooldown.enabled,
+ time: quest.options.cooldown.time,
+ },
+ "time-limit": {
+ enabled: quest.options.timeLimit.enabled,
+ time: quest.options.timeLimit.time,
+ },
+ "sort-order": quest.options.sortOrder,
+ autostart: quest.options.autostart || false,
+ ...(quest.options.completedDisplay && { completedDisplay: quest.options.completedDisplay }),
+ ...(quest.options.cooldownDisplay && { cooldownDisplay: quest.options.cooldownDisplay }),
+ ...(quest.options.permissionDisplay && { permissionDisplay: quest.options.permissionDisplay }),
+ ...(quest.options.lockedDisplay && { lockedDisplay: quest.options.lockedDisplay }),
+ },
+ }
+} \ No newline at end of file