Merge pull request #796 from TNG-dev/zkldi/rm-overjoy-sgl

This commit is contained in:
zkldi
2022-12-19 06:31:44 +00:00
committed by GitHub
10 changed files with 16209 additions and 12555 deletions
File diff suppressed because it is too large Load Diff
@@ -4,13 +4,13 @@ const path = require("path");
const { MutateCollection } = require("../../util");
const program = new Command();
program.option("-i, --input <sieglinde output/ folder>");
program.option("-i, --input <sieglinde output/folder>");
program.parse(process.argv);
const options = program.opts();
if (!options.input) {
throw new Error(`Missing --input.`);
options.input = "../../../../sieglinde/src/output/";
}
const APPLICATION_ORDER = [
@@ -81,10 +81,12 @@ for (const tableName of APPLICATION_ORDER) {
maybeSgl.hcStr = maybeSgl.ecStr;
}
// overjoy hc data is screwed, disable it for now.
// all overjoy data is screwed, disable it for now.
if (maybeSgl.baseLevel.startsWith("★★")) {
maybeSgl.hc = 0;
maybeSgl.hcStr += "?";
maybeSgl.ec = 0;
maybeSgl.ecStr += "?";
}
// sl12 data is screwed, neuter it.
+2
View File
@@ -502,6 +502,7 @@ importers:
sieglinde:
specifiers:
'@types/node-fetch': '2'
bms-table-loader: ^1.0.1
commander: ^8.3.0
fast-xml-parser: ^4.0.0-beta.2
mei-logger: ^1.0.1
@@ -510,6 +511,7 @@ importers:
winston: 3.5.1
dependencies:
'@types/node-fetch': 2.5.12
bms-table-loader: 1.0.1
commander: 8.3.0
fast-xml-parser: 4.0.2
mei-logger: 1.0.3
+6 -2
View File
@@ -15,5 +15,9 @@ our goals.
```
pnpm install
pnpm run
```
pnpm calc-v1
```
## Synchronising with seeds
Run `ts-node database-seeds/scripts/rerunners/bms-pms/apply-sieglinde`.
+1
View File
@@ -12,6 +12,7 @@
"license": "MIT",
"dependencies": {
"@types/node-fetch": "2",
"bms-table-loader": "^1.0.1",
"commander": "^8.3.0",
"fast-xml-parser": "^4.0.0-beta.2",
"mei-logger": "^1.0.1",
+1 -1
View File
@@ -135,7 +135,7 @@ export default async function SieglindeV1Calc(tableInfo: TableRes): Promise<Arra
return {
md5: chart.md5,
title: chart.title,
title: "title" in chart ? String(chart.title) : "",
baseLevel: GetFString(tableInfo.table, chart),
ec: ecVal,
+6 -5
View File
@@ -1,24 +1,25 @@
/* eslint-disable no-await-in-loop */
import { LoadBMSTable } from "bms-table-loader";
import TableValueGetters from "lookups";
import fetch from "node-fetch";
import { BMS_TABLES } from "tachi-common";
import type { BMSTablesDataset, BMSTableChart } from "./types";
import type { BMSTablesDataset } from "./types";
import type { BMSTableEntry } from "bms-table-loader";
// only 7k supported atm
const registeredTables: Array<BMSTablesDataset> = BMS_TABLES.filter((e) => e.playtype === "7K");
export interface TableRes {
table: BMSTablesDataset;
charts: Array<BMSTableChart>;
charts: Array<BMSTableEntry>;
}
export default async function GetTableData(): Promise<Array<TableRes>> {
const out = [];
for (const table of registeredTables.filter((e) => e.name in TableValueGetters)) {
const charts = await fetch(table.url).then((r) => r.json());
const bmsTable = await LoadBMSTable(table.url);
out.push({ table, charts });
out.push({ table, charts: bmsTable.body });
}
return out;
+1 -1
View File
@@ -1,6 +1,6 @@
const TableValueGetters: Record<
"Insane" | "Insane2" | "Normal" | "Normal2" | "Overjoy" | "Satellite" | "Stella",
(x: string) => number | null
(x: number | string) => number | null
> = {
Insane: (c) => {
const n = Number(c);
-10
View File
@@ -6,16 +6,6 @@ export interface BMSTablesDataset {
prefix: string;
}
export interface BMSTableChart {
title: string;
artist: string;
url: string;
url_diff: string;
md5: string;
sha256: string;
level: string;
}
export interface CalcReturns {
md5: string;
title: string;
+9 -7
View File
@@ -8,7 +8,8 @@ import TableValueGetters from "./lookups";
import { XMLParser } from "fast-xml-parser";
import fetch from "node-fetch";
import { writeFile, readFile } from "fs/promises";
import type { BMSTableChart, BMSTablesDataset } from "./types";
import type { BMSTablesDataset } from "./types";
import type { BMSTableEntry } from "bms-table-loader";
const parser = new XMLParser();
@@ -26,11 +27,12 @@ export async function FetchScoresForMD5(md5: string) {
`http://dream-pro.info/~lavalse/LR2IR/2/getrankingxml.cgi?songmd5=${md5}&id=1`
).then((r) => r.text());
const data = parser.parse(scores).ranking.score;
let data = parser.parse(scores).ranking.score;
// in the event this thing has only one score
// it won't be an array due to xml parsing. patch this by hand.
if (!Array.isArray(data)) {
logger.error(`Got rate limited for ${md5}!`, { data });
throw new Error(`Got rate limited on ${md5}.`);
data = [data];
}
// xml sucks
@@ -86,13 +88,13 @@ export function GetSigmoidalValue(x: number) {
return 0.5 * (1 + Math.sin(x * Math.PI - Math.PI / 2));
}
export function GetBaseline(table: BMSTablesDataset, level: string): number | null {
export function GetBaseline(table: BMSTablesDataset, level: number | string): number | null {
// @ts-expect-error don't care it's exhaustive
return TableValueGetters[table.name](level);
}
export function GetFString(table: BMSTablesDataset, chart: BMSTableChart) {
return table.prefix + chart.level;
export function GetFString(table: BMSTablesDataset, chart: BMSTableEntry) {
return table.prefix + chart.level.toString();
}
export function Sleep(ms: number) {