The Messenger: use the new region helpers (#1687)

Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
This commit is contained in:
Aaron Wagener 2023-07-22 00:45:46 -05:00 committed by GitHub
parent 889a4f4db9
commit 8405b35a94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 28 deletions

View File

@ -1,6 +1,6 @@
from typing import Set, TYPE_CHECKING, Optional, Dict
from typing import TYPE_CHECKING, Optional
from BaseClasses import Region, Location, Item, ItemClassification, Entrance, CollectionState
from BaseClasses import Region, Location, Item, ItemClassification, CollectionState
from .Constants import NOTES, PROG_ITEMS, PHOBEKINS, USEFUL_ITEMS
from .Options import Goal
from .Regions import REGIONS, SEALS, MEGA_SHARDS
@ -15,41 +15,30 @@ else:
class MessengerRegion(Region):
def __init__(self, name: str, world: MessengerWorld) -> None:
super().__init__(name, world.player, world.multiworld)
self.add_locations(self.multiworld.worlds[self.player].location_name_to_id)
world.multiworld.regions.append(self)
def add_locations(self, name_to_id: Dict[str, int]) -> None:
for loc in REGIONS[self.name]:
self.locations.append(MessengerLocation(loc, self, name_to_id.get(loc, None)))
locations = [loc for loc in REGIONS[self.name]]
if self.name == "The Shop":
if self.multiworld.goal[self.player] > Goal.option_open_music_box:
self.locations.append(MessengerLocation("Shop Chest", self, None))
self.locations += [MessengerShopLocation(f"The Shop - {shop_loc}", self,
name_to_id[f"The Shop - {shop_loc}"])
for shop_loc in SHOP_ITEMS]
self.locations += [MessengerShopLocation(figurine, self, name_to_id[figurine])
for figurine in FIGURINES]
locations.append("Shop Chest")
shop_locations = {f"The Shop - {shop_loc}": world.location_name_to_id[f"The Shop - {shop_loc}"]
for shop_loc in SHOP_ITEMS}
shop_locations.update(**{figurine: world.location_name_to_id[figurine] for figurine in FIGURINES})
self.add_locations(shop_locations, MessengerShopLocation)
elif self.name == "Tower HQ":
self.locations.append(MessengerLocation("Money Wrench", self, name_to_id["Money Wrench"]))
locations.append("Money Wrench")
if self.multiworld.shuffle_seals[self.player] and self.name in SEALS:
self.locations += [MessengerLocation(seal_loc, self, name_to_id[seal_loc])
for seal_loc in SEALS[self.name]]
locations += [seal_loc for seal_loc in SEALS[self.name]]
if self.multiworld.shuffle_shards[self.player] and self.name in MEGA_SHARDS:
self.locations += [MessengerLocation(shard, self, name_to_id[shard])
for shard in MEGA_SHARDS[self.name]]
def add_exits(self, exits: Set[str]) -> None:
for exit in exits:
ret = Entrance(self.player, f"{self.name} -> {exit}", self)
self.exits.append(ret)
ret.connect(self.multiworld.get_region(exit, self.player))
locations += [shard for shard in MEGA_SHARDS[self.name]]
loc_dict = {loc: world.location_name_to_id[loc] if loc in world.location_name_to_id else None for loc in locations}
self.add_locations(loc_dict, MessengerLocation)
world.multiworld.regions.append(self)
class MessengerLocation(Location):
game = "The Messenger"
def __init__(self, name: str, parent: MessengerRegion, loc_id: Optional[int]) -> None:
super().__init__(parent.player, name, loc_id, parent)
def __init__(self, player: int, name: str, loc_id: Optional[int], parent: MessengerRegion) -> None:
super().__init__(player, name, loc_id, parent)
if loc_id is None:
self.place_locked_item(MessengerItem(name, parent.player, None))

View File

@ -116,7 +116,8 @@ class MessengerWorld(World):
total_seals = min(len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool),
self.multiworld.total_seals[self.player].value)
if total_seals < self.total_seals:
logging.warning(f"Not enough locations for total seals setting. Adjusting to {total_seals}")
logging.warning(f"Not enough locations for total seals setting "
f"({self.multiworld.total_seals[self.player].value}). Adjusting to {total_seals}")
self.total_seals = total_seals
self.required_seals = int(self.multiworld.percent_seals_required[self.player].value / 100 * self.total_seals)