mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-29 10:28:04 +03:00
update chart and song types
This commit is contained in:
@@ -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<Game, Record<string, string>> = {
|
||||
@@ -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") {
|
||||
|
||||
+3
-11
@@ -823,18 +823,13 @@ interface ChartDocumentData {
|
||||
"gitadora:Dora": { inGameID: integer };
|
||||
}
|
||||
|
||||
export interface AnyChartDocument extends MongoDBDocument {
|
||||
export interface ChartDocument<I extends IDStrings = IDStrings> 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<I extends IDStrings> 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<G extends Game = Game> extends MongoDBDocument {
|
||||
id: integer;
|
||||
title: string;
|
||||
artist: string;
|
||||
@@ -920,9 +915,6 @@ export interface AnySongDocument extends MongoDBDocument {
|
||||
* requested.
|
||||
*/
|
||||
"alt-titles": string[];
|
||||
}
|
||||
|
||||
export interface SongDocument<G extends Game> extends AnySongDocument {
|
||||
data: SongDocumentData[G];
|
||||
}
|
||||
|
||||
@@ -949,7 +941,7 @@ export interface FolderSongsDocument extends BaseFolderDocument {
|
||||
|
||||
export interface FolderChartsDocument extends BaseFolderDocument {
|
||||
type: "charts";
|
||||
data: FilterQuery<AnyChartDocument>;
|
||||
data: FilterQuery<ChartDocument>;
|
||||
}
|
||||
|
||||
export interface FolderStaticDocument extends BaseFolderDocument {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user