-
Notifications
You must be signed in to change notification settings - Fork 0
init module #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
init module #4
Conversation
shorodilov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9/10
Взагалі супер: просто, чистенько, елегантно.
Прибери лише оті не зрозумілі except ...: raise і буде кайфово.
challenge_rst/models.py
Outdated
| try: | ||
| print('YOUR DEFENCE IS FAILED!') | ||
| self.decrease_health(settings.SCORE_PLAYER_DOWN) | ||
| except GameOver: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А який у цьому сенс? Ти відловив ексепшн і одразу ж його зарайзив.
challenge_rst/models.py
Outdated
| print('YOUR ATTACK IS SUCCESSFUL!') | ||
| self.score_points += settings.SCORE_PLAYER_ADD | ||
| enemy.decrease_health(settings.SCORE_ENEMY_DOWN) | ||
| except EnemyDown: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А який у цьому сенс? Ти відловив ексепшн і одразу ж його зарайзив.
challenge_rst/models.py
Outdated
| random_person = str(randint(1, 3)) | ||
| return random_person | ||
|
|
||
| def decrease_health(self, score_down): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я б радив прибрати залежність від аргументу.
Ти все одно використовуєш константу - отже просто віднімай 1 у тілі методу.
challenge_rst/models.py
Outdated
| ) | ||
| return fight_choice | ||
|
|
||
| def decrease_health(self, score_down): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я б радив прибрати залежність від аргументу.
Ти все одно використовуєш константу - отже просто віднімай 1 у тілі методу.
challenge_rst/engine.py
Outdated
| player.attack(enemy) | ||
| player.defence(enemy) | ||
| except EnemyDown: | ||
| player.score_points += settings.EXTRA_SCORE_POINTS_ADD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нормально.
Цей коментар більше для інформації - щоб не модифікувати стан обʼєкта напряму, краще зробити метод, що буде додавати гравцю бали. Якийсь add_score(points).
|
Так, зрозумів, два раза exception зробив на те саме. Поприбирав зайве та додав метод add_score. |
shorodilov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9/10
| return player_name | ||
|
|
||
|
|
||
| def add_score(points): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Це ж метод, для додавання балів.
Навіщо оці перекидання чисел туди-сюди?
def add_score(points: int) -> None:
self.score += points
No description provided.