Skip to content

Commit

Permalink
Update warrior.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 8, 2024
1 parent f38677d commit 4770714
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions kyu_4/the_greatest_warrior/warrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Warrior:
"""

def __init__(self):
"""Create a new warrior instance."""
# A warrior's experience starts from 100
self.__experience = BASIC_EXPERIENCE
# A warrior starts at level 1
Expand Down Expand Up @@ -67,24 +68,23 @@ def __set_level(self) -> int:
by another 100, the warrior's level rises to
the next level.
:return:
:return: int
"""
new_level = self.experience // BASIC_EXPERIENCE
return new_level if new_level <= 100 else 100

def __update_experience(self, experience: int):
def __update_experience(self, experience: int) -> None:
"""
Update expirience.
Update experience.
A warrior's experience is cumulative, and does not
reset with each rise of level. The only exception
is when the warrior reaches level 100, with which
the experience stops at 10000.
:return:
"""
if self.level == 100:
self.__experience = MAX_EXPERIENCE
elif self.experience + experience > MAX_EXPERIENCE:
if (self.level == 100
or self.experience + experience > MAX_EXPERIENCE):
self.__experience = MAX_EXPERIENCE
else:
self.__experience += experience
Expand Down Expand Up @@ -118,7 +118,7 @@ def experience(self) -> int:
"""
Return experience value.
:return:
:return: int
"""
return self.__experience

Expand All @@ -127,16 +127,16 @@ def achievements(self) -> list:
"""
Return achievements as a list.
:return:
:return: list
"""
return self.__achievements

def battle(self, enemy_level: int) -> str:
"""
Return message based on the result of the battle.
:param enemy_level:
:return:
:param enemy_level: int
:return: str
"""
msg: str = ''
# If an enemy level does not fall in the range of 1 to 100,
Expand Down Expand Up @@ -174,13 +174,15 @@ def battle(self, enemy_level: int) -> str:

def training(self, params: list) -> str:
"""
Training method.
Training will accept an array of three elements:
the description,
the experience points your warrior earns,
and the minimum level requirement.
1. the description.
2. the experience points your warrior earns.
3. the minimum level requirement.
:param params:
:return:
:param params: list

Check warning on line 184 in kyu_4/the_greatest_warrior/warrior.py

View check run for this annotation

Codecov / codecov/patch

kyu_4/the_greatest_warrior/warrior.py#L184

Added line #L184 was not covered by tests
:return: str
"""
# If the warrior's level meets the minimum level requirement,
# the warrior will receive the experience points from it and
Expand Down

0 comments on commit 4770714

Please sign in to comment.