From 84e731aabbb26f0d84061dafcf5b873c2bb708b5 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 17 May 2021 21:51:45 +0000 Subject: [PATCH] iidx: update api to support qpros in catalog --- bemani/api/objects/catalog.py | 19 +++++++++++++++++++ bemani/data/api/game.py | 15 +++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/bemani/api/objects/catalog.py b/bemani/api/objects/catalog.py index cd6b3aa..3abf33c 100644 --- a/bemani/api/objects/catalog.py +++ b/bemani/api/objects/catalog.py @@ -155,11 +155,30 @@ class CatalogObject(BaseObject): else: return {"emblems": []} + def __format_iidx_extras(self) -> Dict[str, List[Dict[str, Any]]]: + # Gotta look up the unlock catalog + items = self.data.local.game.get_items(self.game, self.version) + + return { + "qpros": [ + { + "identifier": item.data.get_str("identifier"), + "id": str(item.id), + "name": item.data.get_str("name"), + "type": item.type[3:], + } + for item in items + if item.type in ['qp_body', 'qp_face', 'qp_hair', 'qp_hand', 'qp_head'] + ], + } + def __format_extras(self) -> Dict[str, List[Dict[str, Any]]]: if self.game == GameConstants.SDVX: return self.__format_sdvx_extras() elif self.game == GameConstants.JUBEAT: return self.__format_jubeat_extras() + elif self.game == GameConstants.IIDX: + return self.__format_iidx_extras() else: return {} diff --git a/bemani/data/api/game.py b/bemani/data/api/game.py index bb4707c..533e556 100644 --- a/bemani/data/api/game.py +++ b/bemani/data/api/game.py @@ -38,6 +38,17 @@ class GlobalGameData(BaseGlobalData): }, ) + def __translate_iidx_qpros(self, entry: Dict[str, Any]) -> Item: + return Item( + f'qp_{entry["type"]}', + int(entry["id"]), + { + "identifier": entry["identifier"], + "name": entry["name"], + "type": entry["type"], + } + ) + def get_items(self, game: str, version: int) -> List[Item]: """ Given a game/userid, find all items in the catalog. @@ -68,6 +79,10 @@ class GlobalGameData(BaseGlobalData): translation = { "emblems": self.__translate_jubeat_emblems, }.get(catalogtype, None) + elif game == GameConstants.IIDX: + translation = { + "qpros": self.__translate_iidx_qpros, + }.get(catalogtype, None) else: translation = None