From 2bb54cdaaa9d7b3a85089a4b9c03e3b4264a6a32 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Sun, 30 Oct 2022 15:47:29 +0000 Subject: [PATCH] fix(lr2hook): handle early exiting *properly* --- .../import-types/ir/lr2hook/converter.test.ts | 9 +++------ .../score-import/import-types/ir/lr2hook/converter.ts | 2 +- server/src/test-utils/test-data.ts | 8 ++++---- server/src/utils/queries/charts.ts | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/server/src/lib/score-import/import-types/ir/lr2hook/converter.test.ts b/server/src/lib/score-import/import-types/ir/lr2hook/converter.test.ts index f655c1c57..f4dc60508 100644 --- a/server/src/lib/score-import/import-types/ir/lr2hook/converter.test.ts +++ b/server/src/lib/score-import/import-types/ir/lr2hook/converter.test.ts @@ -32,7 +32,7 @@ t.test("#ConverterLR2Hook", (t) => { scoreData: { score: TestingLR2HookScore.scoreData.exScore, hitMeta: { - bp: 75, + bp: 56, }, }, game: "bms", @@ -46,14 +46,11 @@ t.test("#ConverterLR2Hook", (t) => { t.end(); }); - t.test("Should null BP if the score was a fail with hard-gauge.", async (t) => { + t.test("Should null BP if the score was exited early.", async (t) => { const res = await ConverterLR2Hook( dmf(TestingLR2HookScore, { - playerData: { - gauge: "HARD", - }, scoreData: { - lamp: "FAIL", + notesPlayed: 10, }, } as any), { timeReceived: 10 }, diff --git a/server/src/lib/score-import/import-types/ir/lr2hook/converter.ts b/server/src/lib/score-import/import-types/ir/lr2hook/converter.ts index f96b6a993..bb40d4270 100644 --- a/server/src/lib/score-import/import-types/ir/lr2hook/converter.ts +++ b/server/src/lib/score-import/import-types/ir/lr2hook/converter.ts @@ -43,7 +43,7 @@ export const ConverterLR2Hook: ConverterFunction = // lr2hook doesn't send "max" BP so to speak. If you fail really early // or quit out, you can have an early fail with like, 5 BP. - if ((lamp === "FAILED" || lamp === "NO PLAY") && gauge === "HARD") { + if (data.scoreData.notesPlayed !== data.scoreData.notesTotal) { bp = null; } diff --git a/server/src/test-utils/test-data.ts b/server/src/test-utils/test-data.ts index 74924b5f5..3cc504d4f 100644 --- a/server/src/test-utils/test-data.ts +++ b/server/src/test-utils/test-data.ts @@ -254,11 +254,11 @@ export const TestingLR2HookScore: LR2HookScore = { gauge: "GROOVE", }, scoreData: { - pgreat: 1000, - great: 500, - good: 100, + pgreat: 1100, + great: 900, + good: 200, bad: 50, - poor: 25, + poor: 6, exScore: 2500, maxCombo: 50, moneyScore: 150_000, diff --git a/server/src/utils/queries/charts.ts b/server/src/utils/queries/charts.ts index a56863ffd..eae38796d 100644 --- a/server/src/utils/queries/charts.ts +++ b/server/src/utils/queries/charts.ts @@ -98,7 +98,7 @@ export function FindITGChartOnHash(hash: string) { export function FindBMSChartOnHash(hash: string) { return db.charts.bms.findOne({ $or: [{ "data.hashMD5": hash }, { "data.hashSHA256": hash }], - }); + }) as Promise>; } /**