-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
76 lines (66 loc) · 2.58 KB
/
index.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const fs = require("node:fs");
const { generateTarotsSheet } = require("./src/tarots");
const { generateBoostersSheet } = require("./src/boosters");
const { generateVouchersSheet } = require("./src/vouchers");
const { generateBlindChipsSheet } = require("./src/blind_chips");
const { generateJokersSheet } = require("./src/jokers");
const { generateShopSignAnimationSheet } = require("./src/shop");
const { generateDeckContentSheet } = require("./src/deck_content");
const { alphaDiscrepanciesCoordinates } = require("./test/check-alpha");
const path = require("node:path");
const locale = process.argv[2] ?? "fr";
// Ensure the output directory exist for this locale
fs.mkdirSync(`dist/${locale}/1x`, { recursive: true });
fs.mkdirSync(`dist/${locale}/2x`, { recursive: true });
const fontPath = fs.realpathSync(
"assets/balatro-extended-consumable-cards.ttf"
);
const zoneData = JSON.parse(fs.readFileSync("blanks/zones.json", "utf8"));
const consumablesLocales = JSON.parse(
fs.readFileSync(`locales/${locale}/consumables.json`, "utf8")
);
const logAndReturn2x = (gen) =>
gen.then(([oneDest, twoDest, ...otherDest]) => {
console.log(`Generated: ${oneDest}`);
console.log(`Generated: ${twoDest}`);
otherDest.forEach((dest) => console.log(`Generated: ${dest}`));
return twoDest;
});
Promise.all(
[
generateTarotsSheet(locale, zoneData, consumablesLocales, fontPath),
generateBoostersSheet(locale, zoneData, consumablesLocales),
generateVouchersSheet(locale, zoneData, consumablesLocales),
generateBlindChipsSheet(locale, zoneData, consumablesLocales),
generateShopSignAnimationSheet(locale, zoneData, consumablesLocales),
generateJokersSheet(locale, zoneData, consumablesLocales),
generateDeckContentSheet(locale, zoneData),
].map(logAndReturn2x)
)
.then((twoDests) => {
const comparisons = twoDests.map(async (generatedSheet) => {
const referenceSheet = "test/reference/" + path.basename(generatedSheet);
if (fs.existsSync(referenceSheet)) {
const discrepancies = await alphaDiscrepanciesCoordinates(
referenceSheet,
generatedSheet
);
if (discrepancies.length) {
console.error(
`E: Discrepancies found in ${path.basename(generatedSheet)}`
);
console.error(discrepancies);
return true;
}
return false;
}
});
return Promise.all(comparisons);
})
.then((results) => {
if (!results.some(Boolean)) {
console.log(
"No discrepancies found in alpha between original and reference sheets. All good!"
);
}
});