Bumper Stickers: add location rules (#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
This commit is contained in:
parent
be959c05a6
commit
e5ca83b5db
|
@ -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):
|
||||
|
|
|
@ -108,7 +108,7 @@ class BumpStikWorld(World):
|
|||
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 @@ class BumpStikWorld(World):
|
|||
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)
|
||||
|
||||
|
|
|
@ -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"))
|
|
@ -0,0 +1,5 @@
|
|||
from test.TestBase import WorldTestBase
|
||||
|
||||
|
||||
class BumpStikTestBase(WorldTestBase):
|
||||
game = "Bumper Stickers"
|
Loading…
Reference in New Issue