The Messenger: use the new region helpers (#1687)
Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
This commit is contained in:
parent
889a4f4db9
commit
8405b35a94
|
@ -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 .Constants import NOTES, PROG_ITEMS, PHOBEKINS, USEFUL_ITEMS
|
||||||
from .Options import Goal
|
from .Options import Goal
|
||||||
from .Regions import REGIONS, SEALS, MEGA_SHARDS
|
from .Regions import REGIONS, SEALS, MEGA_SHARDS
|
||||||
|
@ -15,41 +15,30 @@ else:
|
||||||
class MessengerRegion(Region):
|
class MessengerRegion(Region):
|
||||||
def __init__(self, name: str, world: MessengerWorld) -> None:
|
def __init__(self, name: str, world: MessengerWorld) -> None:
|
||||||
super().__init__(name, world.player, world.multiworld)
|
super().__init__(name, world.player, world.multiworld)
|
||||||
self.add_locations(self.multiworld.worlds[self.player].location_name_to_id)
|
locations = [loc for loc in REGIONS[self.name]]
|
||||||
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)))
|
|
||||||
if self.name == "The Shop":
|
if self.name == "The Shop":
|
||||||
if self.multiworld.goal[self.player] > Goal.option_open_music_box:
|
if self.multiworld.goal[self.player] > Goal.option_open_music_box:
|
||||||
self.locations.append(MessengerLocation("Shop Chest", self, None))
|
locations.append("Shop Chest")
|
||||||
self.locations += [MessengerShopLocation(f"The Shop - {shop_loc}", self,
|
shop_locations = {f"The Shop - {shop_loc}": world.location_name_to_id[f"The Shop - {shop_loc}"]
|
||||||
name_to_id[f"The Shop - {shop_loc}"])
|
for shop_loc in SHOP_ITEMS}
|
||||||
for shop_loc in SHOP_ITEMS]
|
shop_locations.update(**{figurine: world.location_name_to_id[figurine] for figurine in FIGURINES})
|
||||||
self.locations += [MessengerShopLocation(figurine, self, name_to_id[figurine])
|
self.add_locations(shop_locations, MessengerShopLocation)
|
||||||
for figurine in FIGURINES]
|
|
||||||
elif self.name == "Tower HQ":
|
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:
|
if self.multiworld.shuffle_seals[self.player] and self.name in SEALS:
|
||||||
self.locations += [MessengerLocation(seal_loc, self, name_to_id[seal_loc])
|
locations += [seal_loc for seal_loc in SEALS[self.name]]
|
||||||
for seal_loc in SEALS[self.name]]
|
|
||||||
if self.multiworld.shuffle_shards[self.player] and self.name in MEGA_SHARDS:
|
if self.multiworld.shuffle_shards[self.player] and self.name in MEGA_SHARDS:
|
||||||
self.locations += [MessengerLocation(shard, self, name_to_id[shard])
|
locations += [shard for shard in MEGA_SHARDS[self.name]]
|
||||||
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)
|
||||||
def add_exits(self, exits: Set[str]) -> None:
|
world.multiworld.regions.append(self)
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
class MessengerLocation(Location):
|
class MessengerLocation(Location):
|
||||||
game = "The Messenger"
|
game = "The Messenger"
|
||||||
|
|
||||||
def __init__(self, name: str, parent: MessengerRegion, loc_id: Optional[int]) -> None:
|
def __init__(self, player: int, name: str, loc_id: Optional[int], parent: MessengerRegion) -> None:
|
||||||
super().__init__(parent.player, name, loc_id, parent)
|
super().__init__(player, name, loc_id, parent)
|
||||||
if loc_id is None:
|
if loc_id is None:
|
||||||
self.place_locked_item(MessengerItem(name, parent.player, None))
|
self.place_locked_item(MessengerItem(name, parent.player, None))
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,8 @@ class MessengerWorld(World):
|
||||||
total_seals = min(len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool),
|
total_seals = min(len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool),
|
||||||
self.multiworld.total_seals[self.player].value)
|
self.multiworld.total_seals[self.player].value)
|
||||||
if total_seals < self.total_seals:
|
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.total_seals = total_seals
|
||||||
self.required_seals = int(self.multiworld.percent_seals_required[self.player].value / 100 * self.total_seals)
|
self.required_seals = int(self.multiworld.percent_seals_required[self.player].value / 100 * self.total_seals)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue