artemis/titles/idac/config.py
Hoe 85e84eff67 Let battle_event follow game version (#19)
Reviewed-on: #19
Co-authored-by: Hoe <kwangaho@gmail.com>
Co-committed-by: Hoe <kwangaho@gmail.com>
2024-07-25 19:50:50 +00:00

217 lines
5.6 KiB
Python

from typing import Dict
from core.config import CoreConfig
class IDACServerConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "enable", default=True
)
@property
def loglevel(self) -> int:
return CoreConfig.str_to_loglevel(
CoreConfig.get_config_field(
self.__config, "idac", "server", "loglevel", default="info"
)
)
@property
def ssl(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "ssl", default=False
)
@property
def ssl_cert(self) -> str:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "ssl_cert", default="cert/title.crt"
)
@property
def ssl_key(self) -> str:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "ssl_key", default="cert/title.key"
)
@property
def matching_host(self) -> str:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "matching_host", default="127.0.0.1"
)
@property
def matching(self) -> int:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "port_matching", default=20000
)
@property
def echo1(self) -> int:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "port_echo1", default=20001
)
@property
def echo2(self) -> int:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "port_echo2", default=20002
)
@property
def matching_p2p(self) -> int:
return CoreConfig.get_config_field(
self.__config, "idac", "server", "port_matching_p2p", default=20003
)
class IDACTimereleaseConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def timerelease_no(self) -> int:
return CoreConfig.get_config_field(
self.__config, "idac", "timerelease", "timerelease_no", default=1
)
@property
def timerelease_avatar_gacha_no(self) -> int:
return CoreConfig.get_config_field(
self.__config, "idac", "timerelease", "timerelease_avatar_gacha_no", default=1
)
class IDACStampConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "stamp", "enable", default=True
)
@property
def enabled_stamps(self) -> Dict:
"""
In the form of:
<version as int>:
- <stamp name 1>
- <stamp name 2>
- <stamp name 3>
max 3 stamps per version
f.e.:
150:
- "touhou_remilia_scarlet"
- "touhou_flandre_scarlet"
- "touhou_sakuya_izayoi"
"""
return CoreConfig.get_config_field(
self.__config,
"idac",
"stamp",
"enabled_stamps",
default={},
)
class IDACTimetrialConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "timetrial", "enable", default=True
)
@property
def enabled_timetrial(self) -> Dict:
"""
In the form of:
<version as int>: <timetrial name>
f.e.:
150: "touhou_remilia_scarlet"
"""
return CoreConfig.get_config_field(
self.__config,
"idac",
"timetrial",
"enabled_timetrial",
default={},
)
class IDACTBattleGiftConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "battle_event", "enable", default=True
)
@property
def enabled_battle_event(self) -> Dict:
"""
In the form of:
<version as int>: <battle_event name>
f.e.:
170: "touhou_1st"
"""
return CoreConfig.get_config_field(
self.__config,
"idac",
"battle_event",
"enabled_battle_event",
default={},
)
class IDACRoundConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "round_event", "enable", default=True
)
@property
def enabled_round(self) -> str:
return CoreConfig.get_config_field(
self.__config,
"idac",
"round_event",
"enabled_round",
default="S2R2",
)
@property
def last_round(self) -> str:
return CoreConfig.get_config_field(
self.__config,
"idac",
"round_event",
"last_round",
default="S2R1",
)
class IDACConfig(dict):
def __init__(self) -> None:
self.server = IDACServerConfig(self)
self.timerelease = IDACTimereleaseConfig(self)
self.stamp = IDACStampConfig(self)
self.timetrial = IDACTimetrialConfig(self)
self.battle_event = IDACTBattleGiftConfig(self)
self.round_event = IDACRoundConfig(self)