Factorio: update API use (#3760)

---------

Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
Fabian Dill
2024-09-18 00:18:17 +02:00
committed by GitHub
parent debb936618
commit 6fac83b84c
5 changed files with 136 additions and 149 deletions

View File

@@ -19,12 +19,10 @@ def _sorter(location: "FactorioScienceLocation"):
return location.complexity, location.rel_cost
def get_shapes(factorio_world: "Factorio") -> Dict["FactorioScienceLocation", Set["FactorioScienceLocation"]]:
world = factorio_world.multiworld
player = factorio_world.player
def get_shapes(world: "Factorio") -> Dict["FactorioScienceLocation", Set["FactorioScienceLocation"]]:
prerequisites: Dict["FactorioScienceLocation", Set["FactorioScienceLocation"]] = {}
layout = world.tech_tree_layout[player].value
locations: List["FactorioScienceLocation"] = sorted(factorio_world.science_locations, key=lambda loc: loc.name)
layout = world.options.tech_tree_layout.value
locations: List["FactorioScienceLocation"] = sorted(world.science_locations, key=lambda loc: loc.name)
world.random.shuffle(locations)
if layout == TechTreeLayout.option_single:
@@ -247,5 +245,5 @@ def get_shapes(factorio_world: "Factorio") -> Dict["FactorioScienceLocation", Se
else:
raise NotImplementedError(f"Layout {layout} is not implemented.")
factorio_world.tech_tree_layout_prerequisites = prerequisites
world.tech_tree_layout_prerequisites = prerequisites
return prerequisites