From ad4e082012fa34d30bc87672e8a2b2cd5aa8d013 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 14 Sep 2021 13:35:22 -0400 Subject: [PATCH] Write arkhamdb json output to a file --- strange_eons_to_arkhamdb.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/strange_eons_to_arkhamdb.js b/strange_eons_to_arkhamdb.js index 0f972ec..0eb9d2b 100644 --- a/strange_eons_to_arkhamdb.js +++ b/strange_eons_to_arkhamdb.js @@ -1,3 +1,5 @@ +importClass(java.io.File); +importClass(java.io.FileWriter); importPackage(arkham.project); // TODO: should be defined in strange eons somewhere @@ -246,4 +248,12 @@ for (let member in recurseAllChildren(Eons.getOpenProject())) { cards.sort(function (a, b) { return parseInt(a.code) - parseInt(b.code); }); -println(JSON.stringify(cards, null, 4)); +const file = new File(Eons.getOpenProject().getFile(), pack_code + '.json'); +printf("Writing '%s'\n", file); +const file_writer = new FileWriter(file); +file_writer.write(JSON.stringify(cards, null, 4)); +file_writer.flush(); +file_writer.close(); +println("Done!"); + +Eons.getOpenProject().synchronize();