Compare commits

...

2 Commits

Author SHA1 Message Date
Fabian Dill
4691ef8b64 Update AutoWorld.py 2023-03-16 14:42:29 +01:00
Fabian Dill
cd218c15b3 AutoWorld: optional version requirement system 2023-03-14 17:34:41 +01:00

View File

@@ -13,10 +13,26 @@ if TYPE_CHECKING:
from BaseClasses import MultiWorld, Item, Location, Tutorial from BaseClasses import MultiWorld, Item, Location, Tutorial
class WorldVersionIncompatible(Exception):
pass
class AutoWorldRegister(type): class AutoWorldRegister(type):
world_types: Dict[str, Type[World]] = {} world_types: Dict[str, Type[World]] = {}
def __new__(mcs, name: str, bases: Tuple[type, ...], dct: Dict[str, Any]) -> AutoWorldRegister: def __new__(mcs, name: str, bases: Tuple[type, ...], dct: Dict[str, Any]) -> AutoWorldRegister:
if dct.get("required_archipelago_version", None):
from Utils import version_tuple
if dct["required_archipelago_version"] > version_tuple:
raise WorldVersionIncompatible(
f"World {name} for game {dct.get('game', None)} "
f"requires Archipelago {dct['required_archipelago_version']}, but this is {version_tuple}")
if dct.get("highest_archipelago_version", None):
from Utils import version_tuple
if version_tuple > dct["highest_archipelago_version"]:
raise WorldVersionIncompatible(
f"World {name} for {dct.get('game', None)} "
f"supports Archipelago up to {dct['highest_archipelago_version']}, but this is {version_tuple}")
if "web" in dct: if "web" in dct:
assert isinstance(dct["web"], WebWorld), "WebWorld has to be instantiated." assert isinstance(dct["web"], WebWorld), "WebWorld has to be instantiated."
# filter out any events # filter out any events
@@ -169,6 +185,14 @@ class World(metaclass=AutoWorldRegister):
required_server_version: Tuple[int, int, int] = (0, 2, 4) required_server_version: Tuple[int, int, int] = (0, 2, 4)
"""update this if the resulting multidata breaks forward-compatibility of the server""" """update this if the resulting multidata breaks forward-compatibility of the server"""
required_archipelago_version: ClassVar[Optional[Tuple[int, int, int]]] = None
"""Optional. Enter the minimum required Archipelago version that can use this world.
Typically for version checking when distributing as apworld."""
highest_archipelago_version: ClassVar[Optional[Tuple[int, int, int]]] = None
"""Optional. Enter the highest Archipelago version that can use this world.
Typically for version checking when distributing as apworld."""
hint_blacklist: ClassVar[FrozenSet[str]] = frozenset() hint_blacklist: ClassVar[FrozenSet[str]] = frozenset()
"""any names that should not be hintable""" """any names that should not be hintable"""