починил добавление ивентов
немного расширил функции с базой данных
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
[Settings]
|
[Settings]
|
||||||
difficulty = Проигрывать весело
|
difficulty = Ïðîñòàÿ
|
||||||
sound = True
|
sound = True
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ def add_new_event():
|
|||||||
name = input("Введите название ивента\n")
|
name = input("Введите название ивента\n")
|
||||||
description = input("Введите описание ивента\n")
|
description = input("Введите описание ивента\n")
|
||||||
try:
|
try:
|
||||||
well = bool(input("Этот ивент хороший?\n"))
|
well = input("Этот ивент хороший?\n")
|
||||||
|
if well == "True":
|
||||||
|
well = True
|
||||||
|
else:
|
||||||
|
well = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return e
|
return e
|
||||||
variants = input("Введите варианты развития ивентов, разделённые */!/*\n").split("*/!/*")
|
variants = input("Введите варианты развития ивентов, разделённые */!/*\n").split("*/!/*")
|
||||||
@@ -17,9 +21,12 @@ def add_new_event():
|
|||||||
"variants": variants,
|
"variants": variants,
|
||||||
"consequence": consequence,
|
"consequence": consequence,
|
||||||
"probability_consequence": probability_consequence,
|
"probability_consequence": probability_consequence,
|
||||||
"probability": 0,
|
"probability": 50,
|
||||||
"well": well
|
"well": well
|
||||||
}
|
}
|
||||||
|
from modules.DB import UseDB
|
||||||
|
db = UseDB("events")
|
||||||
|
db.insert_document(response)
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return "Длины variants, consequence и probability_consequence не равны"
|
return "Длины variants, consequence и probability_consequence не равны"
|
||||||
|
|||||||
@@ -16,3 +16,6 @@ class UseDB:
|
|||||||
|
|
||||||
def update_document(self, query_elements, new_values):
|
def update_document(self, query_elements, new_values):
|
||||||
self.series_collection.update_one(query_elements, {'$set': new_values})
|
self.series_collection.update_one(query_elements, {'$set': new_values})
|
||||||
|
|
||||||
|
def del_document(self, query_elements):
|
||||||
|
self.series_collection.delete_one(query_elements)
|
||||||
|
|||||||
Reference in New Issue
Block a user