Skip to content

Commit f40fb11

Browse files
alwaysintrebleBerserker66
authored andcommitted
The Messenger: use the new region helpers (ArchipelagoMW#1687)
Co-authored-by: Fabian Dill <[email protected]>
1 parent ed02f7e commit f40fb11

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

worlds/messenger/SubClasses.py

+16-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Set, TYPE_CHECKING, Optional, Dict
1+
from typing import TYPE_CHECKING, Optional
22

3-
from BaseClasses import Region, Location, Item, ItemClassification, Entrance, CollectionState
3+
from BaseClasses import Region, Location, Item, ItemClassification, CollectionState
44
from .Constants import NOTES, PROG_ITEMS, PHOBEKINS, USEFUL_ITEMS
55
from .Options import Goal
66
from .Regions import REGIONS, SEALS, MEGA_SHARDS
@@ -15,41 +15,30 @@
1515
class MessengerRegion(Region):
1616
def __init__(self, name: str, world: MessengerWorld) -> None:
1717
super().__init__(name, world.player, world.multiworld)
18-
self.add_locations(self.multiworld.worlds[self.player].location_name_to_id)
19-
world.multiworld.regions.append(self)
20-
21-
def add_locations(self, name_to_id: Dict[str, int]) -> None:
22-
for loc in REGIONS[self.name]:
23-
self.locations.append(MessengerLocation(loc, self, name_to_id.get(loc, None)))
18+
locations = [loc for loc in REGIONS[self.name]]
2419
if self.name == "The Shop":
2520
if self.multiworld.goal[self.player] > Goal.option_open_music_box:
26-
self.locations.append(MessengerLocation("Shop Chest", self, None))
27-
self.locations += [MessengerShopLocation(f"The Shop - {shop_loc}", self,
28-
name_to_id[f"The Shop - {shop_loc}"])
29-
for shop_loc in SHOP_ITEMS]
30-
self.locations += [MessengerShopLocation(figurine, self, name_to_id[figurine])
31-
for figurine in FIGURINES]
21+
locations.append("Shop Chest")
22+
shop_locations = {f"The Shop - {shop_loc}": world.location_name_to_id[f"The Shop - {shop_loc}"]
23+
for shop_loc in SHOP_ITEMS}
24+
shop_locations.update(**{figurine: world.location_name_to_id[figurine] for figurine in FIGURINES})
25+
self.add_locations(shop_locations, MessengerShopLocation)
3226
elif self.name == "Tower HQ":
33-
self.locations.append(MessengerLocation("Money Wrench", self, name_to_id["Money Wrench"]))
27+
locations.append("Money Wrench")
3428
if self.multiworld.shuffle_seals[self.player] and self.name in SEALS:
35-
self.locations += [MessengerLocation(seal_loc, self, name_to_id[seal_loc])
36-
for seal_loc in SEALS[self.name]]
29+
locations += [seal_loc for seal_loc in SEALS[self.name]]
3730
if self.multiworld.shuffle_shards[self.player] and self.name in MEGA_SHARDS:
38-
self.locations += [MessengerLocation(shard, self, name_to_id[shard])
39-
for shard in MEGA_SHARDS[self.name]]
40-
41-
def add_exits(self, exits: Set[str]) -> None:
42-
for exit in exits:
43-
ret = Entrance(self.player, f"{self.name} -> {exit}", self)
44-
self.exits.append(ret)
45-
ret.connect(self.multiworld.get_region(exit, self.player))
31+
locations += [shard for shard in MEGA_SHARDS[self.name]]
32+
loc_dict = {loc: world.location_name_to_id[loc] if loc in world.location_name_to_id else None for loc in locations}
33+
self.add_locations(loc_dict, MessengerLocation)
34+
world.multiworld.regions.append(self)
4635

4736

4837
class MessengerLocation(Location):
4938
game = "The Messenger"
5039

51-
def __init__(self, name: str, parent: MessengerRegion, loc_id: Optional[int]) -> None:
52-
super().__init__(parent.player, name, loc_id, parent)
40+
def __init__(self, player: int, name: str, loc_id: Optional[int], parent: MessengerRegion) -> None:
41+
super().__init__(player, name, loc_id, parent)
5342
if loc_id is None:
5443
self.place_locked_item(MessengerItem(name, parent.player, None))
5544

worlds/messenger/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def create_items(self) -> None:
116116
total_seals = min(len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool),
117117
self.multiworld.total_seals[self.player].value)
118118
if total_seals < self.total_seals:
119-
logging.warning(f"Not enough locations for total seals setting. Adjusting to {total_seals}")
119+
logging.warning(f"Not enough locations for total seals setting "
120+
f"({self.multiworld.total_seals[self.player].value}). Adjusting to {total_seals}")
120121
self.total_seals = total_seals
121122
self.required_seals = int(self.multiworld.percent_seals_required[self.player].value / 100 * self.total_seals)
122123

0 commit comments

Comments
 (0)