diff --git a/server/src/score-import/framework/calculated-data/game-specific-stats.ts b/server/src/score-import/framework/calculated-data/game-specific-stats.ts index b8bcc6deb..4a9bc5ec8 100644 --- a/server/src/score-import/framework/calculated-data/game-specific-stats.ts +++ b/server/src/score-import/framework/calculated-data/game-specific-stats.ts @@ -259,3 +259,11 @@ export function CalculateVF5( return Math.floor(level * 2 * percent * gradeCoefficient * lampCoefficient) / 100; } + +// function CalculateJubility( +// dryScore: DryScore<"jubeat:Single">, +// chartData: AnyChartDocument, +// logger: Logger +// ) { +// let rate = dryScore.calculatedData.gameSpecific.musicRate; eurgh, this is hard. +// } diff --git a/server/src/score-import/framework/user-game-stats/builtin-class-handlers.ts b/server/src/score-import/framework/user-game-stats/builtin-class-handlers.ts new file mode 100644 index 000000000..28186308a --- /dev/null +++ b/server/src/score-import/framework/user-game-stats/builtin-class-handlers.ts @@ -0,0 +1,63 @@ +import { Game, Playtypes, integer } from "kamaitachi-common"; + +export function CalculateGitadoraColour( + game: Game, + playtype: Playtypes[Game], + userID: integer, + customRatings: Record +): Record { + let skillColour = GitadoraSkillToColour(customRatings.skill); + + return { + skillColour, + }; +} + +function GitadoraSkillToColour(sk: number) { + if (sk >= 8500) { + return "rainbow"; + } else if (sk >= 8000) { + return "gold"; + } else if (sk >= 7500) { + return "silver"; + } else if (sk >= 7000) { + return "bronze"; + } else if (sk >= 6500) { + return "redgradient"; + } else if (sk >= 6000) { + return "red"; + } else if (sk >= 5500) { + return "purplegradient"; + } else if (sk >= 5000) { + return "purple"; + } else if (sk >= 4500) { + return "bluegradient"; + } else if (sk >= 4000) { + return "blue"; + } else if (sk >= 3500) { + return "greengradient"; + } else if (sk >= 3000) { + return "green"; + } else if (sk >= 2500) { + return "yellowgradient"; + } else if (sk > 2000) { + return "yellow"; + } else if (sk > 1500) { + return "orangegradient"; + } else if (sk > 1000) { + return "orange"; + } + + return "white"; +} + +export function CalculateJubeatColour( + game: Game, + playtype: Playtypes[Game], + userID: integer, + customRatings: Record +): Promise> { + throw new Error("Not implemented."); +} + +function JubilityToColour(jb: number) {} diff --git a/server/src/score-import/framework/user-game-stats/classes.ts b/server/src/score-import/framework/user-game-stats/classes.ts index b0f4bea0b..40c9faa3e 100644 --- a/server/src/score-import/framework/user-game-stats/classes.ts +++ b/server/src/score-import/framework/user-game-stats/classes.ts @@ -3,6 +3,7 @@ import { gameClassValues, ClassData } from "kamaitachi-common/js/game-classes"; import deepmerge from "deepmerge"; import db from "../../../db/db"; import { KtLogger } from "../../../types"; +import { CalculateGitadoraColour, CalculateJubeatColour } from "./builtin-class-handlers"; export interface ClassHandler { ( @@ -10,7 +11,7 @@ export interface ClassHandler { playtype: Playtypes[Game], userID: integer, customRatings: Record - ): Promise>; + ): Promise> | Record; } type ClassHandlerMap = { @@ -21,28 +22,6 @@ type ClassHandlerMap = { | null; }; -// stub functions, see githubissues - -// eslint-disable-next-line require-await -async function CalculateGitadoraColour( - game: Game, - playtype: Playtypes[Game], - userID: integer, - customRatings: Record -): Promise> { - throw new Error("Not implemented."); -} - -// eslint-disable-next-line require-await -async function CalculateJubeatColour( - game: Game, - playtype: Playtypes[Game], - userID: integer, - customRatings: Record -): Promise> { - throw new Error("Not implemented."); -} - /** * Describes the "Default" class handlers for a game, I.E. ones that are * always meant to be called when new scores are found. diff --git a/server/src/score-import/framework/user-game-stats/rating.ts b/server/src/score-import/framework/user-game-stats/rating.ts index 486e91959..6a09cc2b4 100644 --- a/server/src/score-import/framework/user-game-stats/rating.ts +++ b/server/src/score-import/framework/user-game-stats/rating.ts @@ -119,8 +119,23 @@ const CUSTOM_RATING_FUNCTIONS = { MFCP: LazySumAll("MFCP"), }, }, + gitadora: { + Gita: CalculateGitadoraSkill, + }, }; +async function CalculateGitadoraSkill( + game: Game, + playtype: Playtypes[Game], + userID: integer, + logger: KtLogger +) { + // let hotCharts = fetchfolder("gitadora_hot"); + // select best 25 scores on hotcharts + // select best 25 scores not on hot charts ("gitadora_nothot?") + // sum. +} + export async function CalculateCustomRatings( game: Game, playtype: Playtypes[Game],