2023-07-12 11:25:46 +02:00
|
|
|
from ast import Dict
|
2023-03-03 23:46:29 +01:00
|
|
|
from typing import List
|
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
from core.config import CoreConfig
|
|
|
|
|
2023-03-03 23:46:29 +01:00
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
class OngekiServerConfig:
|
2023-02-17 07:02:21 +01:00
|
|
|
def __init__(self, parent_config: "OngekiConfig") -> None:
|
|
|
|
self.__config = parent_config
|
2023-03-03 23:46:29 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "server", "enable", default=True
|
|
|
|
)
|
2023-03-03 23:46:29 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
@property
|
|
|
|
def loglevel(self) -> int:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.str_to_loglevel(
|
|
|
|
CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
2023-11-09 03:42:53 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def use_https(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "server", "use_https", default=False
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
2023-03-03 23:46:29 +01:00
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
class OngekiGachaConfig:
|
2023-03-03 23:46:29 +01:00
|
|
|
def __init__(self, parent_config: "OngekiConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enabled_gachas(self) -> List[int]:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "gachas", "enabled_gachas", default=[]
|
|
|
|
)
|
2023-03-03 23:46:29 +01:00
|
|
|
|
|
|
|
|
2023-07-12 11:25:46 +02:00
|
|
|
class OngekiCardMakerVersionConfig:
|
|
|
|
def __init__(self, parent_config: "OngekiConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
def version(self, version: int) -> Dict:
|
|
|
|
"""
|
|
|
|
in the form of:
|
|
|
|
<ongeki version>: {"card_maker": <compatible card maker version>}
|
|
|
|
6: {"card_maker": 1.30.01}
|
|
|
|
"""
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "version", default={}
|
|
|
|
).get(version)
|
|
|
|
|
2023-09-09 18:03:42 +02:00
|
|
|
class OngekiCryptoConfig:
|
|
|
|
def __init__(self, parent_config: "OngekiConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def keys(self) -> Dict:
|
|
|
|
"""
|
|
|
|
in the form of:
|
|
|
|
internal_version: [key, iv]
|
|
|
|
all values are hex strings
|
|
|
|
"""
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "crypto", "keys", default={}
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def encrypted_only(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "ongeki", "crypto", "encrypted_only", default=False
|
|
|
|
)
|
2023-07-12 11:25:46 +02:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class OngekiConfig(dict):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
self.server = OngekiServerConfig(self)
|
2023-03-03 23:46:29 +01:00
|
|
|
self.gachas = OngekiGachaConfig(self)
|
2023-07-12 11:25:46 +02:00
|
|
|
self.version = OngekiCardMakerVersionConfig(self)
|
2023-09-09 18:03:42 +02:00
|
|
|
self.crypto = OngekiCryptoConfig(self)
|