Skip to content

Bumper Stickers - logic fixes for "off-by-one" errors #2855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions worlds/bumpstik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ def create_items(self):
self.multiworld.itempool += item_pool

def set_rules(self):
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)
for x in range(1, 33):
self.multiworld.get_location(f"Treasure Bumper {x}", self.player).access_rule = \
lambda state, n = x: state.has("Treasure Bumper", self.player, n)
for x in range(1, 6):
self.multiworld.get_location(f"Bonus Booster {x}", self.player).access_rule = \
lambda state, n = x: state.has("Booster Bumper", self.player, n)
self.multiworld.get_location("Level 5 - Cleared all Hazards", self.player).access_rule = \
lambda state: state.has("Hazard Bumper", self.player, 25)

Expand Down
28 changes: 15 additions & 13 deletions worlds/bumpstik/test/TestLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ def testLogic(self):

if bb_count < 4:
self.assertFalse(self.can_reach_location(f"Treasure Bumper {x + 1}"))
# Can't reach Treasure Bumper 9 check until level 2 is unlocked, etc.
# But we don't have enough Treasure Bumpers to reach this check anyway??
elif bb_count == 4:
bb_count += 1
# Level 4 has two new Bonus Booster checks; need to check both

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"))
for y in range(self.count("Booster Bumper"), bb_count + 1):
if y > 0:
self.assertTrue(self.can_reach_location(f"Bonus Booster {y}"),
f"Bonus Booster {y} check not reachable with {self.count('Booster Bumper')} Booster Bumpers")
if y < 5:
self.assertFalse(self.can_reach_location(f"Bonus Booster {y + 1}"),
f"Bonus Booster {y + 1} check reachable with {self.count('Treasure Bumper')} Treasure Bumpers and {self.count('Booster Bumper')} Booster Bumpers")
if y < bb_count:
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"))
self.assertTrue(self.can_reach_location(f"Treasure Bumper {x}"),
f"Treasure Bumper {x} check not reachable with {self.count('Treasure Bumper')} Treasure Bumpers")

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")
self.assertFalse(self.can_reach_location(f"Treasure Bumper {x + 1}"))
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"))
Expand Down