Return null for unofficial usc charts.

This commit is contained in:
zkldi
2021-09-02 23:42:17 +01:00
parent ebfb0e8284
commit 8fef60c065
2 changed files with 15 additions and 0 deletions
@@ -10,6 +10,7 @@ import {
TestingSDVXSingleDryScore,
} from "test-utils/test-data";
import { CreateCalculatedData, CalculateDataForGamePT } from "./calculated-data";
import { ChartDocument, ScoreDocument } from "tachi-common";
const logger = CreateLogCtx(__filename);
@@ -41,6 +42,15 @@ t.test("#CreateCalculatedData", async (t) => {
"Should correctly call rating function overrides for different games"
);
const uscRes = await CreateCalculatedData(
{ game: "usc", playtype: "Single" } as ScoreDocument,
{ data: { isOfficial: false }, playtype: "Single" } as ChartDocument,
null,
logger
);
t.strictSame(uscRes, { VF6: null }, "Should return null if chart was not an official.");
t.end();
});
@@ -199,6 +199,11 @@ function CalculateDataSDVXorUSC(
defaultTierlistID: string | undefined,
logger: KtLogger
): CalculatedData<"sdvx:Single" | "usc:Single"> {
// for usc, unofficial charts currently have no VF6 value.
if (dryScore.game === "usc" && !(chart as ChartDocument<"usc:Single">).data.isOfficial) {
return { VF6: null };
}
const VF6 = CalculateVF6(
dryScore.scoreData.grade as Grades["sdvx:Single"],
dryScore.scoreData.lamp as Lamps["sdvx:Single"],