|
|
@ -1,10 +1,12 @@
|
|
|
|
def expand_recipe(recipe, recipes):
|
|
|
|
global expanded ; expanded = {}
|
|
|
|
|
|
|
|
def expand_recipe(recipe, recipes, main = False):
|
|
|
|
global expanded
|
|
|
|
global expanded
|
|
|
|
|
|
|
|
|
|
|
|
ok = False
|
|
|
|
ok = False
|
|
|
|
part = 1 # Одна часть
|
|
|
|
part = 1 # Одна часть
|
|
|
|
while not ok:
|
|
|
|
while not ok:
|
|
|
|
ok = True
|
|
|
|
ok = True
|
|
|
|
|
|
|
|
min_vol = 0 # Объём мин. рецепта (вход)
|
|
|
|
# Перебираем элементы
|
|
|
|
# Перебираем элементы
|
|
|
|
for el in recipe:
|
|
|
|
for el in recipe:
|
|
|
|
# Если составное
|
|
|
|
# Если составное
|
|
|
@ -16,24 +18,35 @@ def expand_recipe(recipe, recipes):
|
|
|
|
expanded = {}
|
|
|
|
expanded = {}
|
|
|
|
break
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
expand_recipe(recipes[el].comps, recipes)
|
|
|
|
min_vol += expand_recipe(recipes[el].comps, recipes)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if el in expanded:
|
|
|
|
if el in expanded:
|
|
|
|
expanded[el] += recipe[el]*part
|
|
|
|
expanded[el] += recipe[el]*part
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
expanded[el] = recipe[el]*part
|
|
|
|
expanded[el] = recipe[el]*part
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_vol += recipe[el]*part
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if main:
|
|
|
|
|
|
|
|
return expanded, min_vol, part
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return min_vol
|
|
|
|
|
|
|
|
|
|
|
|
def calc(element, amount, recipes):
|
|
|
|
def calc(element, amount, recipes):
|
|
|
|
# TODO: Пока только выводит расширенную версию рецепта
|
|
|
|
# Получаем характеристику элемента
|
|
|
|
recipe, out = recipes[element].comps, recipes[element].out
|
|
|
|
recipe, out = recipes[element].comps, recipes[element].out
|
|
|
|
|
|
|
|
# Расчитываем минимальный рецепт
|
|
|
|
|
|
|
|
expanded, vol, part = expand_recipe(recipe, recipes, True)
|
|
|
|
|
|
|
|
|
|
|
|
global expanded
|
|
|
|
# Домнажаем на сколько нужно
|
|
|
|
expanded = {}
|
|
|
|
need = amount//vol
|
|
|
|
expand_recipe(recipe, recipes)
|
|
|
|
for i in expanded:
|
|
|
|
|
|
|
|
expanded[i] = expanded[i]*need
|
|
|
|
|
|
|
|
out = part*out*need
|
|
|
|
|
|
|
|
|
|
|
|
return expanded
|
|
|
|
return expanded, out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from parse import *
|
|
|
|
from parse import *
|
|
|
|
#print( load_recipes() )
|
|
|
|
#print( load_recipes() )
|
|
|
|
print( calc('Dylovene', 100, load_recipes()) )
|
|
|
|
print( calc('Leporazine', 100, load_recipes()) )
|
|
|
|