|
|
@ -51,7 +51,7 @@ FOOD_LOCALISATION_URL = "https://github.com/SerbiaStrong-220/space-station-14/ra
|
|
|
|
class Reagent:
|
|
|
|
class Reagent:
|
|
|
|
def __init__(self, init_data: dict):
|
|
|
|
def __init__(self, init_data: dict):
|
|
|
|
self.__name: str = init_data.get("name")
|
|
|
|
self.__name: str = init_data.get("name")
|
|
|
|
self.__desc: str = init_data.get("desc")
|
|
|
|
# self.__desc: str = init_data.get("desc")
|
|
|
|
self.__recipe: dict = init_data.get("reactants")
|
|
|
|
self.__recipe: dict = init_data.get("reactants")
|
|
|
|
self.__product = init_data.get("products")
|
|
|
|
self.__product = init_data.get("products")
|
|
|
|
# raw значения которые обработаны
|
|
|
|
# raw значения которые обработаны
|
|
|
@ -69,13 +69,20 @@ class Reagent:
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def recipe(self):
|
|
|
|
def recipe(self):
|
|
|
|
result = []
|
|
|
|
result = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Добавляем количество в итоге
|
|
|
|
|
|
|
|
react_res = self.__product
|
|
|
|
|
|
|
|
for i in react_res:
|
|
|
|
|
|
|
|
result.append(react_res[i])
|
|
|
|
|
|
|
|
|
|
|
|
if not self.__recipe:
|
|
|
|
if not self.__recipe:
|
|
|
|
return None #return result #[False, "", 0]
|
|
|
|
return None #return result #[False, "", 0]
|
|
|
|
for item in self.__recipe:
|
|
|
|
for item in self.__recipe:
|
|
|
|
# Приводим к НОРМАЛЬНОМУ виду
|
|
|
|
# "Бикаридин": [ [0, "Углерод", 1], [1, "Инапровалин", 1] ]
|
|
|
|
# "Бикаридин": [ [0, "Углерод", 1], [1, "Инапровалин"] ]
|
|
|
|
#result.append([self.__recipe[item]["reagent"], localise(item).capitalize(), self.__recipe[item]["amount"]])
|
|
|
|
print(self.__recipe)
|
|
|
|
# "Бикаридин": [ 2, ["Углерод", 1], ["Инапровалин", 1] ]
|
|
|
|
result.append([self.__recipe[item]["reagent"], localise(item).capitalize(), self.__recipe[item]["amount"]])
|
|
|
|
result.append([localise(item).capitalize(), self.__recipe[item]['amount']])
|
|
|
|
|
|
|
|
#print(result)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -117,6 +124,11 @@ def localise(key: str) -> str:
|
|
|
|
# Показатель прогресса
|
|
|
|
# Показатель прогресса
|
|
|
|
from tqdm import tqdm
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Загрузить локализацию если нету файла
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
if not os.path.exists('locale.json'):
|
|
|
|
|
|
|
|
load_localisation()
|
|
|
|
|
|
|
|
|
|
|
|
content = {}
|
|
|
|
content = {}
|
|
|
|
|
|
|
|
|
|
|
|
def yml_load(url):
|
|
|
|
def yml_load(url):
|
|
|
@ -134,12 +146,12 @@ for item in tqdm(yml_load(RECIPES_URL), desc='recipies'):
|
|
|
|
element: {"amount": item["reactants"][element]["amount"], "reagent": element in content} for element in
|
|
|
|
element: {"amount": item["reactants"][element]["amount"], "reagent": element in content} for element in
|
|
|
|
item["reactants"]}
|
|
|
|
item["reactants"]}
|
|
|
|
content[item["id"]]["products"] = item["products"]
|
|
|
|
content[item["id"]]["products"] = item["products"]
|
|
|
|
|
|
|
|
# print(item["products"])
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Включать ли токсины без крафта? (некоторые имеют крафт)
|
|
|
|
# TODO: Включать ли токсины без крафта? (некоторые имеют крафт)
|
|
|
|
reagents = [Reagent(init_data=content[item]) for item in content if "reactants" in content[item]]
|
|
|
|
reagents = [Reagent(init_data=content[item]) for item in content if "reactants" in content[item]]
|
|
|
|
|
|
|
|
|
|
|
|
db = {x.name: x.recipe for x in reagents}
|
|
|
|
db = {x.name: x.recipe for x in reagents}
|
|
|
|
#with open("db.json", mode="w", encoding="utf-8") as db_file:
|
|
|
|
|
|
|
|
# json.dump(db, db_file, ensure_ascii=False, indent=2)
|
|
|
|
|
|
|
|
from db import *
|
|
|
|
from db import *
|
|
|
|
write_db(db)
|
|
|
|
write_db(db)
|
|
|
|