-
Notifications
You must be signed in to change notification settings - Fork 940
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 #781
base: master
Are you sure you want to change the base?
Solution #781
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.
Add all changed files to the PR
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.
Several changes were requested
app/Battle/battle.py
Outdated
|
||
|
||
def battle(knights: dict) -> dict: | ||
# apply weapon |
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.
Remove these comments, the code is self-explicit enough
app/Battle/__init__.py
Outdated
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.
Please, use lower case in directory names here and in the other places as well
app/Battle/battle.py
Outdated
first_knight = knights_list[stats] | ||
second_knight = knights_list[stats + 2] | ||
first_knight["hp"] -= (second_knight["power"] | ||
- first_knight["protection"]) | ||
second_knight["hp"] -= (first_knight["power"] | ||
- second_knight["protection"]) | ||
if first_knight["hp"] <= 0: | ||
first_knight["hp"] = 0 | ||
if second_knight["hp"] <= 0: | ||
second_knight["hp"] = 0 | ||
result.update({ | ||
first_knight["name"]: first_knight["hp"], | ||
second_knight["name"]: second_knight["hp"] | ||
}) |
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.
You could place part of the logic that happens in the loop to a separate function for a better readability
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.
There is no need to create separate file for each function, create a single file utils.py
and place armour, potion and weapon functions there
app/main.py
Outdated
|
||
|
||
print(battle(KNIGHTS)) | ||
# battle |
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.
Remove redundant comments
app/main.py
Outdated
from app.Battle.battle import battle | ||
|
||
|
||
knights = { |
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.
Place knights config to a separate file for better logic separation
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.
app/main.py
Outdated
|
||
print(battle(KNIGHTS)) | ||
# battle | ||
print(battle(knights)) |
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.
It could be a good idea to use if __name__ == "__main__"
here
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.
GJ!
No description provided.