Options: verify starting inventory counts are positive for more than just Factorio
This commit is contained in:
parent
57831f0eba
commit
375a0ff208
12
Options.py
12
Options.py
|
@ -262,6 +262,16 @@ class OptionDict(Option):
|
||||||
return item in self.value
|
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):
|
class OptionList(Option):
|
||||||
default = []
|
default = []
|
||||||
supports_weighting = False
|
supports_weighting = False
|
||||||
|
@ -357,7 +367,7 @@ class NonLocalItems(ItemSet):
|
||||||
displayname = "Not Local Items"
|
displayname = "Not Local Items"
|
||||||
|
|
||||||
|
|
||||||
class StartInventory(OptionDict):
|
class StartInventory(ItemDict):
|
||||||
"""Start with these items."""
|
"""Start with these items."""
|
||||||
verify_item_name = True
|
verify_item_name = True
|
||||||
displayname = "Start Inventory"
|
displayname = "Start Inventory"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from Options import Choice, OptionDict, Option, DefaultOnToggle, Range
|
from Options import Choice, OptionDict, ItemDict, Option, DefaultOnToggle, Range
|
||||||
from schema import Schema, Optional, And, Or
|
from schema import Schema, Optional, And, Or
|
||||||
|
|
||||||
# schema helpers
|
# schema helpers
|
||||||
|
@ -120,15 +120,11 @@ class RecipeIngredients(Choice):
|
||||||
option_science_pack = 1
|
option_science_pack = 1
|
||||||
|
|
||||||
|
|
||||||
class FactorioStartItems(OptionDict):
|
class FactorioStartItems(ItemDict):
|
||||||
displayname = "Starting Items"
|
displayname = "Starting Items"
|
||||||
|
verify_item_name = False
|
||||||
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
||||||
|
|
||||||
def __init__(self, value: typing.Dict[str, typing.Any]):
|
|
||||||
if any(item_count < 1 for item_count in value.values()):
|
|
||||||
raise Exception("Cannot have non-positive item counts.")
|
|
||||||
super().__init__(value)
|
|
||||||
|
|
||||||
|
|
||||||
class TrapCount(Range):
|
class TrapCount(Range):
|
||||||
range_end = 4
|
range_end = 4
|
||||||
|
|
Loading…
Reference in New Issue