2023-02-17 06:02:21 +00:00
|
|
|
from core.config import CoreConfig
|
|
|
|
from typing import Dict
|
|
|
|
|
2023-03-09 16:38:58 +00:00
|
|
|
|
|
|
|
class ChuniServerConfig:
|
2023-02-17 06:02:21 +00:00
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
2023-03-09 16:38:58 +00:00
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "server", "enable", default=True
|
|
|
|
)
|
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
@property
|
|
|
|
def loglevel(self) -> int:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.str_to_loglevel(
|
|
|
|
CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
2023-10-07 16:31:08 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def news_msg(self) -> str:
|
2023-10-09 06:47:55 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-10-07 16:31:08 +00:00
|
|
|
self.__config, "chuni", "server", "news_msg", default=""
|
|
|
|
)
|
2023-02-17 06:02:21 +00:00
|
|
|
|
2023-03-09 16:38:58 +00:00
|
|
|
|
2023-03-24 17:10:10 +00:00
|
|
|
class ChuniTeamConfig:
|
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def team_name(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "team", "name", default=""
|
|
|
|
)
|
2023-07-11 10:04:25 +00:00
|
|
|
@property
|
|
|
|
def rank_scale(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "team", "rank_scale", default="False"
|
|
|
|
)
|
2023-03-24 17:10:10 +00:00
|
|
|
|
|
|
|
|
2023-03-28 16:28:57 +00:00
|
|
|
class ChuniModsConfig:
|
2023-03-24 17:10:10 +00:00
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
2023-03-28 16:28:57 +00:00
|
|
|
@property
|
|
|
|
def use_login_bonus(self) -> bool:
|
2023-03-24 17:10:10 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-03-28 16:28:57 +00:00
|
|
|
self.__config, "chuni", "mods", "use_login_bonus", default=True
|
2023-03-24 17:10:10 +00:00
|
|
|
)
|
|
|
|
|
2024-09-03 00:00:59 +00:00
|
|
|
@property
|
|
|
|
def stock_tickets(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "mods", "stock_tickets", default=None
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def stock_count(self) -> int:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "mods", "stock_count", default=99
|
|
|
|
)
|
|
|
|
|
2023-03-28 16:28:57 +00:00
|
|
|
|
|
|
|
class ChuniVersionConfig:
|
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
def version(self, version: int) -> Dict:
|
|
|
|
"""
|
|
|
|
in the form of:
|
|
|
|
11: {"rom": 2.00.00, "data": 2.00.00}
|
|
|
|
"""
|
2023-03-24 17:10:10 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-03-28 16:28:57 +00:00
|
|
|
self.__config, "chuni", "version", default={}
|
|
|
|
)[version]
|
2023-03-24 17:10:10 +00:00
|
|
|
|
|
|
|
|
2023-03-09 16:38:58 +00:00
|
|
|
class ChuniCryptoConfig:
|
2023-02-17 06:02:21 +00:00
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
2023-03-09 16:38:58 +00:00
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
@property
|
|
|
|
def keys(self) -> Dict:
|
|
|
|
"""
|
|
|
|
in the form of:
|
2023-03-09 16:38:58 +00:00
|
|
|
internal_version: [key, iv]
|
2023-02-17 06:02:21 +00:00
|
|
|
all values are hex strings
|
|
|
|
"""
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "crypto", "keys", default={}
|
|
|
|
)
|
2023-02-17 06:02:21 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def encrypted_only(self) -> bool:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "crypto", "encrypted_only", default=False
|
|
|
|
)
|
|
|
|
|
2024-01-08 23:22:09 +00:00
|
|
|
class ChuniMatchingConfig:
|
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "matching", "enable", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def match_time_limit(self) -> int:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "matching", "match_time_limit", default=60
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def match_error_limit(self) -> int:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "matching", "match_error_limit", default=9999
|
|
|
|
)
|
2023-02-17 06:02:21 +00:00
|
|
|
|
|
|
|
class ChuniConfig(dict):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
self.server = ChuniServerConfig(self)
|
2023-03-24 17:10:10 +00:00
|
|
|
self.team = ChuniTeamConfig(self)
|
2023-03-28 16:28:57 +00:00
|
|
|
self.mods = ChuniModsConfig(self)
|
2023-03-24 17:10:10 +00:00
|
|
|
self.version = ChuniVersionConfig(self)
|
2023-03-09 16:38:58 +00:00
|
|
|
self.crypto = ChuniCryptoConfig(self)
|
2024-01-08 23:22:09 +00:00
|
|
|
self.matching = ChuniMatchingConfig(self)
|