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

Добавили игру AdventuresOfTheHero #218

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stdian
Copy link

@stdian stdian commented Mar 26, 2022

Консольная игра всех времен и народов!

@stdian stdian closed this Mar 26, 2022
@stdian stdian reopened this Mar 26, 2022
@AndrewKhukhrianskyi
Copy link

Сейчас тут будет писать мамкин ревьювер.

Copy link

@AndrewKhukhrianskyi AndrewKhukhrianskyi left a comment

Choose a reason for hiding this comment

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

Кратко:

  1. Структура оформления кода. Не пиши все скопом а разбивай на отдельные файлы.
  2. Логические операции. Много лишних телодвижений и строк
  3. Комментарии. Если надо - сохраняй в отдельном файле, аля comments.txt и явно укажи, на каких строках это должно быть
  4. Константы. Выражения, которые повторяются, заноси в отдельный файл config и доставай оттуда
  5. Улучшения. Пользуйся шнягой в виде синтаксического сахара. Часто ускоряет работу программы. Меньше строк и та же эффективность - выше скорость работы (Байтодроч, немного, да, но на реальной практике тебя за это по голове гладить не будут. Такие явные факапы нужно закрывать)
  6. ???
  7. PROFIT!

P.S - Я автотестер на пайтоне и преподаватель. Просто чтобы у тебя не было ощущения, что я втираю какую-то дичь. Также пробуй дергать негативные способы сломать твою программу, типа использование букв вместо чисел и тп, где это уместно. Так ты закроешь лишние прорехи.

c = input('>>>')
try:
c = int(c)
except:

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):

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)

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)

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:

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:

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:

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.Пришел найти своего друга - гнома Нерута. Ты случайно не знаешь его?')

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)

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)

Choose a reason for hiding this comment

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

Тут тоже по комментам.

@AndrewKhukhrianskyi
Copy link

AndrewKhukhrianskyi commented Jan 7, 2023

Хз актуально ли. (P.S - знаю шо это стеб, но он для меня вырвиглазен. Бегаю по комнате ищу свои глазки)

@cat-policlot
Copy link

Хз актуально ли. (P.S - знаю шо это стеб, но он для меня вырвиглазен. Бегаю по комнате ищу свои глазки)

да, более чем актуально )

Copy link

@ProximalElk6186 ProximalElk6186 left a comment

Choose a reason for hiding this comment

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

Збс

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.

4 participants