добавил перезапись сложности в config.ini
добавил зависимости вероятностей от сложности немного английской грамматики добавил
This commit is contained in:
+18
-10
@@ -1,6 +1,7 @@
|
||||
from modules.DB import UseDB
|
||||
from loguru import logger
|
||||
import random
|
||||
import configparser
|
||||
|
||||
|
||||
def get_random_event():
|
||||
@@ -11,30 +12,37 @@ def get_random_event():
|
||||
|
||||
|
||||
def recalculation_events(well):
|
||||
difficulties = {
|
||||
"Простая": [5, 5],
|
||||
"Средняя": [5, 2],
|
||||
"Сложная": [5, 1],
|
||||
"Проигрывать весело": [10, 1]
|
||||
}
|
||||
config = configparser.ConfigParser()
|
||||
config.read("conf/config.ini")
|
||||
difficulty = config['Settings']['difficulty']
|
||||
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"] + 5})
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] + difficulties[difficulty][0]})
|
||||
well_events = db.find_document({"well": True})
|
||||
cooficent = len(not_well_events) * 5 / len(well_events)
|
||||
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"] - cooficent})
|
||||
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"] + 5})
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] + difficulties[difficulty][1]})
|
||||
not_well_events = db.find_document({"well": False})
|
||||
cooficent = len(well_events) * 5 / len(not_well_events)
|
||||
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"] - cooficent})
|
||||
db.update_document({"_id": i["_id"]}, {"probability": i["probability"] - ratio})
|
||||
|
||||
|
||||
def start_calculating():
|
||||
logger.remove()
|
||||
logger.add("conf/log.log", level="INFO")
|
||||
logger.info("Валидация началась")
|
||||
logger.debug("Валидация началась")
|
||||
db = UseDB("events")
|
||||
response = db.find_document({})
|
||||
sum_percent_probability = sum([i["probability"] for i in response])
|
||||
@@ -50,4 +58,4 @@ def start_calculating():
|
||||
logger.critical(f"Ошибка в ивенте {i['name']}. Разница в длинах variants, consequence "
|
||||
f"и probability_consequence")
|
||||
quit(0)
|
||||
logger.info("Валидация игры успешно прошла")
|
||||
logger.debug("Валидация игры успешно прошла")
|
||||
|
||||
Reference in New Issue
Block a user