diff --git a/plan.py b/plan.py index 998d15b..d9b516e 100755 --- a/plan.py +++ b/plan.py @@ -37,14 +37,14 @@ def calculate_rates(recipes, remain): return required_items -def basic_rate(recipes, name: str): - return fractions.Fraction( - target_recipe['output'][target_name], - target_recipe['crafting_time'] - ) +def basic_rate(recipe): + for output, count in recipe['output'].items(): + return fractions.Fraction( + count, recipe['crafting_time'] + ) -if __name__ == '__main__': +def main(): recipes = satisfactory.Cookbook('data/recipes') required_items = collections.defaultdict(fractions.Fraction) @@ -56,7 +56,7 @@ if __name__ == '__main__': target = recipes[target_name] target_recipe = target['recipes'][0] - remain = [{n: basic_rate(recipes, n) for n in targets}] + remain = [{n: basic_rate(recipes[n]['recipes'][0]) for n in targets}] required_items = calculate_rates(recipes, remain) for name, rate in required_items.items(): @@ -92,3 +92,7 @@ if __name__ == '__main__': print(required_power) print(math.ceil(required_power / 150), "fuel generators") + + +if __name__ == '__main__': + main()