починил авторизацию, ускорил систему с помощью сервера, сделал спрайты по правильному
This commit is contained in:
+8
-30
@@ -1,44 +1,22 @@
|
||||
from modules.DB import UseDB
|
||||
from loguru import logger
|
||||
import random
|
||||
import configparser
|
||||
import requests
|
||||
|
||||
|
||||
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])
|
||||
return db.find_document({"_id": random_event[0]})[0]
|
||||
response = requests.get("http://194.61.1.147:52540/get_random_event")
|
||||
return response.json()
|
||||
|
||||
|
||||
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']
|
||||
db = UseDB("events")
|
||||
not_well_events = db.find_document({"well": False})
|
||||
well_events = db.find_document({"well": True})
|
||||
if well:
|
||||
for i in not_well_events:
|
||||
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:
|
||||
for i in well_events:
|
||||
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})
|
||||
requests.get("http://194.61.1.147:52540/recalculation_events",
|
||||
params={
|
||||
"well": well,
|
||||
"difficulty": config['Settings']['difficulty']
|
||||
})
|
||||
|
||||
|
||||
def start_calculating():
|
||||
|
||||
Reference in New Issue
Block a user