From ab4324c901b7bf70cbbf2888863f5cbefeb4fb97 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 28 Jan 2023 00:30:05 +0100 Subject: [PATCH] Factorio: add option "ramping tech cost" (#1403) * Factorio: add option "ramping tech cost" * Factorio: fix missing s * Factorio: add display_name to ranmping tech costs --- worlds/factorio/Options.py | 9 +++++++++ worlds/factorio/__init__.py | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index 824c0850..c5afb730 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -69,6 +69,14 @@ class TechCostMix(Range): default = 70 +class RampingTechCosts(Toggle): + """Forces the amount of Science Packs required to ramp up with the highest involved Pack. Average is preserved. + For example: + off: Automation (red)/Logistics (green) sciences can range from 1 to 1000 Science Packs, + on: Automation (red) ranges to ~500 packs and Logistics (green) from ~500 to 1000 Science Packs""" + display_name = "Ramping Tech Costs" + + class Silo(Choice): """Ingredients to craft rocket silo or auto-place if set to spawn.""" display_name = "Rocket Silo" @@ -372,6 +380,7 @@ factorio_options: typing.Dict[str, type(Option)] = { "min_tech_cost": MinTechCost, "max_tech_cost": MaxTechCost, "tech_cost_mix": TechCostMix, + "ramping_tech_costs": RampingTechCosts, "silo": Silo, "satellite": Satellite, "free_samples": FreeSamples, diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index 13603d16..a48e7592 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -99,7 +99,13 @@ class Factorio(World): for loc_name in location_names] rand_values = sorted(random.randint(self.multiworld.min_tech_cost[self.player], self.multiworld.max_tech_cost[self.player]) for _ in self.locations) - for i, location in enumerate(sorted(self.locations, key=lambda loc: loc.rel_cost)): + if self.multiworld.ramping_tech_costs[self.player]: + def sorter(loc: FactorioScienceLocation): + return loc.complexity, loc.rel_cost + else: + def sorter(loc: FactorioScienceLocation): + return loc.rel_cost + for i, location in enumerate(sorted(self.locations, key=sorter)): location.count = rand_values[i] del rand_values nauvis.locations.extend(self.locations)