add FormatDifficultyShort

This commit is contained in:
zkldi
2021-07-15 19:57:47 +01:00
parent f72e6877eb
commit e299abddb6
8 changed files with 203 additions and 4 deletions
+1
View File
@@ -16,6 +16,7 @@ interface BaseGamePTConfig<I extends IDStrings> {
sessionRatingAlgs: SessionCalculatedDataLookup[I][];
profileRatingAlgs: UGSRatingsLookup[I][];
difficulties: Difficulties[I][];
shortDifficulties: Partial<Record<Difficulties[I], string>>;
defaultDifficulty: Difficulties[I];
difficultyColours: Record<Difficulties[I], string | null>;
grades: Grades[I][];
+62
View File
@@ -103,6 +103,13 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["ktRating", "ktLampRating", "BPI"],
profileRatingAlgs: ["ktRating", "ktLampRating", "BPI"],
difficulties: ["BEGINNER", "NORMAL", "HYPER", "ANOTHER", "LEGGENDARIA"],
shortDifficulties: {
BEGINNER: "B",
NORMAL: "N",
HYPER: "H",
ANOTHER: "A",
LEGGENDARIA: "L",
},
defaultDifficulty: "ANOTHER",
difficultyColours: {
BEGINNER: exports.COLOUR_SET.paleGreen,
@@ -167,6 +174,12 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["ktRating", "ktLampRating", "BPI"],
profileRatingAlgs: ["ktRating", "ktLampRating", "BPI"],
difficulties: ["NORMAL", "HYPER", "ANOTHER", "LEGGENDARIA"],
shortDifficulties: {
NORMAL: "N",
HYPER: "H",
ANOTHER: "A",
LEGGENDARIA: "L",
},
defaultDifficulty: "ANOTHER",
difficultyColours: {
NORMAL: exports.COLOUR_SET.blue,
@@ -230,6 +243,13 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["naiveRating"],
profileRatingAlgs: ["naiveRating"],
difficulties: ["BASIC", "ADVANCED", "EXPERT", "MASTER", "WORLD'S END"],
shortDifficulties: {
BASIC: "B",
ADVANCED: "A",
EXPERT: "E",
MASTER: "M",
"WORLD'S END": "W",
},
defaultDifficulty: "MASTER",
difficultyColours: {
BASIC: exports.COLOUR_SET.blue,
@@ -278,6 +298,7 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["ProfileVF6", "VF6"],
profileRatingAlgs: ["VF6"],
difficulties: ["NOV", "ADV", "EXH", "INF", "GRV", "HVN", "VVD", "MXM"],
shortDifficulties: {},
defaultDifficulty: "EXH",
difficultyColours: {
NOV: exports.COLOUR_SET.purple,
@@ -328,6 +349,7 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["ProfileVF6", "VF6"],
profileRatingAlgs: ["VF6"],
difficulties: ["NOV", "ADV", "EXH", "INF"],
shortDifficulties: {},
defaultDifficulty: "EXH",
difficultyColours: {
NOV: exports.COLOUR_SET.purple,
@@ -374,6 +396,7 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["ktRating"],
profileRatingAlgs: ["ktRating"],
difficulties: ["Green", "Yellow", "Red"],
shortDifficulties: { Green: "G", Yellow: "Y", Red: "R" },
defaultDifficulty: "Red",
difficultyColours: {
Green: exports.COLOUR_SET.green,
@@ -421,6 +444,7 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["sieglinde"],
profileRatingAlgs: ["sieglinde"],
difficulties: ["CHART"],
shortDifficulties: {},
defaultDifficulty: "CHART",
difficultyColours: {
CHART: null,
@@ -476,6 +500,7 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["sieglinde"],
profileRatingAlgs: ["sieglinde"],
difficulties: ["CHART"],
shortDifficulties: {},
defaultDifficulty: "CHART",
difficultyColours: {
CHART: null,
@@ -531,6 +556,13 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["MFCP", "ktRating"],
profileRatingAlgs: ["MFCP", "ktRating"],
difficulties: ["BEGINNER", "BASIC", "DIFFICULT", "EXPERT", "CHALLENGE"],
shortDifficulties: {
BEGINNER: "b",
BASIC: "B",
DIFFICULT: "D",
EXPERT: "E",
CHALLENGE: "C",
},
defaultDifficulty: "EXPERT",
difficultyColours: {
BEGINNER: exports.COLOUR_SET.paleBlue,
@@ -616,6 +648,12 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["MFCP", "ktRating"],
profileRatingAlgs: ["MFCP", "ktRating"],
difficulties: ["BASIC", "DIFFICULT", "EXPERT", "CHALLENGE"],
shortDifficulties: {
BASIC: "B",
DIFFICULT: "D",
EXPERT: "E",
CHALLENGE: "C",
},
defaultDifficulty: "EXPERT",
difficultyColours: {
BASIC: exports.COLOUR_SET.orange,
@@ -700,6 +738,14 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["ktRating"],
profileRatingAlgs: ["ktRating"],
difficulties: ["Easy", "Basic", "Advanced", "Expert", "Master", "Re:Master"],
shortDifficulties: {
Easy: "e",
Basic: "B",
Advanced: "A",
Expert: "E",
Master: "M",
"Re:Master": "Re",
},
defaultDifficulty: "Master",
difficultyColours: {
Easy: exports.COLOUR_SET.blue,
@@ -763,6 +809,16 @@ const GAME_PT_CONFIGS = {
"BASS EXTREME",
"BASS MASTER",
],
shortDifficulties: {
BASIC: "BSC",
ADVANCED: "ADV",
EXTREME: "EXT",
MASTER: "MAS",
"BASS BASIC": "B-BSC",
"BASS ADVANCED": "B-ADV",
"BASS EXTREME": "B-EXT",
"BASS MASTER": "B-MAS",
},
defaultDifficulty: "EXTREME",
difficultyColours: {
BASIC: exports.COLOUR_SET.blue,
@@ -808,6 +864,12 @@ const GAME_PT_CONFIGS = {
sessionRatingAlgs: ["skill"],
profileRatingAlgs: ["skill"],
difficulties: ["BASIC", "ADVANCED", "EXTREME", "MASTER"],
shortDifficulties: {
BASIC: "BSC",
ADVANCED: "ADV",
EXTREME: "EXT",
MASTER: "MAS",
},
defaultDifficulty: "EXTREME",
difficultyColours: {
BASIC: exports.COLOUR_SET.blue,
File diff suppressed because one or more lines are too long
+5
View File
@@ -1,3 +1,8 @@
import { AnyChartDocument, Game, Playtypes } from "..";
export declare function FormatDifficulty(chart: AnyChartDocument, game: Game): string;
/**
* Formats a chart's difficulty into a shorter variant. This handles a lot of
* game-specific strange edge cases.
*/
export declare function FormatDifficultyShort(chart: AnyChartDocument, game: Game): string;
export declare function FormatGame(game: Game, playtype: Playtypes[Game]): string;
+31 -1
View File
@@ -1,15 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormatGame = exports.FormatDifficulty = void 0;
exports.FormatGame = exports.FormatDifficultyShort = exports.FormatDifficulty = void 0;
const config_1 = require("../config/config");
function FormatDifficulty(chart, game) {
const gameConfig = config_1.GetGameConfig(game);
if (game === "bms") {
return `${chart.playtype} ${chart.level}`;
}
if (gameConfig.validPlaytypes.length > 1) {
return `${chart.playtype} ${chart.difficulty} ${chart.level}`;
}
return `${chart.difficulty}`;
}
exports.FormatDifficulty = FormatDifficulty;
/**
* Formats a chart's difficulty into a shorter variant. This handles a lot of
* game-specific strange edge cases.
*/
function FormatDifficultyShort(chart, game) {
var _a;
const gameConfig = config_1.GetGameConfig(game);
const gptConfig = config_1.GetGamePTConfig(game, chart.playtype);
const shortDiff = (_a = gptConfig.shortDifficulties[chart.difficulty]) !== null && _a !== void 0 ? _a : chart.difficulty;
if (game === "bms") {
return `${chart.playtype} ${chart.level}`;
}
if (game === "gitadora" && chart.playtype === "Gita") {
if (chart.difficulty.startsWith("BASS ")) {
return shortDiff;
}
return `G-${shortDiff}`;
}
if (game === "ddr") {
return `${shortDiff}${chart.playtype}`;
}
if (gameConfig.validPlaytypes.length === 1) {
return shortDiff;
}
return `${chart.playtype} ${shortDiff}`;
}
exports.FormatDifficultyShort = FormatDifficultyShort;
function FormatGame(game, playtype) {
const gameConfig = config_1.GetGameConfig(game);
if (gameConfig.validPlaytypes.length === 1) {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/utils/util.ts"],"names":[],"mappings":";;;AACA,6CAAiD;AAEjD,SAAgB,gBAAgB,CAAC,KAAuB,EAAE,IAAU;IACnE,MAAM,UAAU,GAAG,sBAAa,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,UAAU,CAAC,cAAc,CA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xD,MAAM,SAAS,GAAG,MAAA,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,mCAAI,KAAK,CAAC,UAAU,CAAC;IAEpF,IAAI,IAAI,KAAK,KAAK,EAAE;QACnB,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;KAC1C;IAED,IAAI,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,EAAE;QACrD,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YACzC,OAAO,SAAS,CAAC;SACjB;QAED,OAAO,KAAK,SAAS,EAAE,CAAC;KACxB;IAED,IAAI,IAAI,KAAK,KAAK,EAAE;QACnB,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;KACvC;IAED,IAAI,UAAU,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3C,OAAO,SAAS,CAAC;KACjB;IAED,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,SAAS,EAAE,CAAC;AACzC,CAAC;AA1BD,sDA0BC;AAED,SAAgB,UAAU,CAAC,IAAU,EAAE,QAAyB;IAC/D,MAAM,UAAU,GAAG,sBAAa,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,UAAU,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3C,OAAO,UAAU,CAAC,IAAI,CAAC;KACvB;IAED,OAAO,GAAG,UAAU,CAAC,IAAI,KAAK,QAAQ,GAAG,CAAC;AAC3C,CAAC;AARD,gCAQC"}
+63
View File
@@ -32,6 +32,7 @@ interface BaseGamePTConfig<I extends IDStrings> {
profileRatingAlgs: UGSRatingsLookup[I][];
difficulties: Difficulties[I][];
shortDifficulties: Partial<Record<Difficulties[I], string>>;
defaultDifficulty: Difficulties[I];
difficultyColours: Record<Difficulties[I], string | null>;
@@ -180,6 +181,13 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["ktRating", "ktLampRating", "BPI"],
difficulties: ["BEGINNER", "NORMAL", "HYPER", "ANOTHER", "LEGGENDARIA"],
shortDifficulties: {
BEGINNER: "B",
NORMAL: "N",
HYPER: "H",
ANOTHER: "A",
LEGGENDARIA: "L",
},
defaultDifficulty: "ANOTHER",
difficultyColours: {
BEGINNER: COLOUR_SET.paleGreen,
@@ -253,6 +261,12 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["ktRating", "ktLampRating", "BPI"],
difficulties: ["NORMAL", "HYPER", "ANOTHER", "LEGGENDARIA"],
shortDifficulties: {
NORMAL: "N",
HYPER: "H",
ANOTHER: "A",
LEGGENDARIA: "L",
},
defaultDifficulty: "ANOTHER",
difficultyColours: {
NORMAL: COLOUR_SET.blue,
@@ -324,6 +338,13 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["naiveRating"],
difficulties: ["BASIC", "ADVANCED", "EXPERT", "MASTER", "WORLD'S END"],
shortDifficulties: {
BASIC: "B",
ADVANCED: "A",
EXPERT: "E",
MASTER: "M",
"WORLD'S END": "W",
},
defaultDifficulty: "MASTER",
difficultyColours: {
BASIC: COLOUR_SET.blue,
@@ -380,6 +401,7 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["VF6"],
difficulties: ["NOV", "ADV", "EXH", "INF", "GRV", "HVN", "VVD", "MXM"],
shortDifficulties: {}, // they're all fine
defaultDifficulty: "EXH",
difficultyColours: {
NOV: COLOUR_SET.purple, // colour set dark purple
@@ -438,6 +460,7 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["VF6"],
difficulties: ["NOV", "ADV", "EXH", "INF"],
shortDifficulties: {}, // all fine
defaultDifficulty: "EXH",
difficultyColours: {
NOV: COLOUR_SET.purple, // colour set dark purple
@@ -492,6 +515,7 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["ktRating"],
difficulties: ["Green", "Yellow", "Red"],
shortDifficulties: { Green: "G", Yellow: "Y", Red: "R" },
defaultDifficulty: "Red",
difficultyColours: {
Green: COLOUR_SET.green,
@@ -547,6 +571,7 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["sieglinde"],
difficulties: ["CHART"],
shortDifficulties: {}, // not real
defaultDifficulty: "CHART",
difficultyColours: {
CHART: null,
@@ -611,6 +636,7 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["sieglinde"],
difficulties: ["CHART"],
shortDifficulties: {}, // not real
defaultDifficulty: "CHART",
difficultyColours: {
CHART: null,
@@ -675,6 +701,13 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["MFCP", "ktRating"],
difficulties: ["BEGINNER", "BASIC", "DIFFICULT", "EXPERT", "CHALLENGE"],
shortDifficulties: {
BEGINNER: "b",
BASIC: "B",
DIFFICULT: "D",
EXPERT: "E",
CHALLENGE: "C",
},
defaultDifficulty: "EXPERT",
difficultyColours: {
BEGINNER: COLOUR_SET.paleBlue,
@@ -769,6 +802,12 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["MFCP", "ktRating"],
difficulties: ["BASIC", "DIFFICULT", "EXPERT", "CHALLENGE"],
shortDifficulties: {
BASIC: "B",
DIFFICULT: "D",
EXPERT: "E",
CHALLENGE: "C",
},
defaultDifficulty: "EXPERT",
difficultyColours: {
BASIC: COLOUR_SET.orange,
@@ -862,6 +901,14 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["ktRating"],
difficulties: ["Easy", "Basic", "Advanced", "Expert", "Master", "Re:Master"],
shortDifficulties: {
Easy: "e",
Basic: "B",
Advanced: "A",
Expert: "E",
Master: "M",
"Re:Master": "Re",
},
defaultDifficulty: "Master",
difficultyColours: {
Easy: COLOUR_SET.blue,
@@ -934,6 +981,16 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
"BASS EXTREME",
"BASS MASTER",
],
shortDifficulties: {
BASIC: "BSC",
ADVANCED: "ADV",
EXTREME: "EXT",
MASTER: "MAS",
"BASS BASIC": "B-BSC",
"BASS ADVANCED": "B-ADV",
"BASS EXTREME": "B-EXT",
"BASS MASTER": "B-MAS",
},
defaultDifficulty: "EXTREME",
difficultyColours: {
BASIC: COLOUR_SET.blue,
@@ -988,6 +1045,12 @@ const GAME_PT_CONFIGS: GamePTConfigs = {
profileRatingAlgs: ["skill"],
difficulties: ["BASIC", "ADVANCED", "EXTREME", "MASTER"],
shortDifficulties: {
BASIC: "BSC",
ADVANCED: "ADV",
EXTREME: "EXT",
MASTER: "MAS",
},
defaultDifficulty: "EXTREME",
difficultyColours: {
BASIC: COLOUR_SET.blue,
+39 -1
View File
@@ -1,8 +1,14 @@
import { AnyChartDocument, Game, Playtypes } from "..";
import { GetGameConfig } from "../config/config";
import { GamePTConfig, GetGameConfig, GetGamePTConfig } from "../config/config";
import { Difficulties, IDStrings } from "../types";
export function FormatDifficulty(chart: AnyChartDocument, game: Game): string {
const gameConfig = GetGameConfig(game);
if (game === "bms") {
return `${chart.playtype} ${chart.level}`;
}
if (gameConfig.validPlaytypes.length > 1) {
return `${chart.playtype} ${chart.difficulty} ${chart.level}`;
}
@@ -10,6 +16,38 @@ export function FormatDifficulty(chart: AnyChartDocument, game: Game): string {
return `${chart.difficulty}`;
}
/**
* Formats a chart's difficulty into a shorter variant. This handles a lot of
* game-specific strange edge cases.
*/
export function FormatDifficultyShort(chart: AnyChartDocument, game: Game): string {
const gameConfig = GetGameConfig(game);
const gptConfig = GetGamePTConfig(game, chart.playtype);
const shortDiff = gptConfig.shortDifficulties[chart.difficulty] ?? chart.difficulty;
if (game === "bms") {
return `${chart.playtype} ${chart.level}`;
}
if (game === "gitadora" && chart.playtype === "Gita") {
if (chart.difficulty.startsWith("BASS ")) {
return shortDiff;
}
return `G-${shortDiff}`;
}
if (game === "ddr") {
return `${shortDiff}${chart.playtype}`;
}
if (gameConfig.validPlaytypes.length === 1) {
return shortDiff;
}
return `${chart.playtype} ${shortDiff}`;
}
export function FormatGame(game: Game, playtype: Playtypes[Game]): string {
const gameConfig = GetGameConfig(game);