mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-08 22:59:52 +03:00
fix goal config stuff
This commit is contained in:
Vendored
-8
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user