Conversation
shorodilov
reviewed
Dec 15, 2022
|
|
||
| @staticmethod | ||
| def fight(attack=None, defence=None): | ||
| if attack == 'Warrior' and defence == 'Robber' or attack == 'Robber' and defence == 'Wizard' or attack == 'Wizard' and defence == 'Warrior': |
There was a problem hiding this comment.
Довгі рядки.
Краще роби переноси у таких випадках.
| print('You enter wrong value') | ||
|
|
||
| @staticmethod | ||
| def fight(attack=None, defence=None): |
There was a problem hiding this comment.
Тут не потрібні аргументи за замовчуванням
| f'Health points of {player.player_name} is {player.health_points}\n' | ||
| f'Health points of Enemy is {enemy.health_points}') | ||
| while True: | ||
| if round % 2 == 0: |
There was a problem hiding this comment.
Тут ліпше без if робити. По факту ти виконуєш не потрібну роботу, перевіряючи кратність двом.
Просто запусти у блоці try/except один за одним виклики attack та defense.
| return self.attack | ||
|
|
||
| def select_defence(self): | ||
| self.defence = random.choice(list(action_hero.values())) |
There was a problem hiding this comment.
Suggested change
| self.defence = random.choice(list(action_hero.values())) | |
| return random.choice(list(action_hero.values())) |
| self.health_points -= 1 | ||
|
|
||
| def select_attack(self): | ||
| self.attack = random.choice(list(action_hero.values())) |
There was a problem hiding this comment.
Suggested change
| self.attack = random.choice(list(action_hero.values())) | |
| return random.choice(list(action_hero.values())) |
| rezult_defence = self.fight(attack=enemy_obj.select_attack(), defence=self.select_defence()) | ||
| if rezult_defence: | ||
| self.health_points -= 1 | ||
| if self.health_points == 0: |
There was a problem hiding this comment.
Перекинь цю перевірку до decrease_health
| rezult_attack = self.fight(attack=self.select_attack(), defence=enemy_obj.select_defence()) | ||
| if rezult_attack: | ||
| enemy_obj.descrease_health() | ||
| if enemy_obj.health_points == 0: |
There was a problem hiding this comment.
Перекинь цю перевірку до decrease_health
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.