From 3fba94f000b3d19021f6936af4020286455313fe Mon Sep 17 00:00:00 2001 From: Aaron Wagener Date: Thu, 29 Jun 2023 07:33:37 -0500 Subject: [PATCH] The Messenger: strip generated filler items for a sufficiently small pool (#1907) * The Messenger: strip generated filler items for a sufficiently small remaining item pool * rewrite the test for the small chance there's no large currency shards --- worlds/messenger/__init__.py | 19 +++++++++---------- worlds/messenger/test/TestShop.py | 10 ++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/worlds/messenger/__init__.py b/worlds/messenger/__init__.py index a29a6936a900..8cefdcc9108d 100644 --- a/worlds/messenger/__init__.py +++ b/worlds/messenger/__init__.py @@ -49,17 +49,14 @@ class MessengerWorld(World): base_offset = 0xADD_000 item_name_to_id = {item: item_id for item_id, item in enumerate(ALL_ITEMS, base_offset)} - seal_locs = [seal for seals in SEALS.values() for seal in seals] - mega_shard_locs = [shard for shards in MEGA_SHARDS.values() for shard in shards] - shop_locs = [f"The Shop - {shop_loc}" for shop_loc in SHOP_ITEMS] location_name_to_id = {location: location_id for location_id, location in enumerate([ *ALWAYS_LOCATIONS, - *seal_locs, - *mega_shard_locs, + *[seal for seals in SEALS.values() for seal in seals], + *[shard for shards in MEGA_SHARDS.values() for shard in shards], *BOSS_LOCATIONS, - *shop_locs, + *[f"The Shop - {shop_loc}" for shop_loc in SHOP_ITEMS], *FIGURINES, "Money Wrench", ], base_offset)} @@ -127,13 +124,15 @@ def create_items(self) -> None: for i in range(self.required_seals): seals[i].classification = ItemClassification.progression_skip_balancing itempool += seals - + + remaining_fill = len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool) + filler_pool = dict(list(FILLER.items())[2:]) if remaining_fill < 10 else FILLER itempool += [self.create_item(filler_item) for filler_item in self.multiworld.random.choices( - list(FILLER), - weights=list(FILLER.values()), - k=len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool) + list(filler_pool), + weights=list(filler_pool.values()), + k=remaining_fill )] self.multiworld.itempool += itempool diff --git a/worlds/messenger/test/TestShop.py b/worlds/messenger/test/TestShop.py index cad414e0b7ae..dcc750f6ad21 100644 --- a/worlds/messenger/test/TestShop.py +++ b/worlds/messenger/test/TestShop.py @@ -16,6 +16,7 @@ def testShopRules(self) -> None: with self.subTest("has cost", loc=loc): self.assertFalse(self.can_reach_location(loc)) + def testShopPrices(self) -> None: prices: Dict[str, int] = self.multiworld.worlds[self.player].shop_prices for loc, price in prices.items(): with self.subTest("prices", loc=loc): @@ -48,6 +49,15 @@ class ShopCostMinTest(ShopCostTest): "shop_price": "random", "shuffle_seals": "false", } + + def testShopRules(self) -> None: + if self.multiworld.worlds[self.player].total_shards: + super().testShopRules() + else: + for loc in SHOP_ITEMS: + loc = f"The Shop - {loc}" + with self.subTest("has cost", loc=loc): + self.assertTrue(self.can_reach_location(loc)) def testDBoost(self) -> None: pass