Skip to content

Devel 1#1

Open
Duron1980 wants to merge 2 commits intomasterfrom
devel_1
Open

Devel 1#1
Duron1980 wants to merge 2 commits intomasterfrom
devel_1

Conversation

@Duron1980
Copy link
Owner

No description provided.

@Duron1980 Duron1980 requested a review from shorodilov December 14, 2022 16:04
Copy link

@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.

7/10
Дивись коментарі до роботи.


@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':

Choose a reason for hiding this comment

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

Довгі рядки.
Краще роби переноси у таких випадках.

print('You enter wrong value')

@staticmethod
def fight(attack=None, defence=None):

Choose a reason for hiding this comment

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

Тут не потрібні аргументи за замовчуванням

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:

Choose a reason for hiding this comment

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

Тут ліпше без if робити. По факту ти виконуєш не потрібну роботу, перевіряючи кратність двом.
Просто запусти у блоці try/except один за одним виклики attack та defense.

return self.attack

def select_defence(self):
self.defence = random.choice(list(action_hero.values()))

Choose a reason for hiding this comment

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

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()))

Choose a reason for hiding this comment

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

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:

Choose a reason for hiding this comment

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

Перекинь цю перевірку до 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:

Choose a reason for hiding this comment

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

Перекинь цю перевірку до decrease_health

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.

2 participants