From 69c8ea177130e0215b7ba4e32b7f8474dc95f723 Mon Sep 17 00:00:00 2001 From: zkldi Date: Mon, 16 Aug 2021 06:06:28 +0100 Subject: [PATCH] update chart and song types --- common/src/legacy/legacy-config.ts | 12 ++++++------ common/src/types.ts | 14 +++----------- common/src/utils/util.ts | 6 +++--- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/common/src/legacy/legacy-config.ts b/common/src/legacy/legacy-config.ts index 70b15735b..a41c590a0 100644 --- a/common/src/legacy/legacy-config.ts +++ b/common/src/legacy/legacy-config.ts @@ -5,7 +5,7 @@ // disable all type checking, this is a legacy file and is only kept around // as a reference -import { Game, Playtypes, ChartDocument, AnyChartDocument } from "../types"; +import { Game, Playtypes, ChartDocument, ChartDocument } from "../types"; // human readable stuff for versions const versionHuman: Record> = { @@ -393,7 +393,7 @@ function DirectScoreGradeDelta( game: Game, score: number, percent: number, - chart: AnyChartDocument, + chart: ChartDocument, delta: number ): SGDReturn | null { const grade = GetGrade(game, percent); @@ -428,7 +428,7 @@ interface PartialScore { function ScoreGradeDelta( game: Game, score: PartialScore, - chart: AnyChartDocument, + chart: ChartDocument, delta: number ): SGDReturn | null { const nextGrade = grades[game][grades[game].indexOf(score.scoreData.grade) + delta]; @@ -479,7 +479,7 @@ function AbsoluteScoreGradeDelta( } as unknown; // heheh } - const sc = CalculateScore(game, gradeBoundaries[game][absDelta], chart as AnyChartDocument); + const sc = CalculateScore(game, gradeBoundaries[game][absDelta], chart as ChartDocument); if (sc) { const delta = score - sc; let formattedString = `(${grade})`; @@ -497,7 +497,7 @@ function AbsoluteScoreGradeDelta( } } -function CalculateScore(game: Game, percent: number, chart: AnyChartDocument): number | null { +function CalculateScore(game: Game, percent: number, chart: ChartDocument): number | null { let score = percent; if (game === "iidx" || game === "bms") { @@ -516,7 +516,7 @@ function CalculateScore(game: Game, percent: number, chart: AnyChartDocument): n return null; } -function PercentToScore(percent: number, game: Game, chartData: AnyChartDocument): number { +function PercentToScore(percent: number, game: Game, chartData: ChartDocument): number { let eScore = 0; if (game === "iidx" || game === "bms") { diff --git a/common/src/types.ts b/common/src/types.ts index 807b25968..0278de9d9 100644 --- a/common/src/types.ts +++ b/common/src/types.ts @@ -823,18 +823,13 @@ interface ChartDocumentData { "gitadora:Dora": { inGameID: integer }; } -export interface AnyChartDocument extends MongoDBDocument { +export interface ChartDocument extends MongoDBDocument { chartID: string; rgcID: string | null; // ID to perform backbeat lookup in future. songID: integer; level: string; levelNum: number; - difficulty: Difficulties[IDStrings]; - playtype: AnyPlaytype; isPrimary: boolean; -} - -export interface ChartDocument extends AnyChartDocument { difficulty: Difficulties[I]; playtype: IDStringToPlaytype[I]; data: ChartDocumentData[I]; @@ -906,7 +901,7 @@ interface SongDocumentData { gitadora: { isHot: boolean }; } -export interface AnySongDocument extends MongoDBDocument { +export interface AnySongDocument extends MongoDBDocument { id: integer; title: string; artist: string; @@ -920,9 +915,6 @@ export interface AnySongDocument extends MongoDBDocument { * requested. */ "alt-titles": string[]; -} - -export interface SongDocument extends AnySongDocument { data: SongDocumentData[G]; } @@ -949,7 +941,7 @@ export interface FolderSongsDocument extends BaseFolderDocument { export interface FolderChartsDocument extends BaseFolderDocument { type: "charts"; - data: FilterQuery; + data: FilterQuery; } export interface FolderStaticDocument extends BaseFolderDocument { diff --git a/common/src/utils/util.ts b/common/src/utils/util.ts index 16c035fdd..6f3f711a5 100644 --- a/common/src/utils/util.ts +++ b/common/src/utils/util.ts @@ -1,7 +1,7 @@ -import { AnyChartDocument, AnySongDocument, ChartDocument, Game, IDStrings, Playtypes } from ".."; +import { ChartDocument, AnySongDocument, ChartDocument, Game, IDStrings, Playtypes } from ".."; import { GetGameConfig, GetGamePTConfig } from "../config/config"; -export function FormatDifficulty(chart: AnyChartDocument, game: Game): string { +export function FormatDifficulty(chart: ChartDocument, game: Game): string { const gameConfig = GetGameConfig(game); if (game === "bms") { @@ -19,7 +19,7 @@ export function FormatDifficulty(chart: AnyChartDocument, game: Game): string { * Formats a chart's difficulty into a shorter variant. This handles a lot of * game-specific strange edge cases. */ -export function FormatDifficultyShort(chart: AnyChartDocument, game: Game): string { +export function FormatDifficultyShort(chart: ChartDocument, game: Game): string { const gameConfig = GetGameConfig(game); const gptConfig = GetGamePTConfig(game, chart.playtype); const shortDiff = gptConfig.shortDifficulties[chart.difficulty] ?? chart.difficulty;