mirror of
https://github.com/Justuser3310/ss14_chemistry_site.git
synced 2025-02-08 09:07:38 +00:00
Табы, новый вид: 'Бикаридин': [2,[Углерод,1],[Инапровалин,1]]
This commit is contained in:
parent
f1394117a9
commit
71e293a550
64
update_db.py
64
update_db.py
@ -49,34 +49,41 @@ 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 значения которые обработаны
|
||||||
|
|
||||||
self.heat: bool = init_data.get("heat")
|
self.heat: bool = init_data.get("heat")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return localise(self.__name).capitalize()
|
return localise(self.__name).capitalize()
|
||||||
|
|
||||||
# @property
|
# @property
|
||||||
# def description(self):
|
# def description(self):
|
||||||
# return localise(self.__desc)
|
# return localise(self.__desc)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recipe(self):
|
def recipe(self):
|
||||||
result = []
|
result = []
|
||||||
if not self.__recipe:
|
|
||||||
return None #return result #[False, "", 0]
|
# Добавляем количество в итоге
|
||||||
for item in self.__recipe:
|
react_res = self.__product
|
||||||
# Приводим к НОРМАЛЬНОМУ виду
|
for i in react_res:
|
||||||
# "Бикаридин": [ [0, "Углерод", 1], [1, "Инапровалин"] ]
|
result.append(react_res[i])
|
||||||
print(self.__recipe)
|
|
||||||
result.append([self.__recipe[item]["reagent"], localise(item).capitalize(), self.__recipe[item]["amount"]])
|
if not self.__recipe:
|
||||||
return result
|
return None #return result #[False, "", 0]
|
||||||
|
for item in self.__recipe:
|
||||||
|
# "Бикаридин": [ [0, "Углерод", 1], [1, "Инапровалин", 1] ]
|
||||||
|
#result.append([self.__recipe[item]["reagent"], localise(item).capitalize(), self.__recipe[item]["amount"]])
|
||||||
|
# "Бикаридин": [ 2, ["Углерод", 1], ["Инапровалин", 1] ]
|
||||||
|
result.append([localise(item).capitalize(), self.__recipe[item]['amount']])
|
||||||
|
#print(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def load_localisation():
|
def load_localisation():
|
||||||
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user