-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateSets.js
More file actions
29 lines (26 loc) · 895 Bytes
/
createSets.js
File metadata and controls
29 lines (26 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require("fs");
const ejs = require("ejs");
const configs = require("./config");
const messages = require("./messages");
const houses = messages[configs.lang].houses;
configs.expansion.forEach(expansion => {
console.log("Loading cards from " + expansion.longname + "...");
const cardsFolder = "./json/" + expansion.lang + "/" + expansion.name + "/";
const setFile = "./xml/" + expansion.lang + "/" + expansion.name + ".xml";
const cards = fs.readdirSync(cardsFolder);
console.log("Setup to processing " + cards.length + " cards...");
ejs.renderFile(
"./xml/set.ejs",
{
expansion: expansion,
cards: cards.map(card =>
JSON.parse(fs.readFileSync(cardsFolder + card).toString())
),
houses: houses
},
{ filename: setFile },
function(err, str) {
if (!err) fs.writeFileSync(setFile, str, { flag: "w" });
}
);
});