plan: move the primary functionality into a function
This prevents reliance on global variables
This commit is contained in:
parent
6a82305479
commit
9e2d8dba8a
14
plan.py
14
plan.py
@ -37,14 +37,14 @@ def calculate_rates(recipes, remain):
|
||||
return required_items
|
||||
|
||||
|
||||
def basic_rate(recipes, name: str):
|
||||
def basic_rate(recipe):
|
||||
for output, count in recipe['output'].items():
|
||||
return fractions.Fraction(
|
||||
target_recipe['output'][target_name],
|
||||
target_recipe['crafting_time']
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user