mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-22 23:18:05 +03:00
fix: fucking finally fix delta cells (#1683)
This commit is contained in:
@@ -6,7 +6,7 @@ import { GetEnumColour } from "#lib/game-implementations";
|
||||
import { type GameClientImplementation } from "#lib/types";
|
||||
import { IsNullish } from "#util/misc";
|
||||
import { NumericSOV } from "#util/sorts";
|
||||
import { COLOUR_SET, type GamesForGroup, IIDXLIKE_GBOUNDARIES } from "tachi-common";
|
||||
import { COLOUR_SET, type GamesForGroup, RawIIDXGradeBoundaries } from "tachi-common";
|
||||
import { FormatSieglindeBMS } from "tachi-common/config/game-support/bms";
|
||||
|
||||
import { bgc, CreateRatingSys } from "./_util";
|
||||
@@ -67,7 +67,7 @@ const BASE_IMPL: GameClientImplementation<GamesForGroup["bms" | "pms"]> = {
|
||||
["Deltas", "Deltas", NumericSOV((x) => x.scoreData.percent)],
|
||||
["Lamp", "Lamp", NumericSOV((x) => x.scoreData.enumIndexes.lamp)],
|
||||
],
|
||||
scoreCoreCells: ({ sc }) => (
|
||||
scoreCoreCells: ({ sc, chart }) => (
|
||||
<>
|
||||
<ScoreCell
|
||||
colour={GetEnumColour(sc, "grade")}
|
||||
@@ -76,18 +76,10 @@ const BASE_IMPL: GameClientImplementation<GamesForGroup["bms" | "pms"]> = {
|
||||
score={sc.scoreData.score}
|
||||
/>
|
||||
<DeltaCell
|
||||
formatNumFn={(deltaPercent) => {
|
||||
const max = Math.floor(sc.scoreData.score / (sc.scoreData.percent / 100));
|
||||
|
||||
const v = (deltaPercent / 100) * max;
|
||||
|
||||
// i don't know if this is correct
|
||||
// it's just really hard to work out.
|
||||
return Math.round(v).toFixed(0);
|
||||
}}
|
||||
formatNumFn={(n) => Math.floor(n / 18).toString()}
|
||||
grade={sc.scoreData.grade}
|
||||
gradeBoundaries={IIDXLIKE_GBOUNDARIES}
|
||||
value={sc.scoreData.percent}
|
||||
gradeBoundaries={RawIIDXGradeBoundaries(chart.data.notecount)}
|
||||
value={sc.scoreData.score * 18}
|
||||
/>
|
||||
<BMSOrPMSLampCell score={sc} />
|
||||
</>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { GetEnumColour } from "#lib/game-implementations";
|
||||
import { type GameClientImplementation } from "#lib/types";
|
||||
import { ChangeOpacity } from "#util/color-opacity";
|
||||
import { NumericSOV } from "#util/sorts";
|
||||
import { COLOUR_SET, type GamesForGroup, IIDX_LAMPS, IIDXLIKE_GBOUNDARIES } from "tachi-common";
|
||||
import { COLOUR_SET, type GamesForGroup, IIDX_LAMPS, RawIIDXGradeBoundaries } from "tachi-common";
|
||||
|
||||
import { bgc, CreateRatingSys } from "./_util";
|
||||
|
||||
@@ -97,18 +97,10 @@ const IIDXCoreCells: GameClientImplementation<GamesForGroup["iidx"]>["scoreCoreC
|
||||
score={sc.scoreData.score}
|
||||
/>
|
||||
<DeltaCell
|
||||
formatNumFn={(deltaPercent) => {
|
||||
const max = Math.floor(sc.scoreData.score / (sc.scoreData.percent / 100));
|
||||
|
||||
const v = (deltaPercent / 100) * max;
|
||||
|
||||
// i don't know if this is correct
|
||||
// it's just really hard to work out.
|
||||
return Math.round(v).toFixed(0);
|
||||
}}
|
||||
formatNumFn={(n) => Math.floor(n / 18).toString()}
|
||||
grade={sc.scoreData.grade}
|
||||
gradeBoundaries={IIDXLIKE_GBOUNDARIES}
|
||||
value={sc.scoreData.percent}
|
||||
gradeBoundaries={RawIIDXGradeBoundaries(chart.data.notecount)}
|
||||
value={sc.scoreData.score * 18}
|
||||
/>
|
||||
<IIDXLampCell chart={chart} sc={sc} />
|
||||
</>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { PrudenceError, ValidSchemaValue } from "prudence";
|
||||
import type { ZodObject } from "zod";
|
||||
|
||||
import type { GradeBoundary, IIDXLikes } from "../constants/grade-boundaries";
|
||||
import type {
|
||||
BMSCourseDocument,
|
||||
BMSGames,
|
||||
@@ -22,6 +21,11 @@ import type {
|
||||
} from "../types/metrics";
|
||||
|
||||
import { ALL_GAMES, GameToGameGroup, GetGameConfig, GetGameGroupConfig } from "../config/config";
|
||||
import {
|
||||
type GradeBoundary,
|
||||
type IIDXLikes,
|
||||
MakeGradeBoundaries,
|
||||
} from "../constants/grade-boundaries";
|
||||
|
||||
/**
|
||||
* Stick this in the "default" branch of switch exprs to statically typecheck that your
|
||||
@@ -454,6 +458,32 @@ export function IIDXLikeGetGrade(
|
||||
return "F";
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes exact integer EX-score grade boundaries for a given IIDX-like notecount.
|
||||
*
|
||||
* These mirror the integer arithmetic in IIDXLikeGetGrade and avoid the
|
||||
* floating-point rounding errors that arise from working through percent-space
|
||||
* when the grade denominators are ninths (or eighteenths for MAX-).
|
||||
*/
|
||||
export function RawIIDXGradeBoundaries(
|
||||
notecount: integer,
|
||||
): Array<GradeBoundary<GetEnumValue<IIDXLikes, "grade">>> {
|
||||
const max = notecount * 2;
|
||||
|
||||
return MakeGradeBoundaries<GetEnumValue<IIDXLikes, "grade">>({
|
||||
F: 0,
|
||||
E: max * 4,
|
||||
D: max * 6,
|
||||
C: max * 8,
|
||||
B: max * 10,
|
||||
A: max * 12,
|
||||
AA: max * 14,
|
||||
AAA: max * 16,
|
||||
"MAX-": max * 17,
|
||||
MAX: max * 18,
|
||||
});
|
||||
}
|
||||
|
||||
export function EnumIndexToValue<
|
||||
TGame extends V3Game,
|
||||
EV extends ExtractEnumMetricNames<AllConfMetrics[TGame]>,
|
||||
|
||||
Reference in New Issue
Block a user