-
Notifications
You must be signed in to change notification settings - Fork 26
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
Добавили игру AdventuresOfTheHero #218
base: main
Are you sure you want to change the base?
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.
Кратко:
- Структура оформления кода. Не пиши все скопом а разбивай на отдельные файлы.
- Логические операции. Много лишних телодвижений и строк
- Комментарии. Если надо - сохраняй в отдельном файле, аля comments.txt и явно укажи, на каких строках это должно быть
- Константы. Выражения, которые повторяются, заноси в отдельный файл config и доставай оттуда
- Улучшения. Пользуйся шнягой в виде синтаксического сахара. Часто ускоряет работу программы. Меньше строк и та же эффективность - выше скорость работы (Байтодроч, немного, да, но на реальной практике тебя за это по голове гладить не будут. Такие явные факапы нужно закрывать)
- ???
- PROFIT!
P.S - Я автотестер на пайтоне и преподаватель. Просто чтобы у тебя не было ощущения, что я втираю какую-то дичь. Также пробуй дергать негативные способы сломать твою программу, типа использование букв вместо чисел и тп, где это уместно. Так ты закроешь лишние прорехи.
c = input('>>>') | ||
try: | ||
c = int(c) | ||
except: |
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.
Папаша, какую ошибку ты тут ловишь? Нихуя не понятно, но очень интересно
screen_saver_thread = None | ||
|
||
|
||
def choose(max = 3): |
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.
параметр max - это зарезервированное выражение в петухоне. Можно дописать нечто в духе max_limit
try: | ||
c = int(c) | ||
except: | ||
return choose(max = max) |
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.
Исходя из коммента выше, нужно будет эту дичь тоже переименовать
if c > 0 and c <= max: | ||
return str(c) | ||
|
||
return choose(max = max) |
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.
Та же дичь
except: | ||
return choose(max = max) | ||
|
||
if c > 0 and c <= max: |
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.
Тут тоже. Также эту дичь, которую ты втираешь, можно передать гораздо проще:
0 < c <= max
strs.append(' ░ ░ ░░ ░ ░ ░ ░░ ░ ░ ░░ ░ ░ ░ ░ ▒ ') | ||
strs.append(' ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ') | ||
|
||
for i in strs: |
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.
Чисто мой доеб - вместо i напиши что-то осмысленное, аля title_part
|
||
def game(): | ||
global money | ||
# try: |
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.
Пункт про комменты тоже глянь.
printkrasivo('Здравствуй, ' + user + ', какими судьбами тебя занесло в наши края?') | ||
p('') | ||
p('1.Я пришел в ваши края за семи магическими душами, разных существ.') | ||
p('2.Пришел найти своего друга - гнома Нерута. Ты случайно не знаешь его?') |
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.
Познакомься с форматированием строк - удобная штука. Строки будут короче и сможешь выебнуться немного об этом
Шо эта: https://pythonworld.ru/osnovy/formatirovanie-strok-metod-format.html
Проще говоря - вшиваешь в строку нужные тебе выражения. Даже можно цыганские фокусы в виде мат. операций всяких делать
try: | ||
c = int(c) | ||
except: | ||
return choose(max = max) |
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.
Функции работают по такому принципу: если у тебя стоит нечто, аля def f(hui = 1) и если ты вызовешь функцию в виде f(), то подставиться параметр по дефолту. Проще говоря, можно будет подставить вместо дефолтного параметра что-то другое, типа f(2) и тогда твой hui будет равен 2. Не имеет смысла явно так писать
|
||
if __name__ == '__main__': | ||
cls() | ||
# init(autoreset=True) |
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.
Тут тоже по комментам.
Хз актуально ли. (P.S - знаю шо это стеб, но он для меня вырвиглазен. Бегаю по комнате ищу свои глазки) |
да, более чем актуально ) |
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.
Збс
Консольная игра всех времен и народов!