Skip to content

Bumper Stickers: add location rules #2254

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 12 commits into from
Oct 25, 2023
8 changes: 4 additions & 4 deletions worlds/bumpstik/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 11 additions & 8 deletions worlds/bumpstik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,24 @@ 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)

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)

39 changes: 39 additions & 0 deletions worlds/bumpstik/test/TestLogic.py
Original file line number Diff line number Diff line change
@@ -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"))
5 changes: 5 additions & 0 deletions worlds/bumpstik/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from test.TestBase import WorldTestBase


class BumpStikTestBase(WorldTestBase):
game = "Bumper Stickers"