diff --git a/common/src/config/game-support/maimai-dx.ts b/common/src/config/game-support/maimai-dx.ts index 079993f18..b7145f87c 100644 --- a/common/src/config/game-support/maimai-dx.ts +++ b/common/src/config/game-support/maimai-dx.ts @@ -96,7 +96,7 @@ export const MAIMAI_DX_SINGLE_CONF = { percent: { type: "DECIMAL", validate: p.isBetween(0, 101), - formatter: FmtPercent, + formatter: (v) => FmtPercent(v, 4), description: "The percent this score was worth. Sometimes called 'rate' in game. This is between 0 and 101.", }, diff --git a/server/src/game-implementations/games/_common.ts b/server/src/game-implementations/games/_common.ts index d2e268090..83f942014 100644 --- a/server/src/game-implementations/games/_common.ts +++ b/server/src/game-implementations/games/_common.ts @@ -276,16 +276,16 @@ export const SGLCalc: ScoreCalculator = (scoreData, c } }; -export function GoalFmtPercent(val: number) { - return `Get ${NumToDP(val)}% on`; +export function GoalFmtPercent(val: number, dp = 2) { + return `Get ${NumToDP(val, dp)}% on`; } export function GoalFmtScore(val: number) { return `Get a score of ${val.toLocaleString("en-GB")} on`; } -export function GoalOutOfFmtPercent(val: number) { - return `${NumToDP(val)}%`; +export function GoalOutOfFmtPercent(val: number, dp = 2) { + return `${NumToDP(val, dp)}%`; } export function GoalOutOfFmtScore(val: number) { diff --git a/server/src/game-implementations/games/maimaidx.test.ts b/server/src/game-implementations/games/maimaidx.test.ts index b991518f8..45e8a8176 100644 --- a/server/src/game-implementations/games/maimaidx.test.ts +++ b/server/src/game-implementations/games/maimaidx.test.ts @@ -92,7 +92,7 @@ t.test("Maimai DX Implementation", (t) => { t.test("Goal Formatters", (t) => { t.test("Criteria", (t) => { - t.equal(MAIMAIDX_IMPL.goalCriteriaFormatters.percent(93.14), "Get 93.14% on"); + t.equal(MAIMAIDX_IMPL.goalCriteriaFormatters.percent(93.1415), "Get 93.1415% on"); t.end(); }); @@ -114,15 +114,15 @@ t.test("Maimai DX Implementation", (t) => { expected ); - f("grade", { grade: "S", percent: 97.5 }, GRADES.indexOf("SS"), "(S+)-0.50%"); - f("percent", { percent: 98.23 }, 1_000_000, "98.23%"); + f("grade", { grade: "S", percent: 97.5 }, GRADES.indexOf("SS"), "(S+)-0.5000%"); + f("percent", { percent: 98.23 }, 1_000_000, "98.2300%"); f("lamp", { lamp: "CLEAR" }, LAMPS.indexOf("CLEAR"), "CLEAR"); t.end(); }); t.test("Out Of", (t) => { - t.equal(MAIMAIDX_IMPL.goalOutOfFormatters.percent(99.1123), "99.11%"); + t.equal(MAIMAIDX_IMPL.goalOutOfFormatters.percent(99.1123), "99.1123%"); t.end(); }); diff --git a/server/src/game-implementations/games/maimaidx.ts b/server/src/game-implementations/games/maimaidx.ts index 3a6f5fb56..7727a7f52 100644 --- a/server/src/game-implementations/games/maimaidx.ts +++ b/server/src/game-implementations/games/maimaidx.ts @@ -53,10 +53,10 @@ export const MAIMAIDX_IMPL: GPTServerImplementation<"maimaidx:Single"> = { }, }, goalCriteriaFormatters: { - percent: GoalFmtPercent, + percent: (v) => GoalFmtPercent(v, 4), }, goalProgressFormatters: { - percent: (pb) => `${pb.scoreData.percent.toFixed(2)}%`, + percent: (pb) => `${pb.scoreData.percent.toFixed(4)}%`, lamp: (pb) => pb.scoreData.lamp, grade: (pb, gradeIndex) => GradeGoalFormatter( @@ -64,11 +64,11 @@ export const MAIMAIDX_IMPL: GPTServerImplementation<"maimaidx:Single"> = { pb.scoreData.grade, pb.scoreData.percent, MAIMAIDX_GBOUNDARIES[gradeIndex]!.name, - (v) => `${v.toFixed(2)}%` + (v) => `${v.toFixed(4)}%` ), }, goalOutOfFormatters: { - percent: GoalOutOfFmtPercent, + percent: (v) => GoalOutOfFmtPercent(v, 4), }, pbMergeFunctions: [ CreatePBMergeFor("largest", "enumIndexes.lamp", "Best Lamp", (base, score) => {