Skip to content

Commit

Permalink
feat: properly merge ex score in sdvx pbs
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrising committed Sep 27, 2023
1 parent 3275e8b commit c211753
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
33 changes: 32 additions & 1 deletion server/src/game-implementations/games/sdvx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const scoreData: ScoreData<"sdvx:Single"> = {
score: 9_700_000,
grade: "AAA",
judgements: {},
optional: { enumIndexes: {} },
optional: { enumIndexes: {}, exScore: 10 },
enumIndexes: {
grade: SDVX_GRADES.AAA,
lamp: SDVX_LAMPS.CLEAR,
Expand Down Expand Up @@ -198,6 +198,37 @@ t.test("SDVX Implementation", (t) => {
t.end();
});

t.test("Should join best EX SCore", async (t) => {
await db.scores.insert(mockScore);
await db.scores.insert(
dmf(mockScore, {
scoreID: "bestLamp",
scoreData: {
score: 0,
lamp: "ULTIMATE CHAIN",
enumIndexes: { lamp: SDVX_LAMPS.ULTIMATE_CHAIN },
optional: {
exScore: 9000,
},
},
})
);

t.hasStrict(await CreatePBDoc("sdvx:Single", 1, TestingSDVXAlbidaChart, logger), {
composedFrom: [{ name: "Best Score" }, { name: "Best Lamp", scoreID: "bestLamp" }],
scoreData: {
score: mockScore.scoreData.score,
lamp: "ULTIMATE CHAIN",
enumIndexes: { lamp: SDVX_LAMPS.ULTIMATE_CHAIN },
optional: {
exScore: 9000,
},
},
});

t.end();
});

t.end();
});

Expand Down
11 changes: 9 additions & 2 deletions server/src/game-implementations/games/sdvx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
SDVXLIKE_GOAL_FMT,
SDVXLIKE_GOAL_OO_FMT,
SDVXLIKE_GOAL_PG_FMT,
SDVXLIKE_PB_MERGERS,
SDVXLIKE_PROFILE_CALCS,
SDVXLIKE_SCORE_CALCS,
SDVXLIKE_SCORE_VALIDATORS,
SDVXLIKE_SESSION_CALCS,
} from "./_common";
import { CreatePBMergeFor } from "game-implementations/utils/pb-merge";
import type { GPTServerImplementation } from "game-implementations/types";

export const SDVX_IMPL: GPTServerImplementation<"sdvx:Single"> = {
Expand All @@ -36,7 +36,14 @@ export const SDVX_IMPL: GPTServerImplementation<"sdvx:Single"> = {
goalCriteriaFormatters: SDVXLIKE_GOAL_FMT,
goalProgressFormatters: SDVXLIKE_GOAL_PG_FMT,
goalOutOfFormatters: SDVXLIKE_GOAL_OO_FMT,
pbMergeFunctions: SDVXLIKE_PB_MERGERS,
pbMergeFunctions: [
CreatePBMergeFor("largest", "enumIndexes.lamp", "Best Lamp", (base, score) => {
base.scoreData.lamp = score.scoreData.lamp;
}),
CreatePBMergeFor("largest", "optional.exScore", "Best EX Score", (base, score) => {
base.scoreData.optional.exScore = score.scoreData.optional.exScore;
}),
],
defaultMergeRefName: SDVXLIKE_DEFAULT_MERGE_NAME,
scoreValidators: SDVXLIKE_SCORE_VALIDATORS,
};

0 comments on commit c211753

Please sign in to comment.