Skip to content

Commit 283badf

Browse files
authored
SoE: add apworld manifest (#5557)
* SoE: add APWorld manifest * SoE: small typing fixes
1 parent 088f2cc commit 283badf

File tree

6 files changed

+75
-5
lines changed

6 files changed

+75
-5
lines changed

worlds/soe/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from BaseClasses import MultiWorld, CollectionState
2121

2222
__all__ = ["pyevermizer", "SoEWorld"]
23-
23+
__version__ = "0.50.1"
24+
__author__ = "black-sliver"
2425

2526
"""
2627
In evermizer:
@@ -461,7 +462,7 @@ def generate_output(self, output_directory: str) -> None:
461462
except FileNotFoundError:
462463
pass
463464

464-
def modify_multidata(self, multidata: typing.Dict[str, typing.Any]) -> None:
465+
def modify_multidata(self, multidata: typing.Mapping[str, typing.Any]) -> None:
465466
# wait for self.connect_name to be available.
466467
self.connect_name_available_event.wait()
467468
# we skip in case of error, so that the original error in the output thread is the one that gets raised

worlds/soe/archipelago.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"game": "Secret of Evermore",
3+
"authors": [
4+
"black-sliver"
5+
],
6+
"world_version": "0.50.1",
7+
"minimum_ap_version": "0.4.2"
8+
}

worlds/soe/logic.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@
1616
# Logic.items are all items and extra items excluding non-progression items and duplicates
1717
# NOTE: we are skipping sniff items here because none of them is supposed to provide progression
1818
item_names: Set[str] = set()
19-
items = [item for item in filter(lambda item: item.progression, # type: ignore[arg-type]
20-
chain(pyevermizer.get_items(), pyevermizer.get_extra_items()))
21-
if item.name not in item_names and not item_names.add(item.name)] # type: ignore[func-returns-value]
19+
items = [
20+
item
21+
for item in filter(
22+
lambda item: item.progression,
23+
chain(pyevermizer.get_items(), pyevermizer.get_extra_items()),
24+
)
25+
if item.name not in item_names and not item_names.add(item.name) # type: ignore[func-returns-value]
26+
]
2227

2328

2429
class SoEPlayerLogic:

worlds/soe/test/test_manifest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import json
2+
from pathlib import Path
3+
from unittest import TestCase, skipUnless
4+
5+
6+
@skipUnless((Path(__file__).parent.parent / "tools" / "make_manifest.py").exists(), "Packaged without tools")
7+
class ManifestTest(TestCase):
8+
def test_manifest_is_up_to_date(self) -> None:
9+
from ..tools.make_manifest import make_manifest
10+
11+
expected_manifest = make_manifest()
12+
with (Path(__file__).parent.parent / "archipelago.json").open("r", encoding="utf-8") as f:
13+
actual_manifest = json.load(f)
14+
self.assertEqual(actual_manifest, expected_manifest, "Manifest is not up to date")

worlds/soe/tools/__init__.py

Whitespace-only changes.

worlds/soe/tools/make_manifest.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Create archipelago.json manifest file. Run as `python -m worlds.soe.tools.make_manifest`."""
2+
3+
import json
4+
from importlib.metadata import metadata
5+
from pathlib import Path
6+
from typing import Any
7+
8+
from .. import SoEWorld, __version__ as world_version, __author__ as world_author
9+
10+
11+
__all__ = ["make_manifest"]
12+
13+
14+
def make_manifest() -> dict[str, Any]:
15+
"""
16+
Generate and return manifest dict for the Secret of Evermore APWorld.
17+
18+
The world version is supposed to be equal to the pyevermizer version, but we may have to break that in the future
19+
if we ever do a breaking change to the world after we are >= 1.0.0, or we release multiple versions of the APWorld
20+
for a single pyevermizer version.
21+
"""
22+
meta = metadata("pyevermizer")
23+
version = meta["Version"]
24+
authors = list(dict.fromkeys(map(str.rstrip, (world_author + "," + meta["Author"]).split(","))))
25+
assert world_version == version, f"Expected world version ({world_version}) == pyevermizer version ({version})."
26+
27+
return {
28+
"game": SoEWorld.game,
29+
"authors": authors,
30+
"world_version": world_version,
31+
"minimum_ap_version": "0.4.2", # introduction of settings API
32+
}
33+
34+
35+
if __name__ == "__main__":
36+
assert SoEWorld.__file__, "Could not determine world source."
37+
module_dir = Path(SoEWorld.__file__).parent
38+
assert module_dir.is_dir(), f"{module_dir} is not a directory"
39+
manifest_path = module_dir / "archipelago.json"
40+
41+
with manifest_path.open("w", encoding="utf-8") as f:
42+
json.dump(make_manifest(), f, indent=4)

0 commit comments

Comments
 (0)