|
1 |
| -from typing import Set, TYPE_CHECKING, Optional, Dict |
| 1 | +from typing import TYPE_CHECKING, Optional |
2 | 2 |
|
3 |
| -from BaseClasses import Region, Location, Item, ItemClassification, Entrance, CollectionState |
| 3 | +from BaseClasses import Region, Location, Item, ItemClassification, CollectionState |
4 | 4 | from .Constants import NOTES, PROG_ITEMS, PHOBEKINS, USEFUL_ITEMS
|
5 | 5 | from .Options import Goal
|
6 | 6 | from .Regions import REGIONS, SEALS, MEGA_SHARDS
|
|
15 | 15 | class MessengerRegion(Region):
|
16 | 16 | def __init__(self, name: str, world: MessengerWorld) -> None:
|
17 | 17 | 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]] |
24 | 19 | if self.name == "The Shop":
|
25 | 20 | 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) |
32 | 26 | elif self.name == "Tower HQ":
|
33 |
| - self.locations.append(MessengerLocation("Money Wrench", self, name_to_id["Money Wrench"])) |
| 27 | + locations.append("Money Wrench") |
34 | 28 | 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]] |
37 | 30 | 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) |
46 | 35 |
|
47 | 36 |
|
48 | 37 | class MessengerLocation(Location):
|
49 | 38 | game = "The Messenger"
|
50 | 39 |
|
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) |
53 | 42 | if loc_id is None:
|
54 | 43 | self.place_locked_item(MessengerItem(name, parent.player, None))
|
55 | 44 |
|
|
0 commit comments