Merge pull request 'wacca: allow setting prefecture in config by name' (#9) from Raymonf/artemis:feat/wacca-prefecture into develop

Reviewed-on: Hay1tsme/artemis#9
This commit is contained in:
Hay1tsme 2023-03-02 03:10:41 +00:00
commit e46c8e7dbd
5 changed files with 61 additions and 49 deletions

View File

@ -1,6 +1,7 @@
server: server:
enable: True enable: True
loglevel: "info" loglevel: "info"
prefecture_name: "Hokkaido"
mods: mods:
always_vip: True always_vip: True

View File

@ -1,9 +1,8 @@
from typing import Any, List, Dict from typing import Any, List, Dict
import logging import logging
import inflection
from math import floor from math import floor
from datetime import datetime, timedelta from datetime import datetime, timedelta
from core.config import CoreConfig from core.config import CoreConfig
from titles.wacca.config import WaccaConfig from titles.wacca.config import WaccaConfig
from titles.wacca.const import WaccaConstants from titles.wacca.const import WaccaConstants
@ -71,6 +70,13 @@ class WaccaBase():
} }
self.allowed_stages = [] self.allowed_stages = []
prefecture_name = inflection.underscore(game_cfg.server.prefecture_name).replace(' ', '_').upper()
if prefecture_name not in [region.name for region in WaccaConstants.Region]:
self.logger.warning(f"Invalid prefecture name {game_cfg.server.prefecture_name} in config file")
self.region_id = 1
else:
self.region_id = int(WaccaConstants.Region[prefecture_name].value)
def handle_housing_get_request(self, data: Dict) -> Dict: def handle_housing_get_request(self, data: Dict) -> Dict:
req = BaseRequest(data) req = BaseRequest(data)
housing_id = 1337 housing_id = 1337
@ -86,7 +92,7 @@ class WaccaBase():
req = HousingStartRequestV1(data) req = HousingStartRequestV1(data)
resp = HousingStartResponseV1( resp = HousingStartResponseV1(
1, self.region_id,
[ # Recomended songs [ # Recomended songs
1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32, 1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32,
1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119, 1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119,

View File

@ -13,6 +13,10 @@ class WaccaServerConfig():
def loglevel(self) -> int: def loglevel(self) -> int:
return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'wacca', 'server', 'loglevel', default="info")) return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'wacca', 'server', 'loglevel', default="info"))
@property
def prefecture_name(self) -> str:
return CoreConfig.get_config_field(self.__config, 'wacca', 'server', 'prefecture_name', default="Hokkaido")
class WaccaModsConfig(): class WaccaModsConfig():
def __init__(self, parent_config: "WaccaConfig") -> None: def __init__(self, parent_config: "WaccaConfig") -> None:
self.__config = parent_config self.__config = parent_config

View File

@ -151,6 +151,7 @@ class WaccaConstants():
KAGOSHIMA = 46 KAGOSHIMA = 46
OKINAWA = 47 OKINAWA = 47
UNITED_STATES = 48 UNITED_STATES = 48
USA = 48
TAIWAN = 49 TAIWAN = 49
HONG_KONG = 50 HONG_KONG = 50
SINGAPORE = 51 SINGAPORE = 51

View File

@ -44,7 +44,7 @@ class WaccaLily(WaccaS):
req = HousingStartRequestV2(data) req = HousingStartRequestV2(data)
resp = HousingStartResponseV1( resp = HousingStartResponseV1(
1, self.region_id,
[ # Recomended songs [ # Recomended songs
1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32, 1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32,
1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119, 1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119,