mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-05 13:28:08 +03:00
checkpoint: 16
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user