Factorio: Prevent invalid item counts in start items.
This commit is contained in:
parent
ce95ff65bd
commit
7a9f6e2a8e
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||||
from typing import Dict, Set, Tuple, List, Optional
|
from typing import Dict, Set, Tuple, List, Optional
|
||||||
|
|
||||||
from BaseClasses import MultiWorld, Item, CollectionState, Location
|
from BaseClasses import MultiWorld, Item, CollectionState, Location
|
||||||
|
from Options import Option
|
||||||
|
|
||||||
|
|
||||||
class AutoWorldRegister(type):
|
class AutoWorldRegister(type):
|
||||||
|
@ -67,7 +68,7 @@ class World(metaclass=AutoWorldRegister):
|
||||||
"""A World object encompasses a game's Items, Locations, Rules and additional data or functionality required.
|
"""A World object encompasses a game's Items, Locations, Rules and additional data or functionality required.
|
||||||
A Game should have its own subclass of World in which it defines the required data structures."""
|
A Game should have its own subclass of World in which it defines the required data structures."""
|
||||||
|
|
||||||
options: dict = {} # link your Options mapping
|
options: Dict[str, type(Option)] = {} # link your Options mapping
|
||||||
game: str # name the game
|
game: str # name the game
|
||||||
topology_present: bool = False # indicate if world type has any meaningful layout/pathing
|
topology_present: bool = False # indicate if world type has any meaningful layout/pathing
|
||||||
all_names: Set[str] = frozenset() # gets automatically populated with all item, item group and location names
|
all_names: Set[str] = frozenset() # gets automatically populated with all item, item group and location names
|
||||||
|
@ -170,9 +171,9 @@ class World(metaclass=AutoWorldRegister):
|
||||||
def get_required_client_version(self) -> Tuple[int, int, int]:
|
def get_required_client_version(self) -> Tuple[int, int, int]:
|
||||||
return 0, 1, 6
|
return 0, 1, 6
|
||||||
|
|
||||||
# end of Main.py calls
|
# end of ordered Main.py calls
|
||||||
|
|
||||||
def collect_item(self, state: CollectionState, item: Item, remove=False) -> Optional[str]:
|
def collect_item(self, state: CollectionState, item: Item, remove: bool = False) -> Optional[str]:
|
||||||
"""Collect an item name into state. For speed reasons items that aren't logically useful get skipped.
|
"""Collect an item name into state. For speed reasons items that aren't logically useful get skipped.
|
||||||
Collect None to skip item.
|
Collect None to skip item.
|
||||||
:param remove: indicate if this is meant to remove from state instead of adding."""
|
:param remove: indicate if this is meant to remove from state instead of adding."""
|
||||||
|
|
|
@ -124,6 +124,12 @@ class FactorioStartItems(OptionDict):
|
||||||
displayname = "Starting Items"
|
displayname = "Starting Items"
|
||||||
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]):
|
||||||
|
print(value)
|
||||||
|
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