checkpoint: 16

This commit is contained in:
zkldi
2023-01-19 16:39:31 +00:00
parent f4db781f9d
commit a046fceb4c
44 changed files with 200 additions and 197 deletions
+13 -11
View File
@@ -1,6 +1,12 @@
import { IsString } from "./misc";
import { GetGamePTConfig } from "tachi-common";
import type { Game, GamePTConfig, Playtype } from "tachi-common";
import type {
AnyProfileRatingAlg,
AnyScoreRatingAlg,
AnySessionRatingAlg,
Game,
Playtype,
} from "tachi-common";
const isIntegerRegex = /^-?\d+$/u;
@@ -44,39 +50,35 @@ export function ParseStrPositiveNonZeroInt(val: unknown) {
return v;
}
export type ProfileRatingAlgs = GamePTConfig["defaultProfileRatingAlg"];
export type ScoreRatingAlgs = GamePTConfig["defaultScoreRatingAlg"];
export type SessionRatingAlgs = GamePTConfig["defaultSessionRatingAlg"];
export function CheckStrProfileAlg(game: Game, playtype: Playtype, strVal: string) {
const gptConfig = GetGamePTConfig(game, playtype);
// @hack
if (!gptConfig.profileRatingAlgs.includes(strVal as ProfileRatingAlgs)) {
if (!Object.keys(gptConfig.profileRatingAlgs).includes(strVal as AnyProfileRatingAlg)) {
return null;
}
return strVal as ProfileRatingAlgs;
return strVal as AnyProfileRatingAlg;
}
export function CheckStrScoreAlg(game: Game, playtype: Playtype, strVal: string) {
const gptConfig = GetGamePTConfig(game, playtype);
// @hack
if (!gptConfig.scoreRatingAlgs.includes(strVal as ScoreRatingAlgs)) {
if (!Object.keys(gptConfig.scoreRatingAlgs).includes(strVal as AnyScoreRatingAlg)) {
return null;
}
return strVal as ScoreRatingAlgs;
return strVal as AnyScoreRatingAlg;
}
export function CheckStrSessionAlg(game: Game, playtype: Playtype, strVal: string) {
const gptConfig = GetGamePTConfig(game, playtype);
// @hack
if (!gptConfig.sessionRatingAlgs.includes(strVal as SessionRatingAlgs)) {
if (!Object.keys(gptConfig.sessionRatingAlgs).includes(strVal as AnySessionRatingAlg)) {
return null;
}
return strVal as SessionRatingAlgs;
return strVal as AnySessionRatingAlg;
}