Skip to content

Commit

Permalink
Rename generically-named variables
Browse files Browse the repository at this point in the history
Change variables from generic names (x, y, n) to more meaningful names, for ease of readability.
  • Loading branch information
Kappatechy committed Feb 24, 2024
1 parent 4ad3e7a commit b3ad623
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
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, 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)
for treasure_count in range(1, 33):
self.multiworld.get_location(f"Treasure Bumper {treasure_count}", self.player).access_rule = \
lambda state, treasure_held = treasure_count: state.has("Treasure Bumper", self.player, treasure_held)
for booster_count in range(1, 6):
self.multiworld.get_location(f"Bonus Booster {booster_count}", self.player).access_rule = \
lambda state, booster_held = booster_count: state.has("Booster Bumper", self.player, booster_held)
self.multiworld.get_location("Level 5 - Cleared all Hazards", self.player).access_rule = \
lambda state: state.has("Hazard Bumper", self.player, 25)

Expand Down
36 changes: 18 additions & 18 deletions worlds/bumpstik/test/TestLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@

class TestRuleLogic(BumpStikTestBase):
def testLogic(self):
for x in range(1, 33):
if x == 32:
for treasure_bumpers_held in range(1, 33):
if treasure_bumpers_held == 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 treasure_bumpers_held % 8 == 0:
bb_count = round(treasure_bumpers_held / 8)

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

self.assertTrue(self.can_reach_location(f"Treasure Bumper {x}"),
f"Treasure Bumper {x} check not reachable with {self.count('Treasure Bumper')} Treasure Bumpers")
self.assertTrue(self.can_reach_location(f"Treasure Bumper {treasure_bumpers_held}"),
f"Treasure Bumper {treasure_bumpers_held} check not reachable with {self.count('Treasure Bumper')} Treasure Bumpers")

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

0 comments on commit b3ad623

Please sign in to comment.