Skip to content
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

Solution #801

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VolodymyrPovroznyk
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on the code! 🎉 The structure and use of functions are well done, and the type annotations are correctly applied. While there are some minor improvements suggested, such as using loops for DRY compliance and checking for key existence to avoid errors, these do not critically impact the functionality. Keep up the good work and consider these suggestions for future enhancements! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -0,0 +1,23 @@
def apply_armour(knight_data: dict) -> dict:
knight_data["protection"] = 0

Choose a reason for hiding this comment

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

Consider initializing 'protection' only if it doesn't already exist in 'knight_data'. This will prevent overwriting existing protection values if the function is called multiple times.



def apply_weapon(knight_data: dict) -> dict:
knight_data["power"] += knight_data["weapon"]["power"]

Choose a reason for hiding this comment

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

Ensure that 'weapon' and 'power' keys exist in 'knight_data' before accessing them to avoid potential KeyError exceptions.

knight_stats = ["power", "hp", "protection"]
for stat in knight_stats:
if stat in knight_data["potion"]["effect"]:
knight_data[stat] += knight_data["potion"]["effect"][stat]

Choose a reason for hiding this comment

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

It's a good practice to check if 'potion' and 'effect' keys exist in 'knight_data' before accessing them to prevent KeyError exceptions.

@@ -0,0 +1,16 @@
from app.knight.creation import Knight

Choose a reason for hiding this comment

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

The import statement should use double quotes for consistency with the code style guide. Change from app.knight.creation import Knight to from app.knight.creation import "Knight".

from app.knight.creation import Knight


def check_hp(knights: list[Knight]) -> list[Knight]:

Choose a reason for hiding this comment

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

The function check_hp is correctly defined with type annotations. Ensure that the list of knights is passed correctly when calling this function.

"armour": [],
"weapon": {
"name": "Metal Sword",
"power": 50,

Choose a reason for hiding this comment

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

Trailing commas are generally discouraged in JSON-like structures. Consider removing the trailing comma after the 'power' key.

],
"weapon": {
"name": "Two-handed Sword",
"power": 55,

Choose a reason for hiding this comment

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

Trailing commas are generally discouraged in JSON-like structures. Consider removing the trailing comma after the 'power' key.

],
"weapon": {
"name": "Poisoned Sword",
"power": 60,

Choose a reason for hiding this comment

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

Trailing commas are generally discouraged in JSON-like structures. Consider removing the trailing comma after the 'power' key.

"name": "Blessing",
"effect": {
"hp": +10,
"power": +5,

Choose a reason for hiding this comment

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

Trailing commas are generally discouraged in JSON-like structures. Consider removing the trailing comma after the 'power' key.

Comment on lines +17 to +18
get_damage(knights["lancelot"], knights["mordred"])
get_damage(knights["arthur"], knights["red_knight"])

Choose a reason for hiding this comment

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

Consider using a loop to iterate over pairs of knights to apply the get_damage function. This will help adhere to the DRY principle by avoiding repetitive code.

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