Skip to content
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

Bumper Stickers: add location rules #2254

Merged
merged 12 commits into from
Oct 25, 2023
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, 33):
self.multiworld.get_location(f"Treasure Bumper {x}", self.player).access_rule = \
lambda state, x = x: state.has("Treasure Bumper", self.player, x)
for x in range(1, 6):
self.multiworld.get_location(f"Bonus Booster {x}", 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)

23 changes: 23 additions & 0 deletions worlds/bumpstik/test/TestLogic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from . import BumpStikTestBase


class TestRuleLogic(BumpStikTestBase):
def testTreasures(self):
locations = ["Treasure Bumper 4"]
items = [["Treasure Bumper" for _ in range(4)]]
self.assertAccessDependency(locations, items)

def testTreasuresLv2(self):
locations = ["Treasure Bumper 12"]
items = [["Treasure Bumper" for _ in range(12)] +
["Bonus Booster" for _ in range(2)]]
self.assertAccessDependency(locations, items)

def testLevels(self):
landmarks = [f"Level {x} - Combo 5" for x in range(2, 5)] + \
["Level 5 - Cleared all Hazards"]
for x, landmark in enumerate(landmarks):
locations = [landmark]
items = [["Treasure Bumper" for _ in range(x * 8)] +
["Bonus Booster" for _ in range(x + 1)]]
self.assertAccessDependency(locations, items)
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"
Loading