mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-01 03:18:06 +03:00
26 lines
667 B
TypeScript
26 lines
667 B
TypeScript
import { GetGamePTConfig } from "../config/config";
|
|
import { Grades, integer } from "../types";
|
|
|
|
const IIDXConfig = GetGamePTConfig("iidx", "SP");
|
|
|
|
export function CalculateGradeDeltaIIDX(
|
|
cmpGrade: Grades["iidx:SP" | "iidx:DP"],
|
|
score: integer,
|
|
notecount: integer
|
|
): string {
|
|
const cmpGradeIDX = IIDXConfig.grades.indexOf(cmpGrade);
|
|
|
|
const cmpGradePercent = IIDXConfig.gradeBoundaries[cmpGradeIDX];
|
|
|
|
const cmpScore = Math.ceil(notecount * (cmpGradePercent / 100));
|
|
|
|
const delta = score - cmpScore;
|
|
|
|
if (delta >= 0) {
|
|
return `${cmpGrade}+${delta}`;
|
|
} else {
|
|
// negative numbers implicitly stringify with the - prefix
|
|
return `${cmpGrade}${delta}`;
|
|
}
|
|
}
|