From 06a5dfee26a5da2960796f736e3a125213ad91f6 Mon Sep 17 00:00:00 2001 From: zkldi Date: Thu, 20 May 2021 07:36:22 +0100 Subject: [PATCH] update some incorrect iidx types --- .../common/api-kai/iidx/converter.ts | 22 +++++++++---------- .../import-types/common/api-kai/types.ts | 6 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/src/score-import/import-types/common/api-kai/iidx/converter.ts b/server/src/score-import/import-types/common/api-kai/iidx/converter.ts index fa42d6f32..be7595905 100644 --- a/server/src/score-import/import-types/common/api-kai/iidx/converter.ts +++ b/server/src/score-import/import-types/common/api-kai/iidx/converter.ts @@ -20,7 +20,7 @@ const PR_KaiIIDXScore = { play_style: p.isIn("SINGLE", "DOUBLE"), difficulty: p.isIn("BEGINNER", "NORMAL", "HYPER", "ANOTHER", "LEGGENDARIA"), version_played: p.isBoundedInteger(9, 28), - lamp: "string", + lamp: p.isBoundedInteger(0, 7), ex_score: p.isPositiveInteger, miss_count: p.or(p.isPositiveInteger, p.is(-1)), fast_count: p.isPositiveInteger, @@ -28,25 +28,25 @@ const PR_KaiIIDXScore = { timestamp: "string", }; -function ResolveKaiLamp(lamp: string): Lamps["iidx:SP" | "iidx:DP"] { +function ResolveKaiLamp(lamp: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7): Lamps["iidx:SP" | "iidx:DP"] { switch (lamp) { - case "FAILED": + case 0: + return "NO PLAY"; + case 1: return "FAILED"; - case "EASY_CLEAR": + case 3: return "EASY CLEAR"; - case "ASSIST_CLEAR": + case 2: return "ASSIST CLEAR"; - case "CLEARED": + case 4: return "CLEAR"; - case "HARD_CLEAR": + case 5: return "HARD CLEAR"; - case "EX_HARD_CLEAR": + case 6: return "EX HARD CLEAR"; - case "FULL_COMBO": + case 7: return "FULL COMBO"; } - - throw new InvalidScoreFailure(`Invalid lamp of ${lamp}.`); } export const ConvertAPIKaiIIDX: ConverterFunction = async ( diff --git a/server/src/score-import/import-types/common/api-kai/types.ts b/server/src/score-import/import-types/common/api-kai/types.ts index fa7200ebd..07f9cddbd 100644 --- a/server/src/score-import/import-types/common/api-kai/types.ts +++ b/server/src/score-import/import-types/common/api-kai/types.ts @@ -5,11 +5,11 @@ export interface KaiIIDXScore { play_style: "SINGLE" | "DOUBLE"; difficulty: "BEGINNER" | "NORMAL" | "HYPER" | "ANOTHER" | "LEGGENDARIA"; version_played: integer; - lamp: string; + lamp: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; ex_score: integer; miss_count: integer; // -1 => null - fast_count: integer; - slow_count: integer; + fast_count: integer | null; + slow_count: integer | null; timestamp: string; }