factorio-base-definer/calc.py
2024-02-13 10:09:09 -08:00

179 lines
7.2 KiB
Python

from dataclasses import dataclass
@dataclass(frozen=True)
class Resource:
name: str
# item definitions
class RS:
iron_ore = Resource("Iron Ore")
copper_ore = Resource("Copper Ore")
uranium_ore = Resource("Uranium Ore")
stone = Resource("Stone")
coal = Resource("Coal")
crude_oil = Resource("Crude Oil")
water = Resource("Water")
petrolium_gas = Resource("Petrolium Gas")
light_oil = Resource("Light Oil")
heavy_oil = Resource("Heavy Oil")
energy = Resource("Energy (kW)")
assembler = Resource("Assembler")
mining_drill = Resource("Mining Drill")
furnace = Resource("Furnace")
chemical_plant = Resource("Chemical Plant")
oil_refinery = Resource("Oil Refinery")
rocket_launch = Resource("Rocket Launch")
iron_plate = Resource("Iron Plate")
copper_plate = Resource("Copper Plate")
stone_brick = Resource("Stone Brick")
steel = Resource("Steel")
concrete = Resource("Concrete")
iron_gear = Resource("Iron Gear")
iron_stick = Resource("Iron Stick")
pipe = Resource("Pipe")
copper_cable = Resource("Copper Cable")
circuit_a = Resource("Electronic Circuit")
circuit_b = Resource("Advanced Circuit")
circuit_c = Resource("Processing Unit")
sulfur = Resource("Sulfur")
sulfuric_acid = Resource("Sulfuric Acid")
plastic = Resource("Plastic Bar")
explosives = Resource("Explosives")
battery = Resource("Battery")
engine_unit = Resource("Engine Unit")
engine_unit_electric = Resource("Electric Engine Unit")
belt_y = Resource("Transport Belt")
# belt_r = Resource("Fast Transport Belt")
# belt_b = Resource("Express Transport Belt")
inserter_y = Resource("Inserter")
# inserter_r = Resource("Long-Handed Inserter")
# inserter_b = Resource("Fast Inserter")
steam = Resource("Steam")
lubricant = Resource("Lubricant")
flying_robot_frame = Resource("Flying Robot Frame")
low_density_structure = Resource("Low Density Structure")
magazine_y = Resource("Firearm Magazine")
magazine_r = Resource("Piercing Magazine")
grenade = Resource("Grenade")
rocket_part = Resource("Rocket Part")
rocket_y = Resource("Rocket")
rocket_r = Resource("Explosive Rocket")
science_red = Resource("Automation Science Pack")
science_green = Resource("Logistic Science Pack")
science_gray = Resource("Military Science Pack")
science_blue = Resource("Chemical Science Pack")
science_purple = Resource("Production Science Pack")
science_yellow = Resource("Utility Science Pack")
science_white = Resource("Space Science Pack")
@dataclass
class Recipe:
name: str
resources: dict[Resource, float]
class Recipies:
# mining
iron_ore = Recipe("Iron Ore", {RS.mining_drill: -1, RS.iron_ore: 0.5})
copper_ore = Recipe("Copper Ore", {RS.mining_drill: -1, RS.copper_ore: 0.5})
stone = Recipe("Stone", {RS.mining_drill: -1, RS.stone: 0.5})
coal = Recipe("Coal", {RS.mining_drill: -1, RS.coal: 0.5})
uranium_ore = Recipe("Uranium Ore", {RS.mining_drill: -1, RS.sulfuric_acid: -0.25, RS.uranium_ore: 0.25})
# oil
basic_oil_processing = Recipe(
"Basic Oil Processing",
{
RS.oil_refinery: -5,
RS.crude_oil: -100,
RS.petrolium_gas: 45,
}
)
advanced_oil_processing = Recipe(
"Advanced Oil Processing",
{
RS.oil_refinery: -5,
RS.crude_oil: -100,
RS.water: -50,
RS.petrolium_gas: 55,
RS.light_oil: 45,
RS.heavy_oil: 25,
},
)
coal_liquefaction = Recipe(
"Coal Liquefaction",
{
RS.oil_refinery: -5,
RS.coal: -10,
RS.steam: -50,
RS.petrolium_gas: 10,
RS.light_oil: 20,
RS.heavy_oil: -25 + 90,
}
)
heavy_oil_cracking = Recipe("Heavy Oil Cracking", {RS.chemical_plant: -2, RS.heavy_oil: -40, RS.water: -30, RS.light_oil: 30})
light_oil_cracking = Recipe("Light Oil Cracking", {RS.chemical_plant: -2, RS.light_oil: -30, RS.water: -30, RS.petrolium_gas: 20})
# smelting
iron_plate = Recipe("Iron Plate", {RS.furnace: -3.2, RS.iron_ore: -1, RS.iron_plate: 1})
copper_plate = Recipe("Copper Plate", {RS.furnace: -3.2, RS.copper_ore: -1, RS.copper_plate: 1})
stone_brick = Recipe("Stone Brick", {RS.furnace: -3.2, RS.stone: -2, RS.stone_brick: 1})
steel = Recipe("Steel", {RS.furnace: -16, RS.iron_plate: -5, RS.steel: 1})
# crafting
concrete = Recipe("Concrete", {RS.assembler: -10, RS.iron_ore: -1, RS.stone_brick: -5, RS.water: -100, RS.concrete: 10})
iron_gear = Recipe("Iron Gear", {RS.assembler: -0.5, RS.iron_plate: -2, RS.iron_gear: 1})
iron_stick = Recipe("Iron Stick", {RS.assembler: -0.5, RS.iron_plate: -1, RS.iron_stick: 2})
pipe = None # TODO
copper_cable = Recipe("Copper Cable", {RS.assembler: -0.5, RS.copper_plate: -1, RS.copper_cable: 2})
circuit_a = Recipe("Electronic Circuit", {RS.assembler: -0.5, RS.copper_cable: -3, RS.iron_plate: -1, RS.circuit_a: 1})
circuit_b = Recipe("Advanced Circuit", {RS.assembler: -6, RS.copper_cable: -4, RS.circuit_a: -2, RS.plastic: -2, RS.circuit_b: 1})
circuit_c = Recipe("Processing Unit", {RS.assembler: -10, RS.circuit_b: -2, RS.circuit_a: -20, RS.sulfuric_acid: -5, RS.circuit_c: 1})
sulfur = Recipe("Sulfur", {RS.chemical_plant: -1, RS.petrolium_gas: -30, RS.water: -30, RS.sulfur: 2})
sulfuric_acid = Recipe("Sulfuric Acid", {RS.chemical_plant: -1, RS.iron_plate: -1, RS.sulfur: -5, RS.water: -100, RS.sulfuric_acid: 50})
plastic = Recipe("Plastic", {RS.chemical_plant: -1, RS.coal: -1, RS.petrolium_gas: -20, RS.plastic: 2})
explosives = Recipe("Explosives", {RS.chemical_plant: -4, RS.coal: -1, RS.sulfur: -1, RS.water: -10, RS.explosives: 2})
battery = Recipe("Battery", {RS.chemical_plant: -4, RS.copper_plate: -1, RS.iron_plate: -20, RS.sulfuric_acid: -20, RS.battery: 1})
engine_unit = Recipe("Engine Unit", {RS.assembler: -10, RS.iron_gear: -1, RS.pipe: -2, RS.steel: -1, RS.engine_unit: 1})
engine_unit_electric = Recipe("Electric Engine Unit", {RS.assembler: -10, RS.circuit_a: -2, RS.engine_unit: -1, RS.lubricant: -15, RS.engine_unit_electric: 1})
belt_y = Recipe("Transport Belt", {RS.assembler: -0.5, RS.iron_gear: -1, RS.iron_plate: -1, RS.belt_y: 2})
inserter_y = Recipe("Inserter", {RS.assembler: -0.5, RS.circuit_a: -1, RS.iron_gear: -1, RS.iron_plate: -1, RS.inserter_y: 1})
magazine_y = Recipe("Firearm Magazine", {RS.assembler: -1, RS.iron_plate: -4, RS.magazine_y: 1})
magazine_r = Recipe("Piercing Magazine", {RS.assembler: -1, RS.copper_plate: -5, RS.magazine_y: -1, RS.steel: -1, RS.magazine_r: 1})
grenade = Recipe("Grenade", {RS.assembler: -8, RS.coal: -10, RS.iron_plate: -5, RS.grenade: 1})
rocket_y = Recipe("Rocket", {RS.assembler: -8, RS.circuit_a: -1, RS.explosives: -1, RS.iron_plate: -2, RS.rocket_y: 1})
rocket_r = Recipe("Explosive Rocket", {RS.assembler: -8, RS.explosives: -2, RS.rocket_r: 1})
RECIPIES = {}