This commit is contained in:
zkldi
2021-05-03 00:15:02 +01:00
parent cded8d0dac
commit 5bbcfe9ec1
4 changed files with 88 additions and 23 deletions
@@ -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.
// }
@@ -0,0 +1,63 @@
import { Game, Playtypes, integer } from "kamaitachi-common";
export function CalculateGitadoraColour(
game: Game,
playtype: Playtypes[Game],
userID: integer,
customRatings: Record<string, number>
): Record<string, string> {
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<string, number>
): Promise<Record<string, string>> {
throw new Error("Not implemented.");
}
function JubilityToColour(jb: number) {}
@@ -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<string, number>
): Promise<Record<string, string>>;
): Promise<Record<string, string>> | Record<string, string>;
}
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<string, number>
): Promise<Record<string, string>> {
throw new Error("Not implemented.");
}
// eslint-disable-next-line require-await
async function CalculateJubeatColour(
game: Game,
playtype: Playtypes[Game],
userID: integer,
customRatings: Record<string, number>
): Promise<Record<string, string>> {
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.
@@ -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],