From 942cf22c798298e63a015472ef6a373316617cae Mon Sep 17 00:00:00 2001 From: Pavel Perestoronin Date: Sun, 15 Dec 2019 14:06:39 +0100 Subject: [PATCH] Fix: attribute error --- CHANGELOG.md | 4 ++++ bestmobabot/arena.py | 2 +- bestmobabot/dataclasses_.py | 11 +++++------ setup.py | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dba77d2..23ac5a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## `3.4.0b1` + +- **Исправление**: падение при переборе противников на арене + ## `3.4.0b0` - **Новое**: сохраненная информация о командах других игроков будет использоваться для атаки на топ-100 Гранд Арены diff --git a/bestmobabot/arena.py b/bestmobabot/arena.py index a0dc53f..116080a 100644 --- a/bestmobabot/arena.py +++ b/bestmobabot/arena.py @@ -157,7 +157,7 @@ def filter_enemies(self, enemies: Iterable[BaseArenaEnemy]) -> Iterable[BaseAren 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 this enemy.') - enemy.teams = [[Hero(**hero) for hero in team] for team in teams] + enemy.set_teams([[Hero(**hero) for hero in team] for team in teams]) else: logger.warning('Enemy has unknown teams: {}.', enemy.user) continue diff --git a/bestmobabot/dataclasses_.py b/bestmobabot/dataclasses_.py index 5d8b47f..6609208 100644 --- a/bestmobabot/dataclasses_.py +++ b/bestmobabot/dataclasses_.py @@ -319,11 +319,12 @@ class Config: } @property + @abstractmethod def teams(self) -> List[List[Hero]]: raise NotImplementedError() - @teams.setter - def teams(self, teams: List[List[Hero]]): + @abstractmethod + def set_teams(self, teams: List[List[Hero]]): raise NotImplementedError() def __str__(self) -> str: @@ -337,8 +338,7 @@ class ArenaEnemy(BaseArenaEnemy): def teams(self) -> List[List[Hero]]: return [self.heroes] - @teams.setter - def teams(self, teams: List[List[Hero]]): + def set_teams(self, teams: List[List[Hero]]): self.heroes = teams[0] @@ -349,8 +349,7 @@ class GrandArenaEnemy(BaseArenaEnemy): def teams(self) -> List[List[Hero]]: return self.heroes - @teams.setter - def teams(self, teams: List[List[Hero]]): + def set_teams(self, teams: List[List[Hero]]): self.heroes = teams diff --git a/setup.py b/setup.py index 935989a..f9bd6d3 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='bestmobabot', - version='3.4.0b0', + version='3.4.0b1', author='Pavel Perestoronin', author_email='eigenein@gmail.com', description='Hero Wars game bot 🏆',