newstyle DataPackage. Both versions in merged format for compatibility for now.

This commit is contained in:
Fabian Dill
2021-07-12 18:05:46 +02:00
parent 50a21fbd74
commit f456dba993
9 changed files with 60 additions and 38 deletions

View File

@@ -9,6 +9,8 @@ class AutoWorldRegister(type):
def __new__(cls, name, bases, dct):
dct["all_names"] = dct["item_names"] | dct["location_names"] | set(dct.get("item_name_groups", {}))
dct["item_id_to_name"] = {code: name for name, code in dct["item_name_to_id"].items()}
dct["location_id_to_name"] = {code: name for name, code in dct["location_name_to_id"].items()}
new_class = super().__new__(cls, name, bases, dct)
if "game" in dct:
AutoWorldRegister.world_types[dct["game"]] = new_class
@@ -39,6 +41,16 @@ class World(metaclass=AutoWorldRegister):
location_names: Set[str] = frozenset() # set of all potential location names
all_names: Set[str] = frozenset() # gets automatically populated with all item, item group and location names
# map names to their IDs
item_name_to_id: Dict[str, int] = {}
location_name_to_id: Dict[str, int] = {}
# reverse, automatically generated
item_id_to_name: Dict[int, str] = {}
location_id_to_name: Dict[int, str] = {}
data_version = 1 # increment this every time something in your world's names/id mappings changes.
hint_blacklist: Set[str] = frozenset() # any names that should not be hintable
def __init__(self, world: MultiWorld, player: int):