AutoWorld: ensure WebWorld is instantiated, preventing an easy mistake. (#404)

This commit is contained in:
Fabian Dill 2022-04-03 19:08:50 +02:00 committed by GitHub
parent 5392b32d5c
commit 215d5e9adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -11,6 +11,8 @@ class AutoWorldRegister(type):
world_types: Dict[str, World] = {}
def __new__(cls, name: str, bases, dct: Dict[str, Any]):
if "web" in dct:
assert isinstance(dct["web"], WebWorld), "WebWorld has to be instantiated."
# filter out any events
dct["item_name_to_id"] = {name: id for name, id in dct["item_name_to_id"].items() if id}
dct["location_name_to_id"] = {name: id for name, id in dct["location_name_to_id"].items() if id}