mirror of
https://github.com/Justuser3310/ss14_chemistry_site.git
synced 2025-02-08 09:07:38 +00:00
Compare commits
No commits in common. "22b2a0ec27b1ff5d95fb8885adc6823f50790ad0" and "609c21245fc89a4d454315923cd04b73693405ed" have entirely different histories.
22b2a0ec27
...
609c21245f
@ -1,39 +0,0 @@
|
|||||||
def expand_recipe(recipe, recipes):
|
|
||||||
global expanded
|
|
||||||
|
|
||||||
ok = False
|
|
||||||
part = 1 # Одна часть
|
|
||||||
while not ok:
|
|
||||||
ok = True
|
|
||||||
# Перебираем элементы
|
|
||||||
for el in recipe:
|
|
||||||
# Если составное
|
|
||||||
if el in recipes:
|
|
||||||
# Одна часть должна делиться без остатка!
|
|
||||||
if part % recipes[el].out != 0:
|
|
||||||
ok = False
|
|
||||||
part += 1
|
|
||||||
expanded = {}
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
expand_recipe(recipes[el].comps, recipes)
|
|
||||||
else:
|
|
||||||
if el in expanded:
|
|
||||||
expanded[el] += recipe[el]*part
|
|
||||||
else:
|
|
||||||
expanded[el] = recipe[el]*part
|
|
||||||
|
|
||||||
def calc(element, amount, recipes):
|
|
||||||
# TODO: Пока только выводит расширенную версию рецепта
|
|
||||||
recipe, out = recipes[element].comps, recipes[element].out
|
|
||||||
|
|
||||||
global expanded
|
|
||||||
expanded = {}
|
|
||||||
expand_recipe(recipe, recipes)
|
|
||||||
|
|
||||||
return expanded
|
|
||||||
|
|
||||||
|
|
||||||
from parse import *
|
|
||||||
#print( load_recipes() )
|
|
||||||
print( calc('Dylovene', 100, load_recipes()) )
|
|
Loading…
Reference in New Issue
Block a user