fix goal config stuff

This commit is contained in:
zkldi
2021-06-20 15:32:51 +01:00
parent d8b78116c8
commit cb8300b7ca
3 changed files with 17 additions and 18 deletions
-8
View File
@@ -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";
+16 -5
View File
@@ -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":
@@ -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";