Implement random progressive techs.

This commit is contained in:
CaitSith2 2021-08-02 19:33:14 -07:00
parent 41037ce599
commit dfc56a3272
3 changed files with 10 additions and 9 deletions

View File

@ -106,6 +106,7 @@ Factorio:
progressive: progressive:
on: 1 on: 1
off: 0 off: 0
random: 0
tech_tree_information: tech_tree_information:
none: 0 none: 0
advancement: 0 # show which items are a logical advancement advancement: 0 # show which items are a logical advancement

View File

@ -100,11 +100,13 @@ class RecipeTime(Choice):
option_chaos = 5 option_chaos = 5
# TODO: implement random
class Progressive(Choice): class Progressive(Choice):
displayname = "Progressive Technologies"
option_off = 0 option_off = 0
option_random = 1 option_random = 1
option_on = 2 option_on = 2
alias_false = 0
alias_true = 2
default = 2 default = 2
def want_progressives(self, random): def want_progressives(self, random):
@ -258,9 +260,6 @@ class FactorioWorldGen(OptionDict):
class ImportedBlueprint(DefaultOnToggle): class ImportedBlueprint(DefaultOnToggle):
displayname = "Blueprints" displayname = "Blueprints"
class ProgressiveToggle(DefaultOnToggle):
displayname = "Progressive Technologies"
factorio_options: typing.Dict[str, type(Option)] = { factorio_options: typing.Dict[str, type(Option)] = {
"max_science_pack": MaxSciencePack, "max_science_pack": MaxSciencePack,
"tech_tree_layout": TechTreeLayout, "tech_tree_layout": TechTreeLayout,
@ -273,5 +272,5 @@ factorio_options: typing.Dict[str, type(Option)] = {
"recipe_ingredients": RecipeIngredients, "recipe_ingredients": RecipeIngredients,
"imported_blueprints": ImportedBlueprint, "imported_blueprints": ImportedBlueprint,
"world_gen": FactorioWorldGen, "world_gen": FactorioWorldGen,
"progressive": ProgressiveToggle "progressive": Progressive
} }

View File

@ -28,14 +28,15 @@ class Factorio(World):
data_version = 3 data_version = 3
def generate_basic(self): def generate_basic(self):
want_progressives = {}
skip_silo = self.world.silo[self.player].value == Silo.option_spawn skip_silo = self.world.silo[self.player].value == Silo.option_spawn
for tech_name in base_tech_table: for tech_name in base_tech_table:
if skip_silo and tech_name == "rocket-silo": if skip_silo and tech_name == "rocket-silo":
continue continue
if self.world.progressive[self.player]: progressive_item_name = tech_to_progressive_lookup.get(tech_name, tech_name)
item_name = tech_to_progressive_lookup.get(tech_name, tech_name) want_progressive = want_progressives.setdefault(progressive_item_name,
else: self.world.progressive[self.player].want_progressives(self.world.random))
item_name = tech_name item_name = progressive_item_name if want_progressive else tech_name
tech_item = self.create_item(item_name) tech_item = self.create_item(item_name)
if tech_name in self.static_nodes: if tech_name in self.static_nodes:
self.world.get_location(tech_name, self.player).place_locked_item(tech_item) self.world.get_location(tech_name, self.player).place_locked_item(tech_item)