From 45ec9a11575ad2ec3b87ccae0e418d538469011b Mon Sep 17 00:00:00 2001 From: justuser31 Date: Sat, 4 May 2024 13:18:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B3,=20=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BC=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reworked/calc.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/reworked/calc.py b/reworked/calc.py index 8d47e93..2b5f23b 100644 --- a/reworked/calc.py +++ b/reworked/calc.py @@ -1,6 +1,8 @@ -global expanded ; expanded = {} +global expanded def expand_recipe(recipe, recipes, main = False): global expanded + if main: + expanded = {} ok = False part = 1 # Одна часть @@ -34,19 +36,15 @@ def expand_recipe(recipe, recipes, main = False): def calc(element, amount, recipes): # Получаем характеристику элемента - recipe, out = recipes[element].comps, recipes[element].out + recipe, vol_out = recipes[element].comps, recipes[element].out # Расчитываем минимальный рецепт - expanded, vol, part = expand_recipe(recipe, recipes, True) + expanded, vol_in, part = expand_recipe(recipe, recipes, True) - # Домнажаем на сколько нужно - need = amount//vol + need = amount//vol_in for i in expanded: expanded[i] = expanded[i]*need - out = part*out*need - - return expanded, out + vol_in *= need + vol_out *= part*need + return expanded, vol_in, vol_out -from parse import * -#print( load_recipes() ) -print( calc('Leporazine', 100, load_recipes()) )