[maimaidx] use 4dp for percent formatter (#1338)

* [maimaidx] use 4dp for percent formatter

* also fix server side formatters

* this one too

* update functions in common
This commit is contained in:
beerpsi
2025-08-01 20:17:01 +01:00
committed by GitHub
parent 4ed04fae7f
commit 61e4485caf
4 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -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.",
},
@@ -276,16 +276,16 @@ export const SGLCalc: ScoreCalculator<GPTStrings["bms" | "pms"]> = (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) {
@@ -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();
});
@@ -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) => {