Skip to content

Commit

Permalink
:fix: Using of potions and scrolls settings
Browse files Browse the repository at this point in the history
  • Loading branch information
esemi committed Apr 4, 2024
1 parent 41b0cb9 commit 7570990
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions epsilion_wars_mmorpg_automation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class AppSettings(BaseSettings):
'Внутренняя сила (2🗡; 3🛡)': 2,
'По наитию (3 🥊)': 1,
}
use_potions: bool = Field(default=True)
enabled_potions: set[str] = {
'/use_reg24',
'/use_reg7',
Expand All @@ -177,6 +178,7 @@ class AppSettings(BaseSettings):
'/use_buff_int_1_1',
'/use_buff_int_2_1',
}
use_scrolls: bool = Field(default=True)
enabled_scrolls: set[str] = {
'/use_p_luck',
'/use_luck',
Expand Down
18 changes: 10 additions & 8 deletions epsilion_wars_mmorpg_automation/trainer/handlers/tear_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ async def use_potions_and_show_scrolls(event: events.NewMessage.Event) -> None:
"""Use potions and show scrolls after."""
logger.info('Use potions handler')
enabled_potions = app_settings.enabled_potions

available_potions = parsers.get_potions(event.message.message)
for potion in available_potions:
if potion in enabled_potions:
await action.common_actions.execute_command(event.chat_id, potion)

if app_settings.use_potions:
for potion in available_potions:
if potion in enabled_potions:
await action.common_actions.execute_command(event.chat_id, potion)

await action.common_actions.show_scrolls(event)

Expand All @@ -33,10 +34,11 @@ async def use_scrolls_and_refresh(event: events.NewMessage.Event) -> None:
logger.info('Use scrolls handler')

enabled_scrolls = app_settings.enabled_scrolls

available_scrolls = parsers.get_scrolls(event.message.message)
for scroll in available_scrolls:
if scroll in enabled_scrolls:
await action.common_actions.execute_command(event.chat_id, scroll)

if app_settings.use_scrolls:
for scroll in available_scrolls:
if scroll in enabled_scrolls:
await action.common_actions.execute_command(event.chat_id, scroll)

return await action.common_actions.ping(event)

0 comments on commit 7570990

Please sign in to comment.