Skip to content

Conversation

@eduardzapadinsky
Copy link
Owner

No description provided.

Copy link
Contributor

@shorodilov shorodilov left a 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 і буде кайфово.

try:
print('YOUR DEFENCE IS FAILED!')
self.decrease_health(settings.SCORE_PLAYER_DOWN)
except GameOver:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А який у цьому сенс? Ти відловив ексепшн і одразу ж його зарайзив.

print('YOUR ATTACK IS SUCCESSFUL!')
self.score_points += settings.SCORE_PLAYER_ADD
enemy.decrease_health(settings.SCORE_ENEMY_DOWN)
except EnemyDown:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А який у цьому сенс? Ти відловив ексепшн і одразу ж його зарайзив.

random_person = str(randint(1, 3))
return random_person

def decrease_health(self, score_down):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я б радив прибрати залежність від аргументу.
Ти все одно використовуєш константу - отже просто віднімай 1 у тілі методу.

)
return fight_choice

def decrease_health(self, score_down):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я б радив прибрати залежність від аргументу.
Ти все одно використовуєш константу - отже просто віднімай 1 у тілі методу.

player.attack(enemy)
player.defence(enemy)
except EnemyDown:
player.score_points += settings.EXTRA_SCORE_POINTS_ADD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нормально.
Цей коментар більше для інформації - щоб не модифікувати стан обʼєкта напряму, краще зробити метод, що буде додавати гравцю бали. Якийсь add_score(points).

@eduardzapadinsky
Copy link
Owner Author

Так, зрозумів, два раза exception зробив на те саме. Поприбирав зайве та додав метод add_score.

Copy link
Contributor

@shorodilov shorodilov left a 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):
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants