diff --git a/worlds/bumpstik/Regions.py b/worlds/bumpstik/Regions.py index 247d6d61a34b..6cddde882a08 100644 --- a/worlds/bumpstik/Regions.py +++ b/worlds/bumpstik/Regions.py @@ -23,13 +23,13 @@ def create_regions(world: MultiWorld, player: int): entrance_map = { "Level 1": lambda state: - state.has("Booster Bumper", player, 2) and state.has("Treasure Bumper", player, 9), + state.has("Booster Bumper", player, 1) and state.has("Treasure Bumper", player, 8), "Level 2": lambda state: - state.has("Booster Bumper", player, 3) and state.has("Treasure Bumper", player, 17), + state.has("Booster Bumper", player, 2) and state.has("Treasure Bumper", player, 16), "Level 3": lambda state: - state.has("Booster Bumper", player, 4) and state.has("Treasure Bumper", player, 25), + state.has("Booster Bumper", player, 3) and state.has("Treasure Bumper", player, 24), "Level 4": lambda state: - state.has("Booster Bumper", player, 5) and state.has("Treasure Bumper", player, 33) + state.has("Booster Bumper", player, 5) and state.has("Treasure Bumper", player, 32) } for x, region_name in enumerate(region_map): diff --git a/worlds/bumpstik/__init__.py b/worlds/bumpstik/__init__.py index 9eeb3325e38f..c4e65d07b6a9 100644 --- a/worlds/bumpstik/__init__.py +++ b/worlds/bumpstik/__init__.py @@ -108,7 +108,7 @@ def create_items(self): item_pool += self._create_item_in_quantities( name, frequencies[i]) - item_delta = len(location_table) - len(item_pool) - 1 + item_delta = len(location_table) - len(item_pool) if item_delta > 0: item_pool += self._create_item_in_quantities( "Score Bonus", item_delta) @@ -116,13 +116,16 @@ def create_items(self): self.multiworld.itempool += item_pool def set_rules(self): - forbid_item(self.multiworld.get_location("Bonus Booster 5", self.player), - "Booster Bumper", self.player) - - def generate_basic(self): - self.multiworld.get_location("Level 5 - Cleared all Hazards", self.player).place_locked_item( - self.create_item(self.get_filler_item_name())) - + for x in range(1, 32): + self.multiworld.get_location(f"Treasure Bumper {x + 1}", self.player).access_rule = \ + lambda state, x = x: state.has("Treasure Bumper", self.player, x) + for x in range(1, 5): + self.multiworld.get_location(f"Bonus Booster {x + 1}", self.player).access_rule = \ + lambda state, x = x: state.has("Booster Bumper", self.player, x) + self.multiworld.get_location("Level 5 - Cleared all Hazards", self.player).access_rule = \ + lambda state: state.has("Hazard Bumper", self.player, 25) + self.multiworld.completion_condition[self.player] = \ lambda state: state.has("Booster Bumper", self.player, 5) and \ state.has("Treasure Bumper", self.player, 32) + diff --git a/worlds/bumpstik/test/TestLogic.py b/worlds/bumpstik/test/TestLogic.py new file mode 100644 index 000000000000..e374b7b1e999 --- /dev/null +++ b/worlds/bumpstik/test/TestLogic.py @@ -0,0 +1,39 @@ +from . import BumpStikTestBase + + +class TestRuleLogic(BumpStikTestBase): + def testLogic(self): + for x in range(1, 33): + if x == 32: + self.assertFalse(self.can_reach_location("Level 5 - Cleared all Hazards")) + + self.collect(self.get_item_by_name("Treasure Bumper")) + if x % 8 == 0: + bb_count = round(x / 8) + + if bb_count < 4: + self.assertFalse(self.can_reach_location(f"Treasure Bumper {x + 1}")) + elif bb_count == 4: + bb_count += 1 + + for y in range(self.count("Booster Bumper"), bb_count): + self.assertTrue(self.can_reach_location(f"Bonus Booster {y + 1}"), + f"BB {y + 1} check not reachable with {self.count('Booster Bumper')} BBs") + if y < 4: + self.assertFalse(self.can_reach_location(f"Bonus Booster {y + 2}"), + f"BB {y + 2} check reachable with {self.count('Treasure Bumper')} TBs") + self.collect(self.get_item_by_name("Booster Bumper")) + + if x < 31: + self.assertFalse(self.can_reach_location(f"Treasure Bumper {x + 2}")) + elif x == 31: + self.assertFalse(self.can_reach_location("Level 5 - 50,000+ Total Points")) + + if x < 32: + self.assertTrue(self.can_reach_location(f"Treasure Bumper {x + 1}"), + f"TB {x + 1} check not reachable with {self.count('Treasure Bumper')} TBs") + elif x == 32: + self.assertTrue(self.can_reach_location("Level 5 - 50,000+ Total Points")) + self.assertFalse(self.can_reach_location("Level 5 - Cleared all Hazards")) + self.collect(self.get_items_by_name("Hazard Bumper")) + self.assertTrue(self.can_reach_location("Level 5 - Cleared all Hazards")) diff --git a/worlds/bumpstik/test/__init__.py b/worlds/bumpstik/test/__init__.py new file mode 100644 index 000000000000..1199d7b8e506 --- /dev/null +++ b/worlds/bumpstik/test/__init__.py @@ -0,0 +1,5 @@ +from test.TestBase import WorldTestBase + + +class BumpStikTestBase(WorldTestBase): + game = "Bumper Stickers"