feat: more sieglinde general work

This commit is contained in:
zkldi
2022-08-20 13:03:41 +01:00
parent d806bca2e5
commit ea7ef026f0
6 changed files with 45 additions and 26 deletions
+2 -1
View File
@@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"calc-v1": "ts-node src/main.ts -v 1 -o out.json"
},
"author": "zkldi",
"license": "MIT",
+2 -5
View File
@@ -62,19 +62,16 @@ export default async function SieglindeV2Calc(tableInfo: TableRes): Promise<Arra
.filter((chart) => ecComputer.songDifficulty.has(chart.md5))
.map((chart) => {
const ecValue = ecComputer.songDifficulty.get(chart.md5)!;
const ecPrefix = "σ";
const hcValue = hcComputer.songDifficulty.get(chart.md5)!;
const hcPrefix = "σ";
return {
md5: chart.md5,
title: chart.title,
baseLevel: GetFString(tableInfo.table, chart),
ec: ecValue,
ecStr: `${ecPrefix}${ecValue.toFixed(2)}`,
ecStr: `a`,
hc: hcValue,
hcStr: `${hcPrefix}${hcValue.toFixed(2)}`,
hcStr: `a`,
};
});
}
+3 -1
View File
@@ -14,7 +14,9 @@ export interface TableRes {
export default async function GetTableData(): Promise<Array<TableRes>> {
const out = [];
for (const table of registeredTables) {
for (const table of registeredTables.filter(
(e) => e.name === "Insane" || e.name === "Normal"
)) {
const charts = await fetch(table.url).then((r) => r.json());
out.push({ table, charts });
+18 -17
View File
@@ -48,28 +48,29 @@ void (async () => {
throw new Error(`Unknown sieglinde version ${version}.`);
}
if (version === 0) {
fs.mkdirSync(`${__dirname}/cache`, { recursive: true });
fs.mkdirSync(`${__dirname}/cache`, { recursive: true });
const tableInfo = await GetTableData();
const tableInfo = await GetTableData();
logger.info(`Starting...`);
logger.info(`Starting...`);
const calcData = [];
const calcData = [];
for (const table of tableInfo) {
// literally all the parallelism in this codebase has to be turned off because
// the lr2ir runs off of a toaster which attempts to gut you if you make more than one
// request a second.
// eslint-disable-next-line no-await-in-loop
calcData.push(await calcFn(table));
}
let i = 1;
WriteOut(JSON.stringify(calcData.flat(1)));
for (const table of tableInfo) {
logger.info(`Running for table ${table.table.name}. ${i}/${tableInfo.length}`);
logger.info(`Finished!`);
} else {
logger.error(`Unsupported/Unknown version ${version}.`);
process.exit(-1);
// literally all the parallelism in this codebase has to be turned off because
// the lr2ir runs off of a toaster which attempts to gut you if you make more than one
// request a second.
// eslint-disable-next-line no-await-in-loop
calcData.push(await calcFn(table));
i++;
}
WriteOut(JSON.stringify(calcData.flat(1)));
logger.info(`Finished!`);
})();
+20
View File
@@ -0,0 +1,20 @@
import GetTableData from "../fetch-tables";
import { ChunkifyPromiseAll, GetScoresForMD5 } from "../util";
export default async function FetchAllTableScores() {
const tableInfo = await GetTableData();
const promises = [];
for (const table of tableInfo) {
for (const chart of table.charts) {
promises.push(() => GetScoresForMD5(chart.md5));
}
}
await ChunkifyPromiseAll(promises, 100);
}
if (require.main === module) {
void FetchAllTableScores();
}
-2
View File
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import logger from "../logger";
type SongId = string;