2023-02-17 07:02:21 +01:00
|
|
|
from core.config import CoreConfig
|
|
|
|
from typing import Dict
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
|
|
|
class ChuniServerConfig:
|
2023-02-17 07:02:21 +01:00
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
2023-03-09 17:38:58 +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, "chuni", "server", "enable", default=True
|
|
|
|
)
|
|
|
|
|
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, "chuni", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
2023-10-07 18:31:08 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def news_msg(self) -> str:
|
2023-10-09 08:47:55 +02:00
|
|
|
return CoreConfig.get_config_field(
|
2023-10-07 18:31:08 +02:00
|
|
|
self.__config, "chuni", "server", "news_msg", default=""
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-03-24 18:10:10 +01: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 12:04:25 +02:00
|
|
|
@property
|
|
|
|
def rank_scale(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "team", "rank_scale", default="False"
|
|
|
|
)
|
2023-03-24 18:10:10 +01:00
|
|
|
|
|
|
|
|
2023-03-28 18:28:57 +02:00
|
|
|
class ChuniModsConfig:
|
2023-03-24 18:10:10 +01:00
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
2023-03-28 18:28:57 +02:00
|
|
|
@property
|
|
|
|
def use_login_bonus(self) -> bool:
|
2023-03-24 18:10:10 +01:00
|
|
|
return CoreConfig.get_config_field(
|
2023-03-28 18:28:57 +02:00
|
|
|
self.__config, "chuni", "mods", "use_login_bonus", default=True
|
2023-03-24 18:10:10 +01:00
|
|
|
)
|
|
|
|
|
2023-03-28 18:28:57 +02: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 18:10:10 +01:00
|
|
|
return CoreConfig.get_config_field(
|
2023-03-28 18:28:57 +02:00
|
|
|
self.__config, "chuni", "version", default={}
|
|
|
|
)[version]
|
2023-03-24 18:10:10 +01:00
|
|
|
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
class ChuniCryptoConfig:
|
2023-02-17 07:02:21 +01:00
|
|
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
|
|
|
self.__config = parent_config
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
@property
|
|
|
|
def keys(self) -> Dict:
|
|
|
|
"""
|
|
|
|
in the form of:
|
2023-03-09 17:38:58 +01:00
|
|
|
internal_version: [key, iv]
|
2023-02-17 07:02:21 +01:00
|
|
|
all values are hex strings
|
|
|
|
"""
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "crypto", "keys", default={}
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def encrypted_only(self) -> bool:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "chuni", "crypto", "encrypted_only", default=False
|
|
|
|
)
|
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
class ChuniConfig(dict):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
self.server = ChuniServerConfig(self)
|
2023-03-24 18:10:10 +01:00
|
|
|
self.team = ChuniTeamConfig(self)
|
2023-03-28 18:28:57 +02:00
|
|
|
self.mods = ChuniModsConfig(self)
|
2023-03-24 18:10:10 +01:00
|
|
|
self.version = ChuniVersionConfig(self)
|
2023-03-09 17:38:58 +01:00
|
|
|
self.crypto = ChuniCryptoConfig(self)
|