Conversation
| } | ||
|
|
||
| function writeToOutput(filename, data) { | ||
| fs.writeFileSync(path.join(__dirname, '..', 'output', filename), JSON.stringify(data), 'utf-8'); |
There was a problem hiding this comment.
You could use the space parameter for the stringify here (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#using_the_space_parameter). Should make it a bit easier to read the resulting json files from this. It also might add some length which might not be preferable.
There was a problem hiding this comment.
Yeah the goal here is absolute minification. you can also use numbers to specify how many spaces (or was it tabs?) you want per indentation. Our old content used 2
| fs.writeFileSync(path.join(__dirname, '..', 'output', filename), JSON.stringify(data), 'utf-8'); | ||
| } | ||
|
|
||
| function HoneyTreeData() { |
There was a problem hiding this comment.
New version of the HoneyTreeData() converted from Python to JS by ChatGPT 3.5 (no bugs in the original, just easier readability):
function matchHoneyTreeData(match, honeyRoutes) {
const arrayRegex = /\[(.*?)\]\s*=\s*\{(.*?)\}/;
const valuesStr = match[1];
const honeyTrees = {};
const lines = valuesStr.split("\n");
for (let i = 0; i < lines.length; i++) {
let line = lines[i].trim();
if (!line) {
continue;
}
const submatch = line.match(arrayRegex);
if (!submatch) {
continue;
}
const key = submatch[1];
const values = submatch[2].split(",").map(v => v.trim());
if (!values.includes("AMPHAROS")) {
honeyTrees[honeyRoutes[key]] = values;
}
}
return honeyTrees;
}
function HoneyTreeData(honeyworkCppFilePath, honeyroutesFilePath) {
const constRegex = /const\s+int32_t\s+HONEY_TREES\[\s*NUM_ZONE_ID\s*\]\[\s*10\s*\]\s*=\s*\{\s*([\s\S]*?)\};/;
const fs = require('fs');
const honeyData = fs.readFileSync(honeyworkCppFilePath, 'utf8');
const honeyRoutes = JSON.parse(fs.readFileSync(honeyroutesFilePath, 'utf8'));
// Extract honey trees data
const match = honeyData.match(constRegex);
if (match) {
return matchHoneyTreeData(match, honeyRoutes);
}
}
function getHoneyTreeMons(routes) {
const honeyEncounterData = HoneyTreeData();
for (const key in honeyEncounterData) {
for (const mon of honeyEncounterData[key]) {
if (mon.toUpperCase() in routes[key]) {
continue;
}
if (mon === "FARFETCHD") {
routes[key].push("Farfetch'd");
} else {
routes[key].push(mon.toUpperCase());
}
}
}
}
There was a problem hiding this comment.
Let me know if anything doesn't make sense here and I can explain it.
TO DO
The goal of this PR is to create a system that drastically lowers the file size of our data. So far we have achieved a minification of 57MB -> 1.8MB