-
Notifications
You must be signed in to change notification settings - Fork 1k
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 #874
base: master
Are you sure you want to change the base?
Solution #874
Conversation
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.
Your code meets the task requirements and is well-structured overall! 🎉 While there are some areas for improvement, such as reducing repetition in the battle logic and knight initialization, these are minor and don't impact the functionality. Keep up the great work, and consider these suggestions for future enhancements to make your code even more maintainable and readable. 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
lancelot = Knight(**knightsconfig["lancelot"]) | ||
arthur = Knight(**knightsconfig["arthur"]) | ||
mordred = Knight(**knightsconfig["mordred"]) | ||
red_knight = Knight(**knightsconfig["red_knight"]) |
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.
Consider refactoring the creation of Knight
instances to avoid repetition. You could use a loop or a helper function to initialize the knights, which would make the code more maintainable and adhere to the DRY principle from the checklist.
lancelot.take_damage(mordred.power) | ||
mordred.take_damage(lancelot.power) | ||
|
||
if red_knight["hp"] <= 0: | ||
red_knight["hp"] = 0 | ||
arthur.take_damage(red_knight.power) | ||
red_knight.take_damage(arthur.power) |
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.
The battle logic is repeated for each pair of knights. Consider creating a helper function to handle the battle between two knights. This would reduce code duplication and improve readability.
No description provided.