Options: verify starting inventory counts are positive for more than just Factorio

This commit is contained in:
Fabian Dill
2021-10-25 04:13:25 +02:00
parent 57831f0eba
commit 375a0ff208
2 changed files with 14 additions and 8 deletions

View File

@@ -262,6 +262,16 @@ class OptionDict(Option):
return item in self.value
class ItemDict(OptionDict):
# implemented by Generate
verify_item_name = True
def __init__(self, value: typing.Dict[str, int]):
if any(item_count < 1 for item_count in value.values()):
raise Exception("Cannot have non-positive item counts.")
super(ItemDict, self).__init__(value)
class OptionList(Option):
default = []
supports_weighting = False
@@ -357,7 +367,7 @@ class NonLocalItems(ItemSet):
displayname = "Not Local Items"
class StartInventory(OptionDict):
class StartInventory(ItemDict):
"""Start with these items."""
verify_item_name = True
displayname = "Start Inventory"