From efb4e5a7b38da806cba309b8b89298a92eb80e33 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Thu, 2 Dec 2021 15:27:00 -0800 Subject: [PATCH] Use OptionSet for blacklist --- worlds/factorio/Mod.py | 2 +- worlds/factorio/Options.py | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/worlds/factorio/Mod.py b/worlds/factorio/Mod.py index 07c8b6ea..90580ab4 100644 --- a/worlds/factorio/Mod.py +++ b/worlds/factorio/Mod.py @@ -123,7 +123,7 @@ def generate_mod(world, output_directory: str): if getattr(multiworld, "satellite")[player].value == Options.Satellite.option_randomize_recipe: template_data["free_sample_blacklist"]["satellite"] = 1 - template_data["free_sample_blacklist"].update(multiworld.free_sample_blacklist[player].value) + template_data["free_sample_blacklist"].update({item: 1 for item in multiworld.free_sample_blacklist[player].value}) control_code = control_template.render(**template_data) data_template_code = data_template.render(**template_data) diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index a13c0e60..2da6d974 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -1,7 +1,7 @@ from __future__ import annotations import typing -from Options import Choice, OptionDict, ItemDict, Option, DefaultOnToggle, Range, DeathLink +from Options import Choice, OptionDict, OptionSet, ItemDict, Option, DefaultOnToggle, Range, DeathLink from schema import Schema, Optional, And, Or # schema helpers @@ -154,17 +154,9 @@ class FactorioStartItems(ItemDict): 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""" +class FactorioFreeSampleBlacklist(OptionSet): 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): range_end = 4