From 14fe028fe1740fc62003fe3a4fbb8985cdaa6b25 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 28 Apr 2019 11:03:27 +1000 Subject: [PATCH] recipes: pull type and machine variables out of the recipe list --- data/recipes/components/ai_limiter.json | 33 +++++++++----- data/recipes/components/cable.json | 29 +++++++----- data/recipes/components/caterium_ingot.json | 30 ++++++++----- data/recipes/components/circuit_board.json | 33 +++++++++----- data/recipes/components/computer.json | 35 ++++++++++----- data/recipes/components/concrete.json | 30 ++++++++----- data/recipes/components/copper_ingot.json | 32 ++++++++----- .../components/encased_industrial_beam.json | 33 +++++++++----- .../components/heavy_modular_frame.json | 35 ++++++++++----- .../components/high_speed_connector.json | 34 +++++++++----- data/recipes/components/iron_ingot.json | 28 +++++++----- data/recipes/components/iron_plate.json | 26 +++++++---- data/recipes/components/iron_rod.json | 28 +++++++----- data/recipes/components/modular_frame.json | 33 +++++++++----- data/recipes/components/motor.json | 29 +++++++----- data/recipes/components/plastic.json | 32 ++++++++----- data/recipes/components/quickwire.json | 32 ++++++++----- .../components/reinforced_iron_plate.json | 31 ++++++++----- data/recipes/components/rotor.json | 33 +++++++++----- data/recipes/components/rubber.json | 32 ++++++++----- data/recipes/components/screw.json | 30 ++++++++----- data/recipes/components/stator.json | 29 +++++++----- data/recipes/components/steel_beam.json | 30 ++++++++----- data/recipes/components/steel_ingot.json | 33 +++++++++----- data/recipes/components/steel_pipe.json | 32 ++++++++----- data/recipes/components/supercomputer.json | 35 ++++++++++----- data/recipes/components/wire.json | 32 ++++++++----- data/recipes/machine/assembler.json | 34 +++++++++----- data/recipes/machine/constructor.json | 35 ++++++++++----- data/recipes/machine/manufacturer.json | 35 ++++++++++----- data/recipes/machine/miner_mk1.json | 38 +++++++++++----- data/recipes/machine/oil_pump.json | 34 +++++++++----- data/recipes/machine/portable_miner.json | 29 ++++++++---- data/recipes/machine/smelter.json | 29 +++++++----- data/recipes/machine/space_elevator.json | 25 ++++++----- data/recipes/resources/caterium_ore.json | 19 ++++---- data/recipes/resources/coal.json | 19 ++++---- data/recipes/resources/copper_ore.json | 22 +++++---- data/recipes/resources/crude_oil.json | 19 ++++---- data/recipes/resources/iron_ore.json | 19 ++++---- data/recipes/resources/limestone.json | 24 ++++++---- describe.py | 25 ++--------- graph.py | 45 +++---------------- satisfactory/__init__.py | 44 ++++++++++++++++++ 44 files changed, 844 insertions(+), 500 deletions(-) create mode 100644 satisfactory/__init__.py diff --git a/data/recipes/components/ai_limiter.json b/data/recipes/components/ai_limiter.json index 5f81e7c..f2d44b0 100644 --- a/data/recipes/components/ai_limiter.json +++ b/data/recipes/components/ai_limiter.json @@ -1,12 +1,21 @@ -[ - { - "type": [ "component" ], - "input": { "circuit_board": 1, "quickwire": 18 }, - "output": { "ai_limiter": 1 }, - "machine": "assembler", - "crafting_time": 12, - "clicks": 3, - "stack_size": 100, - "requires": "caterium_electronics" - } -] +{ + "type": [ + "component" + ], + "machine": "assembler", + "recipes": [ + { + "input": { + "circuit_board": 1, + "quickwire": 18 + }, + "output": { + "ai_limiter": 1 + }, + "crafting_time": 12, + "clicks": 3, + "stack_size": 100, + "requires": "caterium_electronics" + } + ] +} diff --git a/data/recipes/components/cable.json b/data/recipes/components/cable.json index 8f4160c..83ab315 100644 --- a/data/recipes/components/cable.json +++ b/data/recipes/components/cable.json @@ -1,10 +1,19 @@ -[ - { - "type": [ "component", "item" ], - "input": { "wire": 2 }, - "output": { "cable": 1 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 1 - } -] +{ + "type": [ + "component", + "item" + ], + "machine": "constructor", + "recipes": [ + { + "input": { + "wire": 2 + }, + "output": { + "cable": 1 + }, + "crafting_time": 4, + "clicks": 1 + } + ] +} diff --git a/data/recipes/components/caterium_ingot.json b/data/recipes/components/caterium_ingot.json index 21a83ae..0fc61c7 100644 --- a/data/recipes/components/caterium_ingot.json +++ b/data/recipes/components/caterium_ingot.json @@ -1,11 +1,19 @@ -[ - { - "type": [ "component" ], - "input": { "caterium_ore": 4 }, - "output": { "caterium_ingot": 1 }, - "machine": "smelter", - "crafting_time": 4, - "clicks": 4, - "requires": "caterium_technology" - } -] \ No newline at end of file +{ + "type": [ + "component" + ], + "machine": "smelter", + "recipes": [ + { + "input": { + "caterium_ore": 4 + }, + "output": { + "caterium_ingot": 1 + }, + "crafting_time": 4, + "clicks": 4, + "requires": "caterium_technology" + } + ] +} \ No newline at end of file diff --git a/data/recipes/components/circuit_board.json b/data/recipes/components/circuit_board.json index 72c57ca..5ea2c6b 100644 --- a/data/recipes/components/circuit_board.json +++ b/data/recipes/components/circuit_board.json @@ -1,12 +1,21 @@ -[ - { - "type": [ "component" ], - "input": { "wire": 12, "plastic": 6 }, - "output": { "circuit_board": 1 }, - "machine": "assembler", - "crafting_time": 12, - "clicks": 3, - "stack_size": 100, - "stage": "expansion" - } -] +{ + "type": [ + "component" + ], + "machine": "assembler", + "stack_size": 100, + "recipes": [ + { + "input": { + "wire": 12, + "plastic": 6 + }, + "output": { + "circuit_board": 1 + }, + "crafting_time": 12, + "clicks": 3, + "stage": "expansion" + } + ] +} diff --git a/data/recipes/components/computer.json b/data/recipes/components/computer.json index 0ce63ce..07b0dbd 100644 --- a/data/recipes/components/computer.json +++ b/data/recipes/components/computer.json @@ -1,12 +1,23 @@ -[ - { - "type": [ "component" ], - "input": { "circuit_board": 5, "cable": 12, "plastic": 18, "screw": 60 }, - "output": { "computer": 1 }, - "machine": "manufacturer", - "crafting_time": 32, - "clicks": 8, - "stack_size": 50, - "stage": "expansion" - } -] +{ + "type": [ + "component" + ], + "machine": "manufacturer", + "stack_size": 50, + "recipes": [ + { + "input": { + "circuit_board": 5, + "cable": 12, + "plastic": 18, + "screw": 60 + }, + "output": { + "computer": 1 + }, + "crafting_time": 32, + "clicks": 8, + "stage": "expansion" + } + ] +} diff --git a/data/recipes/components/concrete.json b/data/recipes/components/concrete.json index 2e19a29..63a82d7 100644 --- a/data/recipes/components/concrete.json +++ b/data/recipes/components/concrete.json @@ -1,11 +1,19 @@ -[ - { - "type": [ "component" ], - "input": { "limestone": 3 }, - "output": { "concrete": 1 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 1, - "requires": "hub_upgrade_2" - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "recipes": [ + { + "input": { + "limestone": 3 + }, + "output": { + "concrete": 1 + }, + "crafting_time": 4, + "clicks": 1, + "requires": "hub_upgrade_2" + } + ] +} diff --git a/data/recipes/components/copper_ingot.json b/data/recipes/components/copper_ingot.json index 87f7bad..826abf8 100644 --- a/data/recipes/components/copper_ingot.json +++ b/data/recipes/components/copper_ingot.json @@ -1,12 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "copper_ore": 1 }, - "output": { "copper_ingot": 1 }, - "machine": "smelter", - "crafting_time": 2, - "clicks": 2, - "stack_size": 100, - "stage": "establishing" - } -] \ No newline at end of file +{ + "type": [ + "component" + ], + "machine": "smelter", + "stack_size": 100, + "recipes": [ + { + "input": { + "copper_ore": 1 + }, + "output": { + "copper_ingot": 1 + }, + "crafting_time": 2, + "clicks": 2, + "stage": "establishing" + } + ] +} diff --git a/data/recipes/components/encased_industrial_beam.json b/data/recipes/components/encased_industrial_beam.json index 199b5a5..6e9f213 100644 --- a/data/recipes/components/encased_industrial_beam.json +++ b/data/recipes/components/encased_industrial_beam.json @@ -1,12 +1,21 @@ -[ - { - "type": [ "component" ], - "input": { "steel_beam": 4, "concrete": 5 }, - "output": { "encased_industrial_beam": 1 }, - "machine": "assembler", - "crafting_time": 15, - "clicks": 4, - "stack_size": 100, - "stage": "development" - } -] +{ + "type": [ + "component" + ], + "machine": "assembler", + "stack_size": 100, + "recipes": [ + { + "input": { + "steel_beam": 4, + "concrete": 5 + }, + "output": { + "encased_industrial_beam": 1 + }, + "crafting_time": 15, + "clicks": 4, + "stage": "development" + } + ] +} diff --git a/data/recipes/components/heavy_modular_frame.json b/data/recipes/components/heavy_modular_frame.json index 1d0990a..951caec 100644 --- a/data/recipes/components/heavy_modular_frame.json +++ b/data/recipes/components/heavy_modular_frame.json @@ -1,12 +1,23 @@ -[ - { - "type": [ "component" ], - "input": { "modular_frame": 5, "steel_pipe": 15, "encased_industrial_beam": 5, "screw": 90 }, - "output": { "heavy_modular_frame": 1 }, - "machine": "assembler", - "crafting_time": 30, - "clicks": 8, - "stack_size": 50, - "stage": "development" - } -] +{ + "type": [ + "component" + ], + "machine": "assembler", + "stack_size": 50, + "recipes": [ + { + "input": { + "modular_frame": 5, + "steel_pipe": 15, + "encased_industrial_beam": 5, + "screw": 90 + }, + "output": { + "heavy_modular_frame": 1 + }, + "crafting_time": 30, + "clicks": 8, + "stage": "development" + } + ] +} diff --git a/data/recipes/components/high_speed_connector.json b/data/recipes/components/high_speed_connector.json index cf62d55..b6f188b 100644 --- a/data/recipes/components/high_speed_connector.json +++ b/data/recipes/components/high_speed_connector.json @@ -1,12 +1,22 @@ -[ - { - "type": [ "component" ], - "input": { "quickwire": 40, "cable": 10, "plastic": 6 }, - "output": { "high_speed_connector": 1 }, - "machine": "manufacturer", - "crafting_time": 24, - "clicks": 6, - "stack_size": 100, - "requires": "caterium_electronics" - } -] +{ + "type": [ + "component" + ], + "machine": "manufacturer", + "stack_size": 100, + "recipes": [ + { + "input": { + "quickwire": 40, + "cable": 10, + "plastic": 6 + }, + "output": { + "high_speed_connector": 1 + }, + "crafting_time": 24, + "clicks": 6, + "requires": "caterium_electronics" + } + ] +} diff --git a/data/recipes/components/iron_ingot.json b/data/recipes/components/iron_ingot.json index bbb7bd3..5a261de 100644 --- a/data/recipes/components/iron_ingot.json +++ b/data/recipes/components/iron_ingot.json @@ -1,10 +1,18 @@ -[ - { - "type": [ "component" ], - "input": { "iron_ore": 1 }, - "output": { "iron_ingot": 1 }, - "machine": "smelter", - "crafting_time": 2, - "clicks": 2 - } -] +{ + "type": [ + "component" + ], + "machine": "smelter", + "recipes": [ + { + "input": { + "iron_ore": 1 + }, + "output": { + "iron_ingot": 1 + }, + "crafting_time": 2, + "clicks": 2 + } + ] +} diff --git a/data/recipes/components/iron_plate.json b/data/recipes/components/iron_plate.json index 9344b92..6b9c4af 100644 --- a/data/recipes/components/iron_plate.json +++ b/data/recipes/components/iron_plate.json @@ -1,9 +1,17 @@ -[ - { - "type": [ "component" ], - "input": { "iron_ingot": 2 }, - "output": { "iron_plate": 1 }, - "crafting_time": 4, - "clicks": 1 - } -] +{ + "type": [ + "component" + ], + "recipes": [ + { + "input": { + "iron_ingot": 2 + }, + "output": { + "iron_plate": 1 + }, + "crafting_time": 4, + "clicks": 1 + } + ] +} diff --git a/data/recipes/components/iron_rod.json b/data/recipes/components/iron_rod.json index 4d6c213..5b4cb25 100644 --- a/data/recipes/components/iron_rod.json +++ b/data/recipes/components/iron_rod.json @@ -1,10 +1,18 @@ -[ - { - "type": [ "component" ], - "input": { "iron_ingot": 1 }, - "output": { "iron_rod": 1 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 1 - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "recipes": [ + { + "input": { + "iron_ingot": 1 + }, + "output": { + "iron_rod": 1 + }, + "crafting_time": 4, + "clicks": 1 + } + ] +} diff --git a/data/recipes/components/modular_frame.json b/data/recipes/components/modular_frame.json index 50e83b5..fa61a3d 100644 --- a/data/recipes/components/modular_frame.json +++ b/data/recipes/components/modular_frame.json @@ -1,12 +1,21 @@ -[ - { - "type": [ "component" ], - "input": { "reinforced_iron_plate": 3, "iron_rod": 3 }, - "output": { "modular_frame": 1 }, - "machine": "assembler", - "crafting_time": 15, - "clicks": 4, - "stack_size": 50, - "stage": "establishing" - } -] +{ + "type": [ + "component" + ], + "machine": "assembler", + "stack_size": 50, + "recipes": [ + { + "input": { + "reinforced_iron_plate": 3, + "iron_rod": 3 + }, + "output": { + "modular_frame": 1 + }, + "crafting_time": 15, + "clicks": 4, + "stage": "establishing" + } + ] +} diff --git a/data/recipes/components/motor.json b/data/recipes/components/motor.json index 3d611fb..88b39a6 100644 --- a/data/recipes/components/motor.json +++ b/data/recipes/components/motor.json @@ -1,10 +1,19 @@ -[ - { - "type": [ "component" ], - "input": { "rotor": 2, "stator": 2 }, - "output": { "motor": 1 }, - "machine": "assembler", - "crafting_time": 12, - "clicks": 3 - } -] +{ + "type": [ + "component" + ], + "machine": "assembler", + "recipes": [ + { + "input": { + "rotor": 2, + "stator": 2 + }, + "output": { + "motor": 1 + }, + "crafting_time": 12, + "clicks": 3 + } + ] +} diff --git a/data/recipes/components/plastic.json b/data/recipes/components/plastic.json index 7e910bb..14416ab 100644 --- a/data/recipes/components/plastic.json +++ b/data/recipes/components/plastic.json @@ -1,12 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "crude_oil": 4 }, - "output": { "plastic": 3 }, - "machine": "oil_refinery", - "crafting_time": 8, - "clicks": 2, - "stack_size": 100, - "stage": "expansion" - } -] +{ + "type": [ + "component" + ], + "machine": "oil_refinery", + "stack_size": 100, + "recipes": [ + { + "input": { + "crude_oil": 4 + }, + "output": { + "plastic": 3 + }, + "crafting_time": 8, + "clicks": 2, + "stage": "expansion" + } + ] +} diff --git a/data/recipes/components/quickwire.json b/data/recipes/components/quickwire.json index cc35c81..e59dd2c 100644 --- a/data/recipes/components/quickwire.json +++ b/data/recipes/components/quickwire.json @@ -1,12 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "caterium_ingot": 1 }, - "output": { "quickwire": 4 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 1, - "stack_size": 500, - "requires": "caterium_technology" - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "stack_size": 500, + "recipes": [ + { + "input": { + "caterium_ingot": 1 + }, + "output": { + "quickwire": 4 + }, + "crafting_time": 4, + "clicks": 1, + "requires": "caterium_technology" + } + ] +} diff --git a/data/recipes/components/reinforced_iron_plate.json b/data/recipes/components/reinforced_iron_plate.json index 89bd259..101a91c 100644 --- a/data/recipes/components/reinforced_iron_plate.json +++ b/data/recipes/components/reinforced_iron_plate.json @@ -1,11 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "iron_plate": 4, "screw": 24 }, - "output": { "reinforced_iron_plate": 1 }, - "machine": "assembler", - "crafting_time": 12, - "clicks": 3, - "requires": "hub_upgrade_2" - } -] \ No newline at end of file +{ + "type": [ + "component" + ], + "machine": "assembler", + "recipes": [ + { + "input": { + "iron_plate": 4, + "screw": 24 + }, + "output": { + "reinforced_iron_plate": 1 + }, + "crafting_time": 12, + "clicks": 3, + "requires": "hub_upgrade_2" + } + ] +} \ No newline at end of file diff --git a/data/recipes/components/rotor.json b/data/recipes/components/rotor.json index 0438577..b72eb72 100644 --- a/data/recipes/components/rotor.json +++ b/data/recipes/components/rotor.json @@ -1,12 +1,21 @@ -[ - { - "type": [ "component" ], - "input": { "iron_rod": 3, "screw": 22 }, - "output": { "rotor": 1 }, - "machine": "smelter", - "crafting_time": 10, - "clicks": 3, - "stack_size": 100, - "stage": "establishing" - } -] +{ + "type": [ + "component" + ], + "machine": "smelter", + "stack_size": 100, + "recipes": [ + { + "input": { + "iron_rod": 3, + "screw": 22 + }, + "output": { + "rotor": 1 + }, + "crafting_time": 10, + "clicks": 3, + "stage": "establishing" + } + ] +} diff --git a/data/recipes/components/rubber.json b/data/recipes/components/rubber.json index be70363..6cc5f8f 100644 --- a/data/recipes/components/rubber.json +++ b/data/recipes/components/rubber.json @@ -1,12 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "crude_oil": 4 }, - "output": { "rubber": 4 }, - "machine": "oil_refinery", - "crafting_time": 8, - "clicks": 2, - "stack_size": 100, - "stage": "expansion" - } -] +{ + "type": [ + "component" + ], + "machine": "oil_refinery", + "stack_size": 100, + "recipes": [ + { + "input": { + "crude_oil": 4 + }, + "output": { + "rubber": 4 + }, + "crafting_time": 8, + "clicks": 2, + "stage": "expansion" + } + ] +} diff --git a/data/recipes/components/screw.json b/data/recipes/components/screw.json index 3991a1c..8c8f911 100644 --- a/data/recipes/components/screw.json +++ b/data/recipes/components/screw.json @@ -1,11 +1,19 @@ -[ - { - "type": [ "component" ], - "input": { "iron_rod": 1 }, - "output": { "screw": 6 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 2, - "requires": "hub_upgrade_2" - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "recipes": [ + { + "input": { + "iron_rod": 1 + }, + "output": { + "screw": 6 + }, + "crafting_time": 4, + "clicks": 2, + "requires": "hub_upgrade_2" + } + ] +} diff --git a/data/recipes/components/stator.json b/data/recipes/components/stator.json index c0ff801..3eca33e 100644 --- a/data/recipes/components/stator.json +++ b/data/recipes/components/stator.json @@ -1,10 +1,19 @@ -[ - { - "type": [ "component" ], - "input": { "steel_pipe": 3, "wire": 10 }, - "output": { "stator": 1 }, - "machine": "assembler", - "crafting_time": 10, - "clicks": 3 - } -] \ No newline at end of file +{ + "type": [ + "component" + ], + "recipes": [ + { + "input": { + "steel_pipe": 3, + "wire": 10 + }, + "output": { + "stator": 1 + }, + "machine": "assembler", + "crafting_time": 10, + "clicks": 3 + } + ] +} \ No newline at end of file diff --git a/data/recipes/components/steel_beam.json b/data/recipes/components/steel_beam.json index 49060de..136724e 100644 --- a/data/recipes/components/steel_beam.json +++ b/data/recipes/components/steel_beam.json @@ -1,11 +1,19 @@ -[ - { - "type": [ "component" ], - "input": { "steel_ingot": 3 }, - "output": { "steel_beam": 1 }, - "machine": "constructor", - "crafting_time": 6, - "clicks": 2, - "stack_size": 100 - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "stack_size": 100, + "recipes": [ + { + "input": { + "steel_ingot": 3 + }, + "output": { + "steel_beam": 1 + }, + "crafting_time": 6, + "clicks": 2 + } + ] +} diff --git a/data/recipes/components/steel_ingot.json b/data/recipes/components/steel_ingot.json index f80bef2..3dfa306 100644 --- a/data/recipes/components/steel_ingot.json +++ b/data/recipes/components/steel_ingot.json @@ -1,12 +1,21 @@ -[ - { - "type": [ "component" ], - "input": { "iron_ore": 3, "coal": 3 }, - "output": { "steel_ingot": 2 }, - "machine": "foundry", - "crafting_time": 4, - "clicks": 4, - "stack_size": 100, - "stage": "development" - } -] +{ + "type": [ + "component" + ], + "machine": "foundry", + "stack_size": 100, + "recipes": [ + { + "input": { + "iron_ore": 3, + "coal": 3 + }, + "output": { + "steel_ingot": 2 + }, + "crafting_time": 4, + "clicks": 4, + "stage": "development" + } + ] +} diff --git a/data/recipes/components/steel_pipe.json b/data/recipes/components/steel_pipe.json index e65d2ee..1cd76a4 100644 --- a/data/recipes/components/steel_pipe.json +++ b/data/recipes/components/steel_pipe.json @@ -1,12 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "steel_ingot": 1 }, - "output": { "steel_pipe": 1 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 1, - "stack_size": 100, - "stage": "development" - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "stack_size": 100, + "recipes": [ + { + "input": { + "steel_ingot": 1 + }, + "output": { + "steel_pipe": 1 + }, + "crafting_time": 4, + "clicks": 1, + "stage": "development" + } + ] +} diff --git a/data/recipes/components/supercomputer.json b/data/recipes/components/supercomputer.json index 005ff57..33eb7eb 100644 --- a/data/recipes/components/supercomputer.json +++ b/data/recipes/components/supercomputer.json @@ -1,12 +1,23 @@ -[ - { - "type": [ "component" ], - "input": { "computer": 2, "ai_limiter": 2, "high_speed_connector": 3, "plastic": 21 }, - "output": { "supercomputer": 1 }, - "machine": "manufacturer", - "crafting_time": 32, - "clicks": 8, - "stack_size": 50, - "requires": "advanced_caterium_electronics" - } -] +{ + "type": [ + "component" + ], + "machine": "manufacturer", + "stack_size": 50, + "recipes": [ + { + "input": { + "computer": 2, + "ai_limiter": 2, + "high_speed_connector": 3, + "plastic": 21 + }, + "output": { + "supercomputer": 1 + }, + "crafting_time": 32, + "clicks": 8, + "requires": "advanced_caterium_electronics" + } + ] +} diff --git a/data/recipes/components/wire.json b/data/recipes/components/wire.json index a1ec41b..73e9e15 100644 --- a/data/recipes/components/wire.json +++ b/data/recipes/components/wire.json @@ -1,12 +1,20 @@ -[ - { - "type": [ "component" ], - "input": { "copper_ingot": 1 }, - "output": { "wire": 3 }, - "machine": "constructor", - "crafting_time": 4, - "clicks": 1, - "stack_size": 500, - "stage": "establishing" - } -] +{ + "type": [ + "component" + ], + "machine": "constructor", + "stack_size": 500, + "recipes": [ + { + "input": { + "copper_ingot": 1 + }, + "output": { + "wire": 3 + }, + "crafting_time": 4, + "clicks": 1, + "stage": "establishing" + } + ] +} diff --git a/data/recipes/machine/assembler.json b/data/recipes/machine/assembler.json index b2c2125..7b50214 100644 --- a/data/recipes/machine/assembler.json +++ b/data/recipes/machine/assembler.json @@ -1,10 +1,24 @@ -[ - { - "type": [ "machine" ], - "input": { "modular_frame": 3, "rotor": 4, "cable": 10 }, - "output": { "assembler": 1 }, - "machine": "_craft_bench", - "power_usage": 15, - "size": [ 11, 14, 8 ] - } -] +{ + "type": [ + "machine" + ], + "machine": "_craft_bench", + "power_usage": 15, + "size": [ + 11, + 14, + 8 + ], + "recipes": [ + { + "input": { + "modular_frame": 3, + "rotor": 4, + "cable": 10 + }, + "output": { + "assembler": 1 + } + } + ] +} diff --git a/data/recipes/machine/constructor.json b/data/recipes/machine/constructor.json index 31efb9b..907cf76 100644 --- a/data/recipes/machine/constructor.json +++ b/data/recipes/machine/constructor.json @@ -1,11 +1,24 @@ -[ - { - "type": [ "machine" ], - "input": { "reinforced_iron_plate": 3, "cable": 2 }, - "output": { "constructor": 1 }, - "machine": "_craft_bench", - "requires": "hub_upgrade_2", - "power_usage": 4, - "size": [ 9, 11, 8 ] - } -] +{ + "type": [ + "machine" + ], + "machine": "_craft_bench", + "requires": "hub_upgrade_2", + "power_usage": 4, + "size": [ + 9, + 11, + 8 + ], + "recipes": [ + { + "input": { + "reinforced_iron_plate": 3, + "cable": 2 + }, + "output": { + "constructor": 1 + } + } + ] +} diff --git a/data/recipes/machine/manufacturer.json b/data/recipes/machine/manufacturer.json index e2aeb9f..a33624b 100644 --- a/data/recipes/machine/manufacturer.json +++ b/data/recipes/machine/manufacturer.json @@ -1,10 +1,25 @@ -[ - { - "type": [ "machine" ], - "input": { "heavy_modular_frame": 2, "motor": 2, "cable": 25, "computer": 3 }, - "output": { "manufacturer": 1 }, - "machine": "_craft_bench", - "power_usage": 55, - "size": [ 20, 22, 12 ] - } -] +{ + "type": [ + "machine" + ], + "machine": "_craft_bench", + "power_usage": 55, + "size": [ + 20, + 22, + 12 + ], + "recipes": [ + { + "input": { + "heavy_modular_frame": 2, + "motor": 2, + "cable": 25, + "computer": 3 + }, + "output": { + "manufacturer": 1 + } + } + ] +} diff --git a/data/recipes/machine/miner_mk1.json b/data/recipes/machine/miner_mk1.json index 7603ab6..fb1a08d 100644 --- a/data/recipes/machine/miner_mk1.json +++ b/data/recipes/machine/miner_mk1.json @@ -1,12 +1,26 @@ -[ - { - "type": [ "machine" ], - "input": { "portable_miner": 1, "iron_rod": 5, "concrete": 5 }, - "output": { "miner_mk1": 1 }, - "is": "miner", - "machine": "_craft_bench", - "power_usage": 5, - "size": [ 8, 14, 18 ], - "requires": "hub_upgrade_4" - } -] \ No newline at end of file +{ + "type": [ + "machine" + ], + "is": "miner", + "machine": "_craft_bench", + "power_usage": 5, + "size": [ + 8, + 14, + 18 + ], + "recipes": [ + { + "input": { + "portable_miner": 1, + "iron_rod": 5, + "concrete": 5 + }, + "output": { + "miner_mk1": 1 + }, + "requires": "hub_upgrade_4" + } + ] +} \ No newline at end of file diff --git a/data/recipes/machine/oil_pump.json b/data/recipes/machine/oil_pump.json index f71f999..45d1fbc 100644 --- a/data/recipes/machine/oil_pump.json +++ b/data/recipes/machine/oil_pump.json @@ -1,10 +1,24 @@ -[ - { - "type": [ "machine" ], - "input": { "heavy_modular_frame": 2, "motor": 3, "cable": 10 }, - "output": { "oil_pump": 1 }, - "machine": "_craft_bench", - "power_usage": 40, - "size": [ 8, 14, 20 ] - } -] +{ + "type": [ + "machine" + ], + "machine": "_craft_bench", + "power_usage": 40, + "size": [ + 8, + 14, + 20 + ], + "recipes": [ + { + "input": { + "heavy_modular_frame": 2, + "motor": 3, + "cable": 10 + }, + "output": { + "oil_pump": 1 + } + } + ] +} diff --git a/data/recipes/machine/portable_miner.json b/data/recipes/machine/portable_miner.json index 43afd52..849b27a 100644 --- a/data/recipes/machine/portable_miner.json +++ b/data/recipes/machine/portable_miner.json @@ -1,9 +1,20 @@ -[ - { - "type": [ "machine", "item" ], - "input": { "iron_plate": 4, "wire": 8, "cable": 4 }, - "output": { "portable_miner": 1 }, - "machine": "equipment_workshop", - "requires": "hub_upgrade_1" - } -] +{ + "type": [ + "machine", + "item" + ], + "machine": "equipment_workshop", + "recipes": [ + { + "input": { + "iron_plate": 4, + "wire": 8, + "cable": 4 + }, + "output": { + "portable_miner": 1 + }, + "requires": "hub_upgrade_1" + } + ] +} diff --git a/data/recipes/machine/smelter.json b/data/recipes/machine/smelter.json index f75ab7b..387dad8 100644 --- a/data/recipes/machine/smelter.json +++ b/data/recipes/machine/smelter.json @@ -1,10 +1,19 @@ -[ - { - "type": [ "machine" ], - "input": { "iron_rod": 5, "wire": 8 }, - "output": { "smelter": 1 }, - "machine": "_craft_bench", - "power_usage": 4, - "size": [ 6, 10, 10 ] - } -] +{ + "type": [ + "machine" + ], + "machine": "_craft_bench", + "power_usage": 4, + "recipes": [ + { + "input": { + "iron_rod": 5, + "wire": 8 + }, + "output": { + "smelter": 1 + }, + "size": [ 6, 10, 10 ] + } + ] +} diff --git a/data/recipes/machine/space_elevator.json b/data/recipes/machine/space_elevator.json index a5cd54c..495abce 100644 --- a/data/recipes/machine/space_elevator.json +++ b/data/recipes/machine/space_elevator.json @@ -1,11 +1,14 @@ -[ - { - "type": [ "machine" ], - "input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 }, - "output": { "space_elevator": 1 }, - "machine": "_placement", - "power_usage": null, - "size": [ 54, 54, 118 ], - "requires": "hub_upgrade_5" - } -] +{ + "type": [ "machine" ], + "machine": "_placement", + "power_usage": null, + "size": [ 54, 54, 118 ], + "recipes": + [ + { + "input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 }, + "output": { "space_elevator": 1 }, + "requires": "hub_upgrade_5" + } + ] +} diff --git a/data/recipes/resources/caterium_ore.json b/data/recipes/resources/caterium_ore.json index 3b08a6a..f82f4d3 100644 --- a/data/recipes/resources/caterium_ore.json +++ b/data/recipes/resources/caterium_ore.json @@ -1,8 +1,11 @@ -[ - { - "type": [ "resource" ], - "input": { }, - "output": { "caterium_ore": 1 }, - "machine": "miner" - } -] +{ + "type": [ "resource" ], + "machine": "miner", + "recipes": [ + { + "input": { }, + "output": { "caterium_ore": 1 } + } + ] +} + diff --git a/data/recipes/resources/coal.json b/data/recipes/resources/coal.json index e501005..b287568 100644 --- a/data/recipes/resources/coal.json +++ b/data/recipes/resources/coal.json @@ -1,8 +1,11 @@ -[ - { - "type": [ "resource" ], - "input": { }, - "output": { "coal": 1 }, - "machine": "miner" - } -] +{ + "type": [ "resource" ], + "machine": "miner", + "recipes": + [ + { + "input": { }, + "output": { "coal": 1 } + } + ] +} diff --git a/data/recipes/resources/copper_ore.json b/data/recipes/resources/copper_ore.json index 4202593..c9246a4 100644 --- a/data/recipes/resources/copper_ore.json +++ b/data/recipes/resources/copper_ore.json @@ -1,8 +1,14 @@ -[ - { - "type": [ "resource" ], - "input": { }, - "output": { "copper_ore": 1 }, - "machine": "miner" - } -] +{ + "type": [ + "resource" + ], + "machine": "miner", + "recipes": [ + { + "input": {}, + "output": { + "copper_ore": 1 + } + } + ] +} diff --git a/data/recipes/resources/crude_oil.json b/data/recipes/resources/crude_oil.json index 998f271..15a4dac 100644 --- a/data/recipes/resources/crude_oil.json +++ b/data/recipes/resources/crude_oil.json @@ -1,8 +1,11 @@ -[ - { - "type": [ "resource" ], - "input": { }, - "output": { "crude_oil": 1 }, - "machine": "oil_pump" - } -] +{ + "type": [ "resource" ], + "machine": "oil_pump", + "recipes": + [ + { + "input": { }, + "output": { "crude_oil": 1 } + } + ] +} diff --git a/data/recipes/resources/iron_ore.json b/data/recipes/resources/iron_ore.json index 38f039a..4ca4e4d 100644 --- a/data/recipes/resources/iron_ore.json +++ b/data/recipes/resources/iron_ore.json @@ -1,8 +1,11 @@ -[ - { - "type": [ "resource" ], - "input": { }, - "output": { "iron_ore": 1 }, - "machine": "miner" - } -] +{ + "type": [ "resource" ], + "machine": "miner", + "recipes": + [ + { + "input": { }, + "output": { "iron_ore": 1 } + } + ] +} diff --git a/data/recipes/resources/limestone.json b/data/recipes/resources/limestone.json index de5109a..b206257 100644 --- a/data/recipes/resources/limestone.json +++ b/data/recipes/resources/limestone.json @@ -1,9 +1,15 @@ -[ - { - "type": [ "resource" ], - "input": { }, - "output": { "limestone": 1 }, - "machine": "miner", - "requires": "hub_upgrade_2" - } -] +{ + "type": [ + "resource" + ], + "machine": "miner", + "requires": "hub_upgrade_2", + "recipes": [ + { + "input": {}, + "output": { + "limestone": 1 + } + } + ] +} diff --git a/describe.py b/describe.py index 5ef7b62..a7618ba 100755 --- a/describe.py +++ b/describe.py @@ -1,31 +1,12 @@ #!/usr/bin/env python3 -import json -import typing -import os +import satisfactory if __name__ == '__main__': root = os.path.dirname(__file__) recipe_root = os.path.join(root, 'data', 'recipes') + cookbook = satisfactory.Cookbook(recipe_root) - recipes = dict() + print(i for i in cookbook.resources()) - for dirname, dirs, files in os.walk(recipe_root): - for f in files: - path = os.path.join(dirname, f) - name, _ = os.path.splitext(f) - with open(path, 'r') as src: - variations = json.load(src) - - recipes[name] = variations - - - resources = set() - - for output, variations in recipes.items(): - for option in variations: - if len(option['input']) == 0: - resources.add(output) - - print("Resources:", resources) diff --git a/graph.py b/graph.py index 90cc77d..c9490ea 100755 --- a/graph.py +++ b/graph.py @@ -1,48 +1,13 @@ #!/usr/bin/env python3 -import json +import satisfactory + import os from typing import Iterable -class Cookbook(object): - recipes: dict - def __init__(self, root: str): - self.recipes = dict() - - for dirname, dirs, files in os.walk(root): - for f in files: - path = os.path.join(dirname, f) - name, _ = os.path.splitext(f) - with open(path, 'r') as src: - variations = json.load(src) - - self.recipes[name] = variations - - def __getitem__(self, item: str): - return self.recipes[item] - - 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]): +def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]): print("digraph G {") seen = set() @@ -51,7 +16,7 @@ def graph(recipes: dict, targets: Iterable[str]): while remain: output = remain.pop() - for need in recipes[output][0]['input']: + for need in cookbook.recipes(output)[0]['input']: print(f"{need} -> {output}") if need not in seen: remain.add(need) @@ -81,7 +46,7 @@ if __name__ == '__main__': args = parser.parse_args() - recipes = Cookbook(args.data) + recipes = satisfactory.Cookbook(args.data) if args.target: graph_one(recipes, args.target) diff --git a/satisfactory/__init__.py b/satisfactory/__init__.py new file mode 100644 index 0000000..f5a4abc --- /dev/null +++ b/satisfactory/__init__.py @@ -0,0 +1,44 @@ +import os +import json + +class Cookbook(object): + __recipes: dict + + def __init__(self, root: str): + self.__recipes = dict() + + for dirname, dirs, files in os.walk(root): + for f in files: + path = os.path.join(dirname, f) + name, _ = os.path.splitext(f) + with open(path, 'r') as src: + self.__recipes[name] = json.load(src) + + def __getitem__(self, item: str): + return self.__recipes[item] + + def all(self): + return self.__recipes.keys() + + def recipes(self, name: str) -> dict: + return self.__recipes[name]['recipes'] + + def is_component(self, name): + return 'component' in self.__recipes[name]['type'] + + def is_resource(self, name): + return '' + + def components(self): + found = set() + + for _, descriptor in self.__recipes.items(): + for variation in descriptor['recipes']: + for need, _ in variation['input'].items(): + if need in found: + continue + found.add(need) + if not self.is_component(need): + continue + yield need +