mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-12 09:18:25 +03:00
factor out SUPPORTED_GAMES
This commit is contained in:
Vendored
+2
-2
@@ -7,9 +7,9 @@ import {
|
||||
validHitData,
|
||||
validDifficulties,
|
||||
validPlaytypes,
|
||||
supportedGames,
|
||||
} from "tachi-common/js/config";
|
||||
import p, { PrudenceSchema, ValidSchemaValue } from "prudence";
|
||||
import { CONF_INFO } from "../../lib/setup/config";
|
||||
|
||||
const LAZY_EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/u;
|
||||
|
||||
@@ -408,7 +408,7 @@ const PRUDENCE_FOLDER_CHART_LOOKUP: PrudenceSchema = {
|
||||
|
||||
const PRUDENCE_FOLDER: PrudenceSchema = {
|
||||
title: "string",
|
||||
game: p.isIn(supportedGames),
|
||||
game: p.isIn(CONF_INFO.SUPPORTED_GAMES),
|
||||
playtype: (self, parent) => p.isIn(validPlaytypes[parent.game as Game])(self),
|
||||
folderID: "string",
|
||||
table: "string",
|
||||
|
||||
@@ -2,12 +2,13 @@ import { KtLogger } from "../../../../logger/logger";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
import { BatchManual, BatchManualContext, BatchManualScore } from "./types";
|
||||
import p, { PrudenceSchema, ValidSchemaValue } from "prudence";
|
||||
import { lamps, supportedGames, validHitData, validPlaytypes } from "tachi-common/js/config";
|
||||
import { lamps, validHitData, validPlaytypes } from "tachi-common/js/config";
|
||||
import { Game, ImportTypes } from "tachi-common";
|
||||
import { ConverterBatchManual } from "./converter";
|
||||
import deepmerge from "deepmerge";
|
||||
import { FormatPrError } from "../../../../../utils/prudence";
|
||||
import { ParserFunctionReturnsSync } from "../types";
|
||||
import { CONF_INFO } from "../../../../setup/config";
|
||||
|
||||
const optNull = (v: ValidSchemaValue) => p.optional(p.nullable(v));
|
||||
|
||||
@@ -101,7 +102,7 @@ const PR_BatchManualScore = (game: Game): PrudenceSchema => ({
|
||||
const PR_BatchManual = (game: Game): PrudenceSchema => ({
|
||||
head: {
|
||||
service: p.isBoundedString(3, 15),
|
||||
game: p.isIn(supportedGames),
|
||||
game: p.isIn(CONF_INFO.SUPPORTED_GAMES),
|
||||
version: "*?string",
|
||||
},
|
||||
body: [PR_BatchManualScore(game)],
|
||||
@@ -140,10 +141,10 @@ export function ParseBatchManualFromObject(
|
||||
);
|
||||
}
|
||||
|
||||
if (!supportedGames.includes(possiblyGame)) {
|
||||
if (!CONF_INFO.SUPPORTED_GAMES.includes(possiblyGame)) {
|
||||
throw new ScoreImportFatalError(
|
||||
400,
|
||||
`Invalid game ${possiblyGame} - expected any of ${supportedGames.join(", ")}`
|
||||
`Invalid game ${possiblyGame} - expected any of ${CONF_INFO.SUPPORTED_GAMES.join(", ")}`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ import JSON5 from "json5";
|
||||
import fs from "fs";
|
||||
import p from "prudence";
|
||||
import { FormatPrError } from "../../utils/prudence";
|
||||
import { integer } from "tachi-common";
|
||||
|
||||
import { integer, Game } from "tachi-common";
|
||||
dotenv.config(); // imports things like NODE_ENV from a local .env file if one is present.
|
||||
|
||||
// reads from $pwd/conf.json5
|
||||
@@ -38,8 +37,9 @@ export interface TachiConfig {
|
||||
CDN_ROOT: string;
|
||||
TYPE: "ktchi" | "btchi" | "omni";
|
||||
PORT: integer;
|
||||
INFO: {
|
||||
TYPE_INFO: {
|
||||
NAME: string;
|
||||
SUPPORTED_GAMES: Game[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,15 +64,17 @@ if (err) {
|
||||
/**
|
||||
* KTCHI | Kamaitachi is the arcade build of Tachi.
|
||||
*/
|
||||
const KTCHI_INFO: TachiConfig["INFO"] = {
|
||||
const KTCHI_INFO: TachiConfig["TYPE_INFO"] = {
|
||||
NAME: "Kamaitachi",
|
||||
SUPPORTED_GAMES: ["iidx", "gitadora", "chunithm", "maimai", "museca", "sdvx"],
|
||||
};
|
||||
|
||||
/**
|
||||
* BTCHI | Bokutachi is the home-simulator build of Tachi.
|
||||
*/
|
||||
const BTCHI_INFO: TachiConfig["INFO"] = {
|
||||
const BTCHI_INFO: TachiConfig["TYPE_INFO"] = {
|
||||
NAME: "Bokutachi",
|
||||
SUPPORTED_GAMES: ["usc", "bms"],
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -81,16 +83,17 @@ const BTCHI_INFO: TachiConfig["INFO"] = {
|
||||
* If you're one of those nerds who is reading this to figure out how to steal and rerun
|
||||
* this codebase this is what you're looking for.
|
||||
*/
|
||||
const OMNI_INFO: TachiConfig["INFO"] = {
|
||||
const OMNI_INFO: TachiConfig["TYPE_INFO"] = {
|
||||
NAME: "Omnitachi",
|
||||
SUPPORTED_GAMES: [...KTCHI_INFO.SUPPORTED_GAMES, ...BTCHI_INFO.SUPPORTED_GAMES],
|
||||
};
|
||||
|
||||
if (config.TYPE === "ktchi") {
|
||||
config.INFO = KTCHI_INFO;
|
||||
config.TYPE_INFO = KTCHI_INFO;
|
||||
} else if (config.TYPE === "btchi") {
|
||||
config.INFO = BTCHI_INFO;
|
||||
config.TYPE_INFO = BTCHI_INFO;
|
||||
} else if (config.type === "omni") {
|
||||
config.INFO = OMNI_INFO;
|
||||
config.TYPE_INFO = OMNI_INFO;
|
||||
}
|
||||
|
||||
const tachiConfig = config as TachiConfig;
|
||||
@@ -104,6 +107,6 @@ export const EAG_API_URL = tachiConfig.EAG_API_URL;
|
||||
export const ARC_API_URL = tachiConfig.ARC_API_URL;
|
||||
export const ARC_AUTH_TOKEN = tachiConfig.ARC_AUTH_TOKEN;
|
||||
export const KTCDN_ROOT = tachiConfig.CDN_ROOT;
|
||||
export const CONF_INFO = tachiConfig.INFO;
|
||||
export const CONF_INFO = tachiConfig.TYPE_INFO;
|
||||
export const PORT = tachiConfig.PORT;
|
||||
export const CONFIG = tachiConfig;
|
||||
|
||||
Reference in New Issue
Block a user