From 454dabd79e25ae76dd4de3208fdf0672146a6d1f Mon Sep 17 00:00:00 2001 From: Christopher Cooper Date: Thu, 24 Apr 2025 00:31:09 -0700 Subject: [PATCH] support new WaccaVersion enum in MYT proto (#1281) --- .../api/myt-wacca/class-handler.ts | 33 +++++++++++-------- .../src/proto/generated/wacca/common_pb.d.ts | 17 ++++++++++ server/src/proto/generated/wacca/common_pb.js | 19 +++++++++++ server/src/proto/myt/wacca/common.proto | 19 +++++++++++ 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/server/src/lib/score-import/import-types/api/myt-wacca/class-handler.ts b/server/src/lib/score-import/import-types/api/myt-wacca/class-handler.ts index dac03aa7d..e181b9e67 100644 --- a/server/src/lib/score-import/import-types/api/myt-wacca/class-handler.ts +++ b/server/src/lib/score-import/import-types/api/myt-wacca/class-handler.ts @@ -1,5 +1,6 @@ import { UnaryRPCAsAsync } from "../../common/api-myt/traverse-api"; import ScoreImportFatalError from "lib/score-import/framework/score-importing/score-import-error"; +import { WaccaVersion } from "proto/generated/wacca/common_pb"; import { DataRequest } from "proto/generated/wacca/user_pb"; import { WaccaStageUps } from "tachi-common/config/game-support/wacca"; import type { ClassProvider } from "lib/score-import/framework/calculated-data/types"; @@ -17,22 +18,26 @@ export default async function CreateMytWACCAClassHandler( const data = dataRes; return (_gptString, _userID, _ratings, _logger) => { - // versions are 0-indexed, so - // 0 -> WACCA - // 1 -> S - // 2 -> Lily - // 3 -> Lily R - // 4 -> Reverse - // 5 -> Plus - // Currently (Feb. 2025) Reverse and Plus are supported on Myt. + // In Apr/May 2025, the keys for version data are changing from + // 0-indexed (starting at WACCA) to custom enum values. + // TODO: Once MYT transitions over to the new enum, remove the _OLD + // values from the enum proto definition, and remove the compatibility + // code below. + // Currently (Apr. 2025) Reverse and Plus are supported on Myt. // We look for both Reverse and PLUS version data, PLUS being prioritized if exists. // If / when custom dans are added, this will need to change. - // Also, these may change to be 1-indexed at some point. - const REVERSE_VERSION = 4; - const PLUS_VERSION = 5; - const versionData = data.getVersionDataMap().has(PLUS_VERSION) - ? data.getVersionDataMap().get(PLUS_VERSION) - : data.getVersionDataMap().get(REVERSE_VERSION); + const versionDataMap = data.getVersionDataMap(); + let versionData: DataResponse.VersionData | undefined; + + if (versionDataMap.has(WaccaVersion.WACCA_VERSION_PLUS)) { + versionData = versionDataMap.get(WaccaVersion.WACCA_VERSION_PLUS); + } else if (versionDataMap.has(WaccaVersion.WACCA_VERSION_PLUS_OLD)) { + versionData = versionDataMap.get(WaccaVersion.WACCA_VERSION_PLUS_OLD); + } else if (versionDataMap.has(WaccaVersion.WACCA_VERSION_REVERSE)) { + versionData = versionDataMap.get(WaccaVersion.WACCA_VERSION_REVERSE); + } else if (versionDataMap.has(WaccaVersion.WACCA_VERSION_REVERSE_OLD)) { + versionData = versionDataMap.get(WaccaVersion.WACCA_VERSION_REVERSE_OLD); + } // rank: // 0 -> none diff --git a/server/src/proto/generated/wacca/common_pb.d.ts b/server/src/proto/generated/wacca/common_pb.d.ts index 108716946..6a2e35cf1 100644 --- a/server/src/proto/generated/wacca/common_pb.d.ts +++ b/server/src/proto/generated/wacca/common_pb.d.ts @@ -71,6 +71,23 @@ export namespace WaccaJudge { } } +export interface WaccaVersionMap { + WACCA_VERSION_UNSPECIFIED: 0; + WACCA_VERSION_S_OLD: 1; + WACCA_VERSION_LILY_OLD: 2; + WACCA_VERSION_LILY_R_OLD: 3; + WACCA_VERSION_REVERSE_OLD: 4; + WACCA_VERSION_PLUS_OLD: 5; + WACCA_VERSION_WACCA: 100; + WACCA_VERSION_S: 150; + WACCA_VERSION_LILY: 200; + WACCA_VERSION_LILY_R: 250; + WACCA_VERSION_REVERSE: 300; + WACCA_VERSION_PLUS: 400; +} + +export const WaccaVersion: WaccaVersionMap; + export interface WaccaMusicDifficultyMap { WACCA_MUSIC_DIFFICULTY_UNSPECIFIED: 0; WACCA_MUSIC_DIFFICULTY_NORMAL: 1; diff --git a/server/src/proto/generated/wacca/common_pb.js b/server/src/proto/generated/wacca/common_pb.js index 85c34e2e6..f22039711 100644 --- a/server/src/proto/generated/wacca/common_pb.js +++ b/server/src/proto/generated/wacca/common_pb.js @@ -26,6 +26,7 @@ goog.exportSymbol('proto.mythos.wacca.v0.WaccaJudge', null, global); goog.exportSymbol('proto.mythos.wacca.v0.WaccaMusicDifficulty', null, global); goog.exportSymbol('proto.mythos.wacca.v0.WaccaMusicScoreGrade', null, global); goog.exportSymbol('proto.mythos.wacca.v0.WaccaPlayMode', null, global); +goog.exportSymbol('proto.mythos.wacca.v0.WaccaVersion', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -538,6 +539,24 @@ proto.mythos.wacca.v0.WaccaJudge.prototype.setMiss = function(value) { }; +/** + * @enum {number} + */ +proto.mythos.wacca.v0.WaccaVersion = { + WACCA_VERSION_UNSPECIFIED: 0, + WACCA_VERSION_S_OLD: 1, + WACCA_VERSION_LILY_OLD: 2, + WACCA_VERSION_LILY_R_OLD: 3, + WACCA_VERSION_REVERSE_OLD: 4, + WACCA_VERSION_PLUS_OLD: 5, + WACCA_VERSION_WACCA: 100, + WACCA_VERSION_S: 150, + WACCA_VERSION_LILY: 200, + WACCA_VERSION_LILY_R: 250, + WACCA_VERSION_REVERSE: 300, + WACCA_VERSION_PLUS: 400 +}; + /** * @enum {number} */ diff --git a/server/src/proto/myt/wacca/common.proto b/server/src/proto/myt/wacca/common.proto index bfa47938c..008d4e726 100644 --- a/server/src/proto/myt/wacca/common.proto +++ b/server/src/proto/myt/wacca/common.proto @@ -2,6 +2,25 @@ syntax = "proto3"; package mythos.wacca.v0; + +enum WaccaVersion { + WACCA_VERSION_UNSPECIFIED = 0; + + // TODO: once MYT transitions over to the new enum, remove the _OLD values + WACCA_VERSION_S_OLD = 1; + WACCA_VERSION_LILY_OLD = 2; + WACCA_VERSION_LILY_R_OLD = 3; + WACCA_VERSION_REVERSE_OLD = 4; + WACCA_VERSION_PLUS_OLD = 5; + + WACCA_VERSION_WACCA = 100; + WACCA_VERSION_S = 150; + WACCA_VERSION_LILY = 200; + WACCA_VERSION_LILY_R = 250; + WACCA_VERSION_REVERSE = 300; + WACCA_VERSION_PLUS = 400; +} + enum WaccaMusicDifficulty { WACCA_MUSIC_DIFFICULTY_UNSPECIFIED = 0; WACCA_MUSIC_DIFFICULTY_NORMAL = 1;