From c211753c2ffb2acbc90b547161edd72eae768a80 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Wed, 27 Sep 2023 14:12:04 +0100 Subject: [PATCH] feat: properly merge ex score in sdvx pbs --- .../game-implementations/games/sdvx.test.ts | 33 ++++++++++++++++++- server/src/game-implementations/games/sdvx.ts | 11 +++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/server/src/game-implementations/games/sdvx.test.ts b/server/src/game-implementations/games/sdvx.test.ts index afed5227b..77799efa0 100644 --- a/server/src/game-implementations/games/sdvx.test.ts +++ b/server/src/game-implementations/games/sdvx.test.ts @@ -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, @@ -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(); }); diff --git a/server/src/game-implementations/games/sdvx.ts b/server/src/game-implementations/games/sdvx.ts index 30e17dcdf..d72dfafba 100644 --- a/server/src/game-implementations/games/sdvx.ts +++ b/server/src/game-implementations/games/sdvx.ts @@ -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"> = { @@ -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, };