class Debug: """Debugging options.""" RESPOND_TO_DM = str2bool(os.getenv("RESPOND_TO_DM", "no")) DROP_TABLES_ON_RESTART = str2bool(os.getenv("DROP_TABLES_ON_RESTART", "no")) BENCHMARK_POMWAR_ATTACK = str2bool( os.getenv("BENCHMARK_POMWAR_ATTACK", "no")) POMS_COMMAND_IS_PUBLIC = str2bool(os.getenv("POMS_COMMAND_IS_PUBLIC", "no"))
def get_random( self, *, team: Union[str, Team], average_daily_actions: int, critical: bool, heavy: bool, ) -> Attack: """Return a random Attack from the XMLs.""" tags = {False: _XMLTags.NORMAL_ATTACK, True: _XMLTags.HEAVY_ATTACK} tier = self._get_tier_from_average_actions(average_daily_actions) choice = random.choice([ e for e in flatten( x.xpath( f".//team[@name='{team}']/tier[@level='{tier}']/{tags[heavy]}" ) for x in self._xmls) if str2bool(e.attrib.get("critical", "false")) == critical ]) return Attack( story=choice.text.strip(), is_heavy=heavy, is_critical=critical, )
class Debug: """Debugging options.""" RESPOND_TO_DM = str2bool(os.getenv("RESPOND_TO_DM", "no")) DROP_TABLES_ON_RESTART = str2bool(os.getenv("DROP_TABLES_ON_RESTART", "no")) POMS_COMMAND_IS_PUBLIC = str2bool(os.getenv("POMS_COMMAND_IS_PUBLIC", "no")) # Useful for benchmarking and tiers testing. POMWARS_ACTIONS_ALWAYS_SUCCEED = str2bool(os.getenv("POMWARS_ACTIONS_ALWAYS_SUCCEED", "no")) @classmethod def disable(cls) -> None: """Override settings from environment variables and set all boolean debug options to false. Useful for unit tests. """ for attr, _ in filter(lambda p: isinstance(p[1], bool), ((p, getattr(cls, p)) for p in dir(cls))): setattr(cls, attr, False)
class Debug: """Debugging options.""" RESPOND_TO_DM = str2bool(os.getenv("RESPOND_TO_DM", "no")) DROP_TABLES_ON_RESTART = str2bool(os.getenv("DROP_TABLES_ON_RESTART", "no")) BENCHMARK_POMWAR_ATTACK = str2bool( os.getenv("BENCHMARK_POMWAR_ATTACK", "no")) POMS_COMMAND_IS_PUBLIC = str2bool(os.getenv("POMS_COMMAND_IS_PUBLIC", "no")) @classmethod def disable(cls) -> None: """Override settings from environment variables and set all boolean debug options to false. Useful for unit tests. """ for attr, _ in filter(lambda p: isinstance(p[1], bool), ((p, getattr(cls, p)) for p in dir(cls))): setattr(cls, attr, False)
class Pomwars: """Configuration for Pom Wars.""" LOAD_POM_WARS = str2bool(os.getenv("LOAD_POM_WARS", "no")) KNIGHT_ROLE = os.getenv("KNIGHT_ROLE") VIKING_ROLE = os.getenv("VIKING_ROLE") BASE_DAMAGE_FOR_NORMAL_ATTACKS = positive_int( os.getenv("BASE_DAMAGE_FOR_NORMAL_ATTACKS")) BASE_DAMAGE_FOR_HEAVY_ATTACKS = positive_int( os.getenv("BASE_DAMAGE_FOR_HEAVY_ATTACKS")) BASE_CHANCE_FOR_CRITICAL = 0.20 SUCCESSFUL_ATTACK_EMOTE = os.getenv("SUCCESSFUL_ATTACK_EMOTE") SUCCESSFUL_DEFEND_EMOTE = os.getenv("SUCCESSFUL_DEFEND_EMOTE") ACTION_COLOUR = 0xF5F5DC HEAVY_COLOUR = 0xFFD700 NORMAL_COLOUR = 0xec5c5b # Normal attack DEFEND_COLOUR = 0x55aedd JOIN_CHANNEL_NAME = os.getenv("JOIN_CHANNEL_NAME").lstrip("#") KNIGHT_ONLY_GUILDS = [ int(guild.strip()) if guild.strip() else 0 for guild in os.getenv("KNIGHT_ONLY_GUILDS").split(",") ] VIKING_ONLY_GUILDS = [ int(guild.strip()) if guild.strip() else 0 for guild in os.getenv("VIKING_ONLY_GUILDS").split(",") ] HEAVY_ATTACK_LEVEL_VALIANT_ATTEMPT_CONDOLENCE_REWARDS = { # Level: (Min chance, Max chance) 1: (0.25, 0.75), 2: (0.30, 0.80), 3: (0.30, 0.80), 4: (0.33, 0.83), 5: (0.37, 0.87), } HEAVY_PITY_INCREMENT = 0.10 HEAVY_QUALIFIERS = ["heavy", "hard", "sharp", "strong"] DEFEND_LEVEL_MULTIPLIERS = {1: 0.05, 2: 0.08, 3: 0.07, 4: 0.08, 5: 0.09} DEFEND_DURATION_MINUTES = 30 MAXIMUM_TEAM_DEFENCE = 0.25 class Emotes: """Emotes for use in embeds.""" KNIGHT = "<:knights:622832507766702100>" VIKING = "<:vikings:705822896978919594>" WINNER = "<a:winner:795418467908976671>" ATTACK = "<:attack:794694043015446530>" CRITICAL = "<:criticalhit:794710983536672788>" DEFEND = "<:defend:794694015861260308>"
class Pomwars: """Configuration for Pom Wars.""" KNIGHT_ROLE = "Knight" VIKING_ROLE = "Viking" AVERAGING_PERIOD_DAYS = 7 MAX_FORGIVEN_DAYS = 2 # NOTE: When this is set to False, then there is a hard cap on the number # of actions each day which can be considered for averaging, called the # Shadow Cap. CONSIDER_ONLY_SUCCESSFUL_ACTIONS = True SHADOW_CAP_LIMIT_PER_DAY = 10 BASE_DAMAGE_FOR_NORMAL_ATTACKS = 10 BASE_DAMAGE_FOR_HEAVY_ATTACKS = 40 BASE_CHANCE_FOR_CRITICAL = 0.20 DAMAGE_MULTIPLIER_FOR_CRITICAL = 1.35 ACTION_COLOUR = 0xF5F5DC HEAVY_ATTACK_COLOUR = 0xFFD700 NORMAL_ATTACK_COLOUR = 0xec5c5b DEFEND_COLOUR = 0x55aedd LOAD_POM_WARS = str2bool(os.getenv("LOAD_POM_WARS", "no")) SUCCESSFUL_ATTACK_EMOTE = os.getenv("SUCCESSFUL_ATTACK_EMOTE") SUCCESSFUL_DEFEND_EMOTE = os.getenv("SUCCESSFUL_DEFEND_EMOTE") JOIN_CHANNEL_NAME = os.getenv("JOIN_CHANNEL_NAME").lstrip("#") KNIGHT_ONLY_GUILDS = [ int(guild.strip()) if guild.strip() else 0 for guild in os.getenv("KNIGHT_ONLY_GUILDS").split(",") ] VIKING_ONLY_GUILDS = [ int(guild.strip()) if guild.strip() else 0 for guild in os.getenv("VIKING_ONLY_GUILDS").split(",") ] HEAVY_ATTACK_LEVEL_VALIANT_ATTEMPT_CONDOLENCE_REWARDS = { # Level: (Min chance, Max chance) 1: (0.25, 0.75), 2: (0.30, 0.80), 3: (0.30, 0.80), 4: (0.33, 0.83), 5: (0.37, 0.87), } HEAVY_PITY_INCREMENT = 0.10 HEAVY_QUALIFIERS = ["heavy", "hard", "sharp", "strong"] DEFEND_LEVEL_MULTIPLIERS = {1: 0.05, 2: 0.06, 3: 0.07, 4: 0.08, 5: 0.09} DEFEND_DURATION_MINUTES = 30 MAXIMUM_TEAM_DEFENCE = 0.25 class Emotes: """Emotes for use in embeds.""" KNIGHT = "<:knights:622832507766702100>" VIKING = "<:vikings:705822896978919594>" WINNER = "<a:winner:795418467908976671>" ATTACK = "<:attack:794694043015446530>" CRITICAL = "<:criticalhit:794710983536672788>" DEFEND = "<:defend:794694015861260308>"