Allow explicit blacklisting (and whitelisting) of free samples from yaml
This commit is contained in:
parent
548d893eaa
commit
a15689e380
|
@ -113,6 +113,8 @@ def generate_mod(world, output_directory: str):
|
||||||
"goal": multiworld.goal[player].value}
|
"goal": multiworld.goal[player].value}
|
||||||
|
|
||||||
for factorio_option in Options.factorio_options:
|
for factorio_option in Options.factorio_options:
|
||||||
|
if factorio_option == "free_sample_blacklist":
|
||||||
|
continue
|
||||||
template_data[factorio_option] = getattr(multiworld, factorio_option)[player].value
|
template_data[factorio_option] = getattr(multiworld, factorio_option)[player].value
|
||||||
|
|
||||||
if getattr(multiworld, "silo")[player].value == Options.Silo.option_randomize_recipe:
|
if getattr(multiworld, "silo")[player].value == Options.Silo.option_randomize_recipe:
|
||||||
|
@ -121,6 +123,8 @@ def generate_mod(world, output_directory: str):
|
||||||
if getattr(multiworld, "satellite")[player].value == Options.Satellite.option_randomize_recipe:
|
if getattr(multiworld, "satellite")[player].value == Options.Satellite.option_randomize_recipe:
|
||||||
template_data["free_sample_blacklist"]["satellite"] = 1
|
template_data["free_sample_blacklist"]["satellite"] = 1
|
||||||
|
|
||||||
|
template_data["free_sample_blacklist"].update(multiworld.free_sample_blacklist[player].value)
|
||||||
|
|
||||||
control_code = control_template.render(**template_data)
|
control_code = control_template.render(**template_data)
|
||||||
data_template_code = data_template.render(**template_data)
|
data_template_code = data_template.render(**template_data)
|
||||||
data_final_fixes_code = data_final_template.render(**template_data)
|
data_final_fixes_code = data_final_template.render(**template_data)
|
||||||
|
|
|
@ -154,6 +154,18 @@ class FactorioStartItems(ItemDict):
|
||||||
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
||||||
|
|
||||||
|
|
||||||
|
class FactorioFreeSampleBlacklist(OptionDict):
|
||||||
|
"""any non-zero value means that item is blacklisted from free samples. zero overrides the built-in blacklist"""
|
||||||
|
displayname = "Free Sample Blacklist"
|
||||||
|
|
||||||
|
def __init__(self, value: typing.Dict[str, int]):
|
||||||
|
self.value = value or {}
|
||||||
|
if any(type(value) not in [int, bool] for value in self.value.values()):
|
||||||
|
raise Exception("Cannot have non-number blacklist options")
|
||||||
|
for key in self.value.keys():
|
||||||
|
self.value[key] = 1 if self.value[key] else 0
|
||||||
|
|
||||||
|
|
||||||
class TrapCount(Range):
|
class TrapCount(Range):
|
||||||
range_end = 4
|
range_end = 4
|
||||||
|
|
||||||
|
@ -322,6 +334,7 @@ factorio_options: typing.Dict[str, type(Option)] = {
|
||||||
"free_samples": FreeSamples,
|
"free_samples": FreeSamples,
|
||||||
"tech_tree_information": TechTreeInformation,
|
"tech_tree_information": TechTreeInformation,
|
||||||
"starting_items": FactorioStartItems,
|
"starting_items": FactorioStartItems,
|
||||||
|
"free_sample_blacklist": FactorioFreeSampleBlacklist,
|
||||||
"recipe_time": RecipeTime,
|
"recipe_time": RecipeTime,
|
||||||
"recipe_ingredients": RecipeIngredients,
|
"recipe_ingredients": RecipeIngredients,
|
||||||
"imported_blueprints": ImportedBlueprint,
|
"imported_blueprints": ImportedBlueprint,
|
||||||
|
|
Loading…
Reference in New Issue