mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-28 01:48:11 +03:00
port chunithm
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { ChartDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
|
||||
const logger = CreateLogCtx("charts-chunithm.ts");
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"chunithm:Single">> {
|
||||
let song = await db.songs.chunithm.findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
if (!song) {
|
||||
logger.severe(`Cannot find song with ID ${c.id}?`);
|
||||
throw new Error(`Cannot find song with ID ${c.id}?`);
|
||||
}
|
||||
|
||||
const newChartDoc: ChartDocument<"chunithm:Single"> = {
|
||||
rgcID: null,
|
||||
chartID: c.chartID,
|
||||
difficulty: c.difficulty,
|
||||
songID: c.id,
|
||||
playtype: c.playtype,
|
||||
levelNum: c.levelNum,
|
||||
level: c.level.toString(),
|
||||
flags: {
|
||||
"IN BASE GAME": !!c.flags["IN BASE GAME"],
|
||||
OMNIMIX: !!c.flags.OMNIMIX,
|
||||
},
|
||||
data: {
|
||||
inGameID: c.internals.inGameINTID,
|
||||
},
|
||||
isPrimary: true,
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.chunithm.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
newChartDoc.versions = [song.firstVersion!];
|
||||
} else {
|
||||
newChartDoc.versions = gameOrders.chunithm.slice(idx);
|
||||
}
|
||||
|
||||
return newChartDoc;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await MigrateRecords(db.charts.chunithm, "charts-chunithm", ConvertFn);
|
||||
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -0,0 +1,27 @@
|
||||
import { SongDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import MigrateRecords from "./migrate";
|
||||
|
||||
function ConvertFn(c: any): SongDocument<"chunithm"> {
|
||||
const newSongDoc: SongDocument<"chunithm"> = {
|
||||
title: c.title,
|
||||
artist: c.artist,
|
||||
id: c.id,
|
||||
firstVersion: c.firstAppearance,
|
||||
"alt-titles": c["alt-titles"].filter((e: string) => e !== c.title),
|
||||
"search-titles": c["search-titles"]
|
||||
.map((e: string) => e.toString())
|
||||
.filter((e: string) => e !== c.title),
|
||||
data: {
|
||||
genre: c.genre,
|
||||
},
|
||||
};
|
||||
|
||||
return newSongDoc;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await MigrateRecords(db.songs.chunithm, "songs-chunithm", ConvertFn);
|
||||
|
||||
process.exit(0);
|
||||
})();
|
||||
Reference in New Issue
Block a user