Skip to content

Commit

Permalink
Opt: improve fetching cached teams for arena top-100
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Perestoronin committed Dec 18, 2019
1 parent 3070d2b commit 7a15831
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

## `master`
## `3.4.0b2`

- **Оптимизация**: настройки арены по умолчанию, новая утилита для отладки
- **Оптимизация**: улучшен подбор команд для атаки на Топ-100

## `3.4.0b1`

Expand Down
7 changes: 4 additions & 3 deletions bestmobabot/arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ def filter_enemies(self, enemies: Iterable[BaseArenaEnemy]) -> Iterable[BaseAren
logger.debug('Skipped empty user #{}.', enemy.user_id)
continue
if len(enemy.teams) < self.n_required_teams:
if teams := self.db.get(f'{self.enemy_key(enemy)}:teams'):
logger.warning('Using stored teams for enemy {}.', enemy.user)
enemy.set_teams([[Hero(**hero) for hero in team] for team in teams])
if value := self.db.get(f'{self.enemy_key(enemy)}:teams'):
logger.warning('Using cached teams for enemy {}.', enemy.user)
cached_teams = [[Hero(**hero) for hero in team] for team in value]
enemy.set_teams([*enemy.teams, *cached_teams[len(enemy.teams):]])
else:
logger.warning('Enemy has unknown teams: {}.', enemy.user)
continue
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='bestmobabot',
version='3.4.0b1',
version='3.4.0b2',
author='Pavel Perestoronin',
author_email='eigenein@gmail.com',
description='Hero Wars game bot 🏆',
Expand Down

0 comments on commit 7a15831

Please sign in to comment.