Use OptionSet for blacklist
This commit is contained in:
parent
a15689e380
commit
efb4e5a7b3
|
@ -123,7 +123,7 @@ 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)
|
template_data["free_sample_blacklist"].update({item: 1 for item in 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)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import typing
|
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
|
from schema import Schema, Optional, And, Or
|
||||||
|
|
||||||
# schema helpers
|
# schema helpers
|
||||||
|
@ -154,17 +154,9 @@ class FactorioStartItems(ItemDict):
|
||||||
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
||||||
|
|
||||||
|
|
||||||
class FactorioFreeSampleBlacklist(OptionDict):
|
class FactorioFreeSampleBlacklist(OptionSet):
|
||||||
"""any non-zero value means that item is blacklisted from free samples. zero overrides the built-in blacklist"""
|
|
||||||
displayname = "Free Sample 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
|
||||||
|
|
Loading…
Reference in New Issue