починил добавление ивентов

немного расширил функции с базой данных
This commit is contained in:
2022-12-26 18:50:41 +07:00
parent 6437995082
commit fea2530727
4 changed files with 21 additions and 3 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
[Settings]
difficulty = Проигрывать весело
difficulty = Ïðîñòàÿ
sound = True
+9 -2
View File
@@ -2,7 +2,11 @@ def add_new_event():
name = input("Введите название ивента\n")
description = input("Введите описание ивента\n")
try:
well = bool(input("Этот ивент хороший?\n"))
well = input("Этот ивент хороший?\n")
if well == "True":
well = True
else:
well = False
except Exception as e:
return e
variants = input("Введите варианты развития ивентов, разделённые */!/*\n").split("*/!/*")
@@ -17,9 +21,12 @@ def add_new_event():
"variants": variants,
"consequence": consequence,
"probability_consequence": probability_consequence,
"probability": 0,
"probability": 50,
"well": well
}
from modules.DB import UseDB
db = UseDB("events")
db.insert_document(response)
return response
else:
return "Длины variants, consequence и probability_consequence не равны"
+3
View File
@@ -16,3 +16,6 @@ class UseDB:
def update_document(self, query_elements, 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)
+8
View File
@@ -0,0 +1,8 @@
from modules.DB import UseDB
db = UseDB("events")
for i in db.find_document({}):
print(i)
# db.del_document({"name": i["name"]})
# db.update_document({"name": "test not bad"}, {"probability": 50})
db.update_document({"name": "test bad "}, {"probability": 50})