From 79df7638a8c40ba81b971ed70951b0240c799b75 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 28 Apr 2019 09:22:41 +1000 Subject: [PATCH] recipes: add subtype indicator for each recipe --- data/recipes/components/ai_limiter.json | 1 + data/recipes/components/cable.json | 1 + data/recipes/components/caterium_ingot.json | 1 + data/recipes/components/circuit_board.json | 1 + data/recipes/components/computer.json | 1 + data/recipes/components/concrete.json | 1 + data/recipes/components/copper_ingot.json | 1 + .../components/encased_industrial_beam.json | 1 + .../recipes/components/heavy_modular_frame.json | 1 + .../components/high_speed_connector.json | 1 + data/recipes/components/iron_ingot.json | 1 + data/recipes/components/iron_plate.json | 1 + data/recipes/components/iron_rod.json | 1 + data/recipes/components/modular_frame.json | 1 + data/recipes/components/motor.json | 1 + data/recipes/components/plastic.json | 1 + data/recipes/components/quickwire.json | 1 + .../components/reinforced_iron_plate.json | 1 + data/recipes/components/rotor.json | 1 + data/recipes/components/rubber.json | 1 + data/recipes/components/screw.json | 1 + data/recipes/components/stator.json | 1 + data/recipes/components/steel_beam.json | 1 + data/recipes/components/steel_ingot.json | 1 + data/recipes/components/steel_pipe.json | 1 + data/recipes/components/supercomputer.json | 1 + data/recipes/components/wire.json | 1 + data/recipes/machine/assembler.json | 1 + data/recipes/machine/constructor.json | 1 + data/recipes/machine/manufacturer.json | 1 + data/recipes/machine/miner_mk1.json | 1 + data/recipes/machine/oil_pump.json | 1 + data/recipes/machine/portable_miner.json | 1 + data/recipes/machine/smelter.json | 1 + data/recipes/machine/space_elevator.json | 1 + data/recipes/resources/caterium_ore.json | 1 + data/recipes/resources/coal.json | 1 + data/recipes/resources/copper_ore.json | 1 + data/recipes/resources/crude_oil.json | 1 + data/recipes/resources/iron_ore.json | 1 + data/recipes/resources/limestone.json | 1 + graph.py | 17 ++++++++++++++++- 42 files changed, 57 insertions(+), 1 deletion(-) diff --git a/data/recipes/components/ai_limiter.json b/data/recipes/components/ai_limiter.json index 21036d1..5f81e7c 100644 --- a/data/recipes/components/ai_limiter.json +++ b/data/recipes/components/ai_limiter.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "circuit_board": 1, "quickwire": 18 }, "output": { "ai_limiter": 1 }, "machine": "assembler", diff --git a/data/recipes/components/cable.json b/data/recipes/components/cable.json index 56f7a1a..8f4160c 100644 --- a/data/recipes/components/cable.json +++ b/data/recipes/components/cable.json @@ -1,5 +1,6 @@ [ { + "type": [ "component", "item" ], "input": { "wire": 2 }, "output": { "cable": 1 }, "machine": "constructor", diff --git a/data/recipes/components/caterium_ingot.json b/data/recipes/components/caterium_ingot.json index 26cef6a..21a83ae 100644 --- a/data/recipes/components/caterium_ingot.json +++ b/data/recipes/components/caterium_ingot.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "caterium_ore": 4 }, "output": { "caterium_ingot": 1 }, "machine": "smelter", diff --git a/data/recipes/components/circuit_board.json b/data/recipes/components/circuit_board.json index fe5adb1..72c57ca 100644 --- a/data/recipes/components/circuit_board.json +++ b/data/recipes/components/circuit_board.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "wire": 12, "plastic": 6 }, "output": { "circuit_board": 1 }, "machine": "assembler", diff --git a/data/recipes/components/computer.json b/data/recipes/components/computer.json index ba03443..0ce63ce 100644 --- a/data/recipes/components/computer.json +++ b/data/recipes/components/computer.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "circuit_board": 5, "cable": 12, "plastic": 18, "screw": 60 }, "output": { "computer": 1 }, "machine": "manufacturer", diff --git a/data/recipes/components/concrete.json b/data/recipes/components/concrete.json index a47b98f..2e19a29 100644 --- a/data/recipes/components/concrete.json +++ b/data/recipes/components/concrete.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "limestone": 3 }, "output": { "concrete": 1 }, "machine": "constructor", diff --git a/data/recipes/components/copper_ingot.json b/data/recipes/components/copper_ingot.json index 121e1a3..87f7bad 100644 --- a/data/recipes/components/copper_ingot.json +++ b/data/recipes/components/copper_ingot.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "copper_ore": 1 }, "output": { "copper_ingot": 1 }, "machine": "smelter", diff --git a/data/recipes/components/encased_industrial_beam.json b/data/recipes/components/encased_industrial_beam.json index e03c8ae..199b5a5 100644 --- a/data/recipes/components/encased_industrial_beam.json +++ b/data/recipes/components/encased_industrial_beam.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "steel_beam": 4, "concrete": 5 }, "output": { "encased_industrial_beam": 1 }, "machine": "assembler", diff --git a/data/recipes/components/heavy_modular_frame.json b/data/recipes/components/heavy_modular_frame.json index 8cc789c..1d0990a 100644 --- a/data/recipes/components/heavy_modular_frame.json +++ b/data/recipes/components/heavy_modular_frame.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "modular_frame": 5, "steel_pipe": 15, "encased_industrial_beam": 5, "screw": 90 }, "output": { "heavy_modular_frame": 1 }, "machine": "assembler", diff --git a/data/recipes/components/high_speed_connector.json b/data/recipes/components/high_speed_connector.json index 193d35f..cf62d55 100644 --- a/data/recipes/components/high_speed_connector.json +++ b/data/recipes/components/high_speed_connector.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "quickwire": 40, "cable": 10, "plastic": 6 }, "output": { "high_speed_connector": 1 }, "machine": "manufacturer", diff --git a/data/recipes/components/iron_ingot.json b/data/recipes/components/iron_ingot.json index 61d747d..bbb7bd3 100644 --- a/data/recipes/components/iron_ingot.json +++ b/data/recipes/components/iron_ingot.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_ore": 1 }, "output": { "iron_ingot": 1 }, "machine": "smelter", diff --git a/data/recipes/components/iron_plate.json b/data/recipes/components/iron_plate.json index 597a914..9344b92 100644 --- a/data/recipes/components/iron_plate.json +++ b/data/recipes/components/iron_plate.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_ingot": 2 }, "output": { "iron_plate": 1 }, "crafting_time": 4, diff --git a/data/recipes/components/iron_rod.json b/data/recipes/components/iron_rod.json index e5b2119..4d6c213 100644 --- a/data/recipes/components/iron_rod.json +++ b/data/recipes/components/iron_rod.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_ingot": 1 }, "output": { "iron_rod": 1 }, "machine": "constructor", diff --git a/data/recipes/components/modular_frame.json b/data/recipes/components/modular_frame.json index 85f47f6..50e83b5 100644 --- a/data/recipes/components/modular_frame.json +++ b/data/recipes/components/modular_frame.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "reinforced_iron_plate": 3, "iron_rod": 3 }, "output": { "modular_frame": 1 }, "machine": "assembler", diff --git a/data/recipes/components/motor.json b/data/recipes/components/motor.json index 3aa15fa..3d611fb 100644 --- a/data/recipes/components/motor.json +++ b/data/recipes/components/motor.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "rotor": 2, "stator": 2 }, "output": { "motor": 1 }, "machine": "assembler", diff --git a/data/recipes/components/plastic.json b/data/recipes/components/plastic.json index 2a0e62d..7e910bb 100644 --- a/data/recipes/components/plastic.json +++ b/data/recipes/components/plastic.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "crude_oil": 4 }, "output": { "plastic": 3 }, "machine": "oil_refinery", diff --git a/data/recipes/components/quickwire.json b/data/recipes/components/quickwire.json index dc56f42..cc35c81 100644 --- a/data/recipes/components/quickwire.json +++ b/data/recipes/components/quickwire.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "caterium_ingot": 1 }, "output": { "quickwire": 4 }, "machine": "constructor", diff --git a/data/recipes/components/reinforced_iron_plate.json b/data/recipes/components/reinforced_iron_plate.json index f7708da..89bd259 100644 --- a/data/recipes/components/reinforced_iron_plate.json +++ b/data/recipes/components/reinforced_iron_plate.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_plate": 4, "screw": 24 }, "output": { "reinforced_iron_plate": 1 }, "machine": "assembler", diff --git a/data/recipes/components/rotor.json b/data/recipes/components/rotor.json index 7ca836a..0438577 100644 --- a/data/recipes/components/rotor.json +++ b/data/recipes/components/rotor.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_rod": 3, "screw": 22 }, "output": { "rotor": 1 }, "machine": "smelter", diff --git a/data/recipes/components/rubber.json b/data/recipes/components/rubber.json index 1916887..be70363 100644 --- a/data/recipes/components/rubber.json +++ b/data/recipes/components/rubber.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "crude_oil": 4 }, "output": { "rubber": 4 }, "machine": "oil_refinery", diff --git a/data/recipes/components/screw.json b/data/recipes/components/screw.json index 49a1d72..3991a1c 100644 --- a/data/recipes/components/screw.json +++ b/data/recipes/components/screw.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_rod": 1 }, "output": { "screw": 6 }, "machine": "constructor", diff --git a/data/recipes/components/stator.json b/data/recipes/components/stator.json index 0108c6a..c0ff801 100644 --- a/data/recipes/components/stator.json +++ b/data/recipes/components/stator.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "steel_pipe": 3, "wire": 10 }, "output": { "stator": 1 }, "machine": "assembler", diff --git a/data/recipes/components/steel_beam.json b/data/recipes/components/steel_beam.json index 551e9e4..49060de 100644 --- a/data/recipes/components/steel_beam.json +++ b/data/recipes/components/steel_beam.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "steel_ingot": 3 }, "output": { "steel_beam": 1 }, "machine": "constructor", diff --git a/data/recipes/components/steel_ingot.json b/data/recipes/components/steel_ingot.json index 6304a60..f80bef2 100644 --- a/data/recipes/components/steel_ingot.json +++ b/data/recipes/components/steel_ingot.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "iron_ore": 3, "coal": 3 }, "output": { "steel_ingot": 2 }, "machine": "foundry", diff --git a/data/recipes/components/steel_pipe.json b/data/recipes/components/steel_pipe.json index 58aabc7..e65d2ee 100644 --- a/data/recipes/components/steel_pipe.json +++ b/data/recipes/components/steel_pipe.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "steel_ingot": 1 }, "output": { "steel_pipe": 1 }, "machine": "constructor", diff --git a/data/recipes/components/supercomputer.json b/data/recipes/components/supercomputer.json index 8e7dff4..005ff57 100644 --- a/data/recipes/components/supercomputer.json +++ b/data/recipes/components/supercomputer.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "computer": 2, "ai_limiter": 2, "high_speed_connector": 3, "plastic": 21 }, "output": { "supercomputer": 1 }, "machine": "manufacturer", diff --git a/data/recipes/components/wire.json b/data/recipes/components/wire.json index 9f410b6..a1ec41b 100644 --- a/data/recipes/components/wire.json +++ b/data/recipes/components/wire.json @@ -1,5 +1,6 @@ [ { + "type": [ "component" ], "input": { "copper_ingot": 1 }, "output": { "wire": 3 }, "machine": "constructor", diff --git a/data/recipes/machine/assembler.json b/data/recipes/machine/assembler.json index 304ec93..b2c2125 100644 --- a/data/recipes/machine/assembler.json +++ b/data/recipes/machine/assembler.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "modular_frame": 3, "rotor": 4, "cable": 10 }, "output": { "assembler": 1 }, "machine": "_craft_bench", diff --git a/data/recipes/machine/constructor.json b/data/recipes/machine/constructor.json index 98b512f..31efb9b 100644 --- a/data/recipes/machine/constructor.json +++ b/data/recipes/machine/constructor.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "reinforced_iron_plate": 3, "cable": 2 }, "output": { "constructor": 1 }, "machine": "_craft_bench", diff --git a/data/recipes/machine/manufacturer.json b/data/recipes/machine/manufacturer.json index cc3c239..e2aeb9f 100644 --- a/data/recipes/machine/manufacturer.json +++ b/data/recipes/machine/manufacturer.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "heavy_modular_frame": 2, "motor": 2, "cable": 25, "computer": 3 }, "output": { "manufacturer": 1 }, "machine": "_craft_bench", diff --git a/data/recipes/machine/miner_mk1.json b/data/recipes/machine/miner_mk1.json index e5d0226..7603ab6 100644 --- a/data/recipes/machine/miner_mk1.json +++ b/data/recipes/machine/miner_mk1.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "portable_miner": 1, "iron_rod": 5, "concrete": 5 }, "output": { "miner_mk1": 1 }, "is": "miner", diff --git a/data/recipes/machine/oil_pump.json b/data/recipes/machine/oil_pump.json index 4542953..f71f999 100644 --- a/data/recipes/machine/oil_pump.json +++ b/data/recipes/machine/oil_pump.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "heavy_modular_frame": 2, "motor": 3, "cable": 10 }, "output": { "oil_pump": 1 }, "machine": "_craft_bench", diff --git a/data/recipes/machine/portable_miner.json b/data/recipes/machine/portable_miner.json index f6a5ff0..43afd52 100644 --- a/data/recipes/machine/portable_miner.json +++ b/data/recipes/machine/portable_miner.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine", "item" ], "input": { "iron_plate": 4, "wire": 8, "cable": 4 }, "output": { "portable_miner": 1 }, "machine": "equipment_workshop", diff --git a/data/recipes/machine/smelter.json b/data/recipes/machine/smelter.json index 0ec948a..f75ab7b 100644 --- a/data/recipes/machine/smelter.json +++ b/data/recipes/machine/smelter.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "iron_rod": 5, "wire": 8 }, "output": { "smelter": 1 }, "machine": "_craft_bench", diff --git a/data/recipes/machine/space_elevator.json b/data/recipes/machine/space_elevator.json index e2c2658..a5cd54c 100644 --- a/data/recipes/machine/space_elevator.json +++ b/data/recipes/machine/space_elevator.json @@ -1,5 +1,6 @@ [ { + "type": [ "machine" ], "input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 }, "output": { "space_elevator": 1 }, "machine": "_placement", diff --git a/data/recipes/resources/caterium_ore.json b/data/recipes/resources/caterium_ore.json index 2451501..3b08a6a 100644 --- a/data/recipes/resources/caterium_ore.json +++ b/data/recipes/resources/caterium_ore.json @@ -1,5 +1,6 @@ [ { + "type": [ "resource" ], "input": { }, "output": { "caterium_ore": 1 }, "machine": "miner" diff --git a/data/recipes/resources/coal.json b/data/recipes/resources/coal.json index ae606c9..e501005 100644 --- a/data/recipes/resources/coal.json +++ b/data/recipes/resources/coal.json @@ -1,5 +1,6 @@ [ { + "type": [ "resource" ], "input": { }, "output": { "coal": 1 }, "machine": "miner" diff --git a/data/recipes/resources/copper_ore.json b/data/recipes/resources/copper_ore.json index b8c58ca..4202593 100644 --- a/data/recipes/resources/copper_ore.json +++ b/data/recipes/resources/copper_ore.json @@ -1,5 +1,6 @@ [ { + "type": [ "resource" ], "input": { }, "output": { "copper_ore": 1 }, "machine": "miner" diff --git a/data/recipes/resources/crude_oil.json b/data/recipes/resources/crude_oil.json index 264c665..998f271 100644 --- a/data/recipes/resources/crude_oil.json +++ b/data/recipes/resources/crude_oil.json @@ -1,5 +1,6 @@ [ { + "type": [ "resource" ], "input": { }, "output": { "crude_oil": 1 }, "machine": "oil_pump" diff --git a/data/recipes/resources/iron_ore.json b/data/recipes/resources/iron_ore.json index 982d91b..38f039a 100644 --- a/data/recipes/resources/iron_ore.json +++ b/data/recipes/resources/iron_ore.json @@ -1,5 +1,6 @@ [ { + "type": [ "resource" ], "input": { }, "output": { "iron_ore": 1 }, "machine": "miner" diff --git a/data/recipes/resources/limestone.json b/data/recipes/resources/limestone.json index aa2fe5b..de5109a 100644 --- a/data/recipes/resources/limestone.json +++ b/data/recipes/resources/limestone.json @@ -1,5 +1,6 @@ [ { + "type": [ "resource" ], "input": { }, "output": { "limestone": 1 }, "machine": "miner", diff --git a/graph.py b/graph.py index 5595ec4..90cc77d 100755 --- a/graph.py +++ b/graph.py @@ -26,6 +26,21 @@ class Cookbook(object): def all(self): return self.recipes.keys() + def is_component(self, name): + return 'component' in self.recipes[name]['type'] + + def components(self): + found = set() + + for target, methods in self.recipes.items(): + for variation in methods: + for need, _ in variation['input'].items(): + if need in found: + continue + found.add(need) + if not self.is_component(need): + continue + yield need def graph(recipes: dict, targets: Iterable[str]): print("digraph G {") @@ -71,6 +86,6 @@ if __name__ == '__main__': if args.target: graph_one(recipes, args.target) else: - graph_all(recipes) + graph(recipes, recipes.components()) main()