fea2530727
немного расширил функции с базой данных
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
def add_new_event():
|
|
name = input("Введите название ивента\n")
|
|
description = input("Введите описание ивента\n")
|
|
try:
|
|
well = input("Этот ивент хороший?\n")
|
|
if well == "True":
|
|
well = True
|
|
else:
|
|
well = False
|
|
except Exception as e:
|
|
return e
|
|
variants = input("Введите варианты развития ивентов, разделённые */!/*\n").split("*/!/*")
|
|
consequence = input("Введите функции которые выполнятся при варианте ивента, "
|
|
"разделённые */!/*\n").split("*/!/*")
|
|
probability_consequence = [int(i) for i in input("Введите вероятности вариантов ивентов,"
|
|
" разделённые */!/*\n").split("*/!/*")]
|
|
if len(variants) == len(consequence) == len(probability_consequence):
|
|
response = {
|
|
"name": name,
|
|
"description": description,
|
|
"variants": variants,
|
|
"consequence": consequence,
|
|
"probability_consequence": probability_consequence,
|
|
"probability": 50,
|
|
"well": well
|
|
}
|
|
from modules.DB import UseDB
|
|
db = UseDB("events")
|
|
db.insert_document(response)
|
|
return response
|
|
else:
|
|
return "Длины variants, consequence и probability_consequence не равны"
|
|
|
|
|
|
def main():
|
|
while True:
|
|
answer = input("Что сегодня сделаем?\n")
|
|
if answer == "добавить эвент":
|
|
print(add_new_event())
|
|
else:
|
|
print("Ничего не понятно")
|
|
quit(0)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|