38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const [levelStatsPath, classStatsPath, outputPath] = process.argv.slice(2);
|
|
if (!levelStatsPath || !classStatsPath || !outputPath) {
|
|
throw new Error("Usage: node extract-wow335-base-stats.mjs <player_levelstats.sql> <player_classlevelstats.sql> <output.json>");
|
|
}
|
|
|
|
function tupleRows(sql) {
|
|
return [...sql.matchAll(/^\(([^)]+)\)[,;]?$/gm)].map((match) => (
|
|
match[1].split(",").map((value) => Number(value))
|
|
));
|
|
}
|
|
|
|
const attributes = {};
|
|
for (const [race, characterClass, level, strength, agility, stamina, intellect, spirit] of tupleRows(
|
|
fs.readFileSync(levelStatsPath, "utf8"),
|
|
)) {
|
|
const key = `${race}:${characterClass}`;
|
|
(attributes[key] ??= [])[level - 1] = [strength, agility, stamina, intellect, spirit];
|
|
}
|
|
|
|
const resources = {};
|
|
for (const [characterClass, level, baseHealth, baseMana] of tupleRows(
|
|
fs.readFileSync(classStatsPath, "utf8"),
|
|
)) {
|
|
(resources[characterClass] ??= [])[level - 1] = [baseHealth, baseMana];
|
|
}
|
|
|
|
const output = {
|
|
schemaVersion: 1,
|
|
source: "AzerothCore database-wotlk 3.3.5a player_levelstats/player_classlevelstats",
|
|
attributes,
|
|
resources,
|
|
};
|
|
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
fs.writeFileSync(outputPath, `${JSON.stringify(output)}\n`);
|