Skip to content

Commit

Permalink
1.3.2 fixed total output and input
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomansion committed Oct 25, 2022
1 parent 3f10cad commit b87f0ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions factorio_blueprint_analyser/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(self, bp_json):
self.blueprint = bp_json
utils.warning(f"Blueprint book detected, using first blueprint")


if "blueprint" not in bp_json:
raise Exception("Invalid blueprint, no 'blueprint' key found")

Expand Down Expand Up @@ -322,13 +321,23 @@ def get_analysis(self):

# Blueprint related information
# Adding the total in and out flow
items_input = []
items_input = {}
for root_node in self.network.root_nodes():
items_input.append(root_node.flow.items)
items = root_node.flow.items
for item in items:
if item in items_input:
items_input[item] += items[item]
else:
items_input[item] = items[item]

items_output = []
items_output = {}
for leaf_node in self.network.leaf_nodes():
items_output.append(leaf_node.flow.items)
items = leaf_node.flow.items
for item in items:
if item in items_output:
items_output[item] += items[item]
else:
items_output[item] = items[item]

analysed_bp["blueprint"]["items_input"] = items_input
analysed_bp["blueprint"]["items_output"] = items_output
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='factorioBlueprintAnalyser',
version='1.3.1',
version='1.3.2',
description="A python library analyse Factorio Blueprints and find bottlenecks.",
url="https://github.com/tomansion/factorio_blueprint_analyser_app/",
author="Tom Mansion",
Expand Down

0 comments on commit b87f0ca

Please sign in to comment.