From f24d554a448673d67dfdc52286e5301a7832f278 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Fri, 3 Mar 2023 16:26:07 -0500 Subject: [PATCH] wacca: pull region_id from allnet if available --- titles/wacca/base.py | 21 +++++++++++++++++++-- titles/wacca/const.py | 23 ++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/titles/wacca/base.py b/titles/wacca/base.py index 25ec33b..64b4248 100644 --- a/titles/wacca/base.py +++ b/titles/wacca/base.py @@ -91,10 +91,27 @@ class WaccaBase(): def handle_housing_start_request(self, data: Dict) -> Dict: req = HousingStartRequestV1(data) - if req.appVersion.country != "JPN" and req.appVersion.country in [region.name for region in WaccaConstants.Region]: + machine = self.data.arcade.get_machine(req.chipId) + if machine is not None: + arcade = self.data.arcade.get_arcade(machine["arcade"]) + + allnet_region_id = arcade["region_id"] + + if req.appVersion.country == "JPN": + if allnet_region_id is not None: + region = WaccaConstants.allnet_region_id_to_wacca_region(allnet_region_id) + + if region is None: + region_id = self.region_id + + else: + region_id = self.region_id + + elif req.appVersion.country in WaccaConstants.VALID_COUNTRIES: region_id = WaccaConstants.Region[req.appVersion.country] + else: - region_id = self.region_id + region_id = 0 resp = HousingStartResponseV1(region_id) return resp.make() diff --git a/titles/wacca/const.py b/titles/wacca/const.py index a984682..f072143 100644 --- a/titles/wacca/const.py +++ b/titles/wacca/const.py @@ -1,4 +1,7 @@ from enum import Enum +from typing import Optional + +from core.const import AllnetJapanRegionId class WaccaConstants(): CONFIG_NAME = "wacca.yaml" @@ -165,4 +168,22 @@ class WaccaConstants(): @classmethod def game_ver_to_string(cls, ver: int): - return cls.VERSION_NAMES[ver] \ No newline at end of file + return cls.VERSION_NAMES[ver] + + @classmethod + def allnet_region_id_to_wacca_region(cls, region: int) -> Optional[Region]: + try: + return [ + cls.Region.NONE, cls.Region.AICHI, cls.Region.AOMORI, cls.Region.AKITA, cls.Region.ISHIKAWA, + cls.Region.IBARAKI, cls.Region.IWATE, cls.Region.EHIME, cls.Region.OITA, cls.Region.OSAKA, + cls.Region.OKAYAMA, cls.Region.OKINAWA, cls.Region.KAGAWA, cls.Region.KAGOSHIMA, cls.Region.KANAGAWA, + cls.Region.GIFU, cls.Region.KYOTO, cls.Region.KUMAMOTO, cls.Region.GUNMA, cls.Region.KOCHI, + cls.Region.SAITAMA, cls.Region.SAGA, cls.Region.SHIGA, cls.Region.SHIZUOKA, cls.Region.SHIMANE, + cls.Region.CHIBA, cls.Region.TOKYO, cls.Region.TOKUSHIMA, cls.Region.TOCHIGI, cls.Region.TOTTORI, + cls.Region.TOYAMA, cls.Region.NAGASAKI, cls.Region.NAGANO, cls.Region.NARA, cls.Region.NIIGATA, + cls.Region.HYOGO, cls.Region.HIROSHIMA, cls.Region.FUKUI, cls.Region.FUKUOKA, cls.Region.FUKUSHIMA, + cls.Region.HOKKAIDO, cls.Region.MIE, cls.Region.MIYAGI, cls.Region.MIYAZAKI, cls.Region.YAMAGATA, + cls.Region.YAMAGUCHI, cls.Region.YAMANASHI, cls.Region.WAKAYAMA, + ][region] + except: return None +