diff --git a/worlds/soe/__init__.py b/worlds/soe/__init__.py index 161c749fd6..8de83da7ea 100644 --- a/worlds/soe/__init__.py +++ b/worlds/soe/__init__.py @@ -20,7 +20,8 @@ if typing.TYPE_CHECKING: from BaseClasses import MultiWorld, CollectionState __all__ = ["pyevermizer", "SoEWorld"] - +__version__ = "0.50.1" +__author__ = "black-sliver" """ In evermizer: @@ -461,7 +462,7 @@ class SoEWorld(World): except FileNotFoundError: pass - def modify_multidata(self, multidata: typing.Dict[str, typing.Any]) -> None: + def modify_multidata(self, multidata: typing.Mapping[str, typing.Any]) -> None: # wait for self.connect_name to be available. self.connect_name_available_event.wait() # we skip in case of error, so that the original error in the output thread is the one that gets raised diff --git a/worlds/soe/archipelago.json b/worlds/soe/archipelago.json new file mode 100644 index 0000000000..5a3ca8353e --- /dev/null +++ b/worlds/soe/archipelago.json @@ -0,0 +1,8 @@ +{ + "game": "Secret of Evermore", + "authors": [ + "black-sliver" + ], + "world_version": "0.50.1", + "minimum_ap_version": "0.4.2" +} \ No newline at end of file diff --git a/worlds/soe/logic.py b/worlds/soe/logic.py index 92ffb14b3f..30633d2fcc 100644 --- a/worlds/soe/logic.py +++ b/worlds/soe/logic.py @@ -16,9 +16,14 @@ rules = pyevermizer.get_logic() # Logic.items are all items and extra items excluding non-progression items and duplicates # NOTE: we are skipping sniff items here because none of them is supposed to provide progression item_names: Set[str] = set() -items = [item for item in filter(lambda item: item.progression, # type: ignore[arg-type] - chain(pyevermizer.get_items(), pyevermizer.get_extra_items())) - if item.name not in item_names and not item_names.add(item.name)] # type: ignore[func-returns-value] +items = [ + item + for item in filter( + lambda item: item.progression, + chain(pyevermizer.get_items(), pyevermizer.get_extra_items()), + ) + if item.name not in item_names and not item_names.add(item.name) # type: ignore[func-returns-value] +] class SoEPlayerLogic: diff --git a/worlds/soe/test/test_manifest.py b/worlds/soe/test/test_manifest.py new file mode 100644 index 0000000000..64dfbdf8c8 --- /dev/null +++ b/worlds/soe/test/test_manifest.py @@ -0,0 +1,14 @@ +import json +from pathlib import Path +from unittest import TestCase, skipUnless + + +@skipUnless((Path(__file__).parent.parent / "tools" / "make_manifest.py").exists(), "Packaged without tools") +class ManifestTest(TestCase): + def test_manifest_is_up_to_date(self) -> None: + from ..tools.make_manifest import make_manifest + + expected_manifest = make_manifest() + with (Path(__file__).parent.parent / "archipelago.json").open("r", encoding="utf-8") as f: + actual_manifest = json.load(f) + self.assertEqual(actual_manifest, expected_manifest, "Manifest is not up to date") diff --git a/worlds/soe/tools/__init__.py b/worlds/soe/tools/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/worlds/soe/tools/make_manifest.py b/worlds/soe/tools/make_manifest.py new file mode 100644 index 0000000000..34e9c42b05 --- /dev/null +++ b/worlds/soe/tools/make_manifest.py @@ -0,0 +1,42 @@ +"""Create archipelago.json manifest file. Run as `python -m worlds.soe.tools.make_manifest`.""" + +import json +from importlib.metadata import metadata +from pathlib import Path +from typing import Any + +from .. import SoEWorld, __version__ as world_version, __author__ as world_author + + +__all__ = ["make_manifest"] + + +def make_manifest() -> dict[str, Any]: + """ + Generate and return manifest dict for the Secret of Evermore APWorld. + + The world version is supposed to be equal to the pyevermizer version, but we may have to break that in the future + if we ever do a breaking change to the world after we are >= 1.0.0, or we release multiple versions of the APWorld + for a single pyevermizer version. + """ + meta = metadata("pyevermizer") + version = meta["Version"] + authors = list(dict.fromkeys(map(str.rstrip, (world_author + "," + meta["Author"]).split(",")))) + assert world_version == version, f"Expected world version ({world_version}) == pyevermizer version ({version})." + + return { + "game": SoEWorld.game, + "authors": authors, + "world_version": world_version, + "minimum_ap_version": "0.4.2", # introduction of settings API + } + + +if __name__ == "__main__": + assert SoEWorld.__file__, "Could not determine world source." + module_dir = Path(SoEWorld.__file__).parent + assert module_dir.is_dir(), f"{module_dir} is not a directory" + manifest_path = module_dir / "archipelago.json" + + with manifest_path.open("w", encoding="utf-8") as f: + json.dump(make_manifest(), f, indent=4)