Skip to content

Commit 55b9849

Browse files
FelicitusNekoFlySniper
authored andcommitted
Bumper Stickers: add location rules (ArchipelagoMW#2254)
* bumpstik: treasure/booster location rules * bumpstik: oop missed a bit * bumpstik: apply access rule to Hazards check * bumpstik: move completion cond. to set_rules * bumpstik: tests? I have literally never written these before so 🤷 * bumpstik: oops * bumpstik: how about this? * bumpstik: fix some logic * bumpstik: this almost works but not quite * bumpstik: accurate region boundaries for BBs since we're using rules now * bumpstik: holy heck it works now
1 parent 0d1b9fa commit 55b9849

File tree

4 files changed

+59
-12
lines changed

4 files changed

+59
-12
lines changed

worlds/bumpstik/Regions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def create_regions(world: MultiWorld, player: int):
2323

2424
entrance_map = {
2525
"Level 1": lambda state:
26-
state.has("Booster Bumper", player, 2) and state.has("Treasure Bumper", player, 9),
26+
state.has("Booster Bumper", player, 1) and state.has("Treasure Bumper", player, 8),
2727
"Level 2": lambda state:
28-
state.has("Booster Bumper", player, 3) and state.has("Treasure Bumper", player, 17),
28+
state.has("Booster Bumper", player, 2) and state.has("Treasure Bumper", player, 16),
2929
"Level 3": lambda state:
30-
state.has("Booster Bumper", player, 4) and state.has("Treasure Bumper", player, 25),
30+
state.has("Booster Bumper", player, 3) and state.has("Treasure Bumper", player, 24),
3131
"Level 4": lambda state:
32-
state.has("Booster Bumper", player, 5) and state.has("Treasure Bumper", player, 33)
32+
state.has("Booster Bumper", player, 5) and state.has("Treasure Bumper", player, 32)
3333
}
3434

3535
for x, region_name in enumerate(region_map):

worlds/bumpstik/__init__.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,24 @@ def create_items(self):
108108
item_pool += self._create_item_in_quantities(
109109
name, frequencies[i])
110110

111-
item_delta = len(location_table) - len(item_pool) - 1
111+
item_delta = len(location_table) - len(item_pool)
112112
if item_delta > 0:
113113
item_pool += self._create_item_in_quantities(
114114
"Score Bonus", item_delta)
115115

116116
self.multiworld.itempool += item_pool
117117

118118
def set_rules(self):
119-
forbid_item(self.multiworld.get_location("Bonus Booster 5", self.player),
120-
"Booster Bumper", self.player)
121-
122-
def generate_basic(self):
123-
self.multiworld.get_location("Level 5 - Cleared all Hazards", self.player).place_locked_item(
124-
self.create_item(self.get_filler_item_name()))
125-
119+
for x in range(1, 32):
120+
self.multiworld.get_location(f"Treasure Bumper {x + 1}", self.player).access_rule = \
121+
lambda state, x = x: state.has("Treasure Bumper", self.player, x)
122+
for x in range(1, 5):
123+
self.multiworld.get_location(f"Bonus Booster {x + 1}", self.player).access_rule = \
124+
lambda state, x = x: state.has("Booster Bumper", self.player, x)
125+
self.multiworld.get_location("Level 5 - Cleared all Hazards", self.player).access_rule = \
126+
lambda state: state.has("Hazard Bumper", self.player, 25)
127+
126128
self.multiworld.completion_condition[self.player] = \
127129
lambda state: state.has("Booster Bumper", self.player, 5) and \
128130
state.has("Treasure Bumper", self.player, 32)
131+

worlds/bumpstik/test/TestLogic.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from . import BumpStikTestBase
2+
3+
4+
class TestRuleLogic(BumpStikTestBase):
5+
def testLogic(self):
6+
for x in range(1, 33):
7+
if x == 32:
8+
self.assertFalse(self.can_reach_location("Level 5 - Cleared all Hazards"))
9+
10+
self.collect(self.get_item_by_name("Treasure Bumper"))
11+
if x % 8 == 0:
12+
bb_count = round(x / 8)
13+
14+
if bb_count < 4:
15+
self.assertFalse(self.can_reach_location(f"Treasure Bumper {x + 1}"))
16+
elif bb_count == 4:
17+
bb_count += 1
18+
19+
for y in range(self.count("Booster Bumper"), bb_count):
20+
self.assertTrue(self.can_reach_location(f"Bonus Booster {y + 1}"),
21+
f"BB {y + 1} check not reachable with {self.count('Booster Bumper')} BBs")
22+
if y < 4:
23+
self.assertFalse(self.can_reach_location(f"Bonus Booster {y + 2}"),
24+
f"BB {y + 2} check reachable with {self.count('Treasure Bumper')} TBs")
25+
self.collect(self.get_item_by_name("Booster Bumper"))
26+
27+
if x < 31:
28+
self.assertFalse(self.can_reach_location(f"Treasure Bumper {x + 2}"))
29+
elif x == 31:
30+
self.assertFalse(self.can_reach_location("Level 5 - 50,000+ Total Points"))
31+
32+
if x < 32:
33+
self.assertTrue(self.can_reach_location(f"Treasure Bumper {x + 1}"),
34+
f"TB {x + 1} check not reachable with {self.count('Treasure Bumper')} TBs")
35+
elif x == 32:
36+
self.assertTrue(self.can_reach_location("Level 5 - 50,000+ Total Points"))
37+
self.assertFalse(self.can_reach_location("Level 5 - Cleared all Hazards"))
38+
self.collect(self.get_items_by_name("Hazard Bumper"))
39+
self.assertTrue(self.can_reach_location("Level 5 - Cleared all Hazards"))

worlds/bumpstik/test/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from test.TestBase import WorldTestBase
2+
3+
4+
class BumpStikTestBase(WorldTestBase):
5+
game = "Bumper Stickers"

0 commit comments

Comments
 (0)