diff --git a/server/src/external/mongo/schemas.ts b/server/src/external/mongo/schemas.ts index 9c2d44dcb..6b040b0b3 100644 --- a/server/src/external/mongo/schemas.ts +++ b/server/src/external/mongo/schemas.ts @@ -1,13 +1,5 @@ import deepmerge from "deepmerge"; import { Game, Playtypes } from "tachi-common"; -import { - grades, - importTypes, - lamps, - validHitData, - validDifficulties, - validPlaytypes, -} from "tachi-common/js/config"; import p, { PrudenceSchema, ValidSchemaValue } from "prudence"; import { CONF_INFO } from "../../lib/setup/config"; diff --git a/server/src/lib/achievables/goals.ts b/server/src/lib/achievables/goals.ts index 7dbdf6151..ed674b90e 100644 --- a/server/src/lib/achievables/goals.ts +++ b/server/src/lib/achievables/goals.ts @@ -1,5 +1,11 @@ -import { GoalDocument, integer, PBScoreDocument, Game } from "tachi-common"; -import { grades, lamps } from "tachi-common/js/config"; +import { + GoalDocument, + integer, + PBScoreDocument, + Game, + GetGamePTConfig, + Playtypes, +} from "tachi-common"; import db from "../../external/mongo/db"; import { KtLogger } from "../logger/logger"; import { GetFolderChartIDs } from "../../utils/folder"; @@ -69,6 +75,7 @@ export async function EvaluateGoalForUser( const outOfHuman = HumaniseGoalProgress( goal.game, + goal.playtype, goal.criteria.key, goal.criteria.value, null @@ -82,6 +89,7 @@ export async function EvaluateGoalForUser( outOfHuman, progressHuman: HumaniseGoalProgress( goal.game, + goal.playtype, goal.criteria.key, res.scoreData[scoreDataKey], res @@ -120,6 +128,7 @@ export async function EvaluateGoalForUser( progress: nextBestScore.scoreData[scoreDataKey], progressHuman: HumaniseGoalProgress( goal.game, + goal.playtype, goal.criteria.key, nextBestScore.scoreData[scoreDataKey], nextBestScore @@ -192,20 +201,22 @@ type IIDXOrBMSPB = PBScoreDocument<"iidx:SP" | "iidx:DP" | "bms:7K" | "bms:14K"> // @todo, #100 improve this (add things like BP for iidx, maybe, percents for scores?) export function HumaniseGoalProgress( game: Game, + playtype: Playtypes[Game], key: GoalKeys, value: number, userPB: PBScoreDocument | null ): string { + const gptConfig = GetGamePTConfig(game, playtype); switch (key) { case "scoreData.gradeIndex": - return grades[game][value]; + return gptConfig.grades[value]; case "scoreData.lampIndex": if (userPB && (game === "iidx" || game === "bms")) { - return `${lamps[game][value]} (BP: ${ + return `${gptConfig.lamps[value]} (BP: ${ (userPB as IIDXOrBMSPB).scoreData.hitMeta.bp ?? "N/A" })`; } - return lamps[game][value]; + return gptConfig.lamps[value]; case "scoreData.percent": return `${value.toFixed(2)}%`; case "scoreData.score": diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.ts index 36f507a8d..3eab3a035 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.ts @@ -2,11 +2,7 @@ import { Router } from "express"; import db from "../../../../../../../../../external/mongo/db"; import { SYMBOL_TachiData } from "../../../../../../../../../lib/constants/tachi"; import { GetRelevantSongsAndCharts } from "../../../../../../../../../utils/db"; -import { - GetDefaultScoreRatingAlg, - GetDefaultSessionRatingAlg, - GetUsersRanking, -} from "../../../../../../../../../utils/user"; +import { GetUsersRanking } from "../../../../../../../../../utils/user"; import { CheckUserPlayedGamePlaytype } from "./middleware"; import { FilterQuery } from "mongodb"; import { UserGoalDocument, UserMilestoneDocument, GetGamePTConfig } from "tachi-common";