добавил debug_functions.py, пока только добавление ивентов и то не полностью
This commit is contained in:
@@ -7,7 +7,8 @@ import configparser
|
||||
def get_random_event():
|
||||
db = UseDB("events")
|
||||
response = db.find_document({})
|
||||
random_event = random.choices([i["_id"] for i in response], weights=[i["probability"] for i in response])
|
||||
random_event = random.choices([i["_id"] for i in response],
|
||||
weights=[i["probability"] for i in response])
|
||||
return db.find_document({"_id": random_event[0]})[0]
|
||||
|
||||
|
||||
@@ -21,21 +22,20 @@ def recalculation_events(well):
|
||||
config = configparser.ConfigParser()
|
||||
config.read("conf/config.ini")
|
||||
difficulty = config['Settings']['difficulty']
|
||||
db = UseDB("events")
|
||||
not_well_events = db.find_document({"well": False})
|
||||
well_events = db.find_document({"well": True})
|
||||
if well:
|
||||
db = UseDB("events")
|
||||
not_well_events = db.find_document({"well": False})
|
||||
for i in not_well_events:
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] + difficulties[difficulty][0]})
|
||||
well_events = db.find_document({"well": True})
|
||||
db.update_document({"_id": i["_id"]},
|
||||
{"probability": i["probability"] + difficulties[difficulty][0]})
|
||||
ratio = len(not_well_events) * difficulties[difficulty][0] / len(well_events)
|
||||
for i in well_events:
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] - ratio})
|
||||
else:
|
||||
db = UseDB("events")
|
||||
well_events = db.find_document({"well": True})
|
||||
for i in well_events:
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] + difficulties[difficulty][1]})
|
||||
not_well_events = db.find_document({"well": False})
|
||||
db.update_document({"_id": i["_id"]},
|
||||
{"probability": i["probability"] + difficulties[difficulty][1]})
|
||||
ratio = len(well_events) * difficulties[difficulty][1] / len(not_well_events)
|
||||
for i in not_well_events:
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] - ratio})
|
||||
|
||||
Reference in New Issue
Block a user