Archipelago/worlds/bumpstik/test/TestLogic.py

42 lines
2.6 KiB
Python
Raw Normal View History

from . import BumpStikTestBase
class TestRuleLogic(BumpStikTestBase):
def testLogic(self):
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
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"))
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
if treasure_bumpers_held % 8 == 0:
bb_count = round(treasure_bumpers_held / 8)
if bb_count < 4:
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
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
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
# Level 4 has two new Bonus Booster checks; need to check both
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
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"))
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
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")
Bumper Stickers: logic fixes for "off-by-one" errors (#2855) * Corrected logic error. Per discussion here: https://discord.com/channels/731205301247803413/1148330200891932742/1192138309120577646 At the moment, the logic expects Treasure Bumper 2 to require 1 bumper, Treasure Bumper 3 to require 2, etc., and for Treasure Bumper 1 to be in Sphere 1. This is incorrect, each Bumper check should require 1 Bumper item of it's type. This corrects that. I've verified I was able to generate with it by editing my apworld locally, but I'm also not a programmer and don't know anything about tests. However, I'd think this is a simple change. * Correct logic in Bumper Sticker unit tests Off By One errors were rampant in the Bumper Stickers unit test logic. This should correct those errors. * Correct use of "range" function The function setting the access rules for Treasure and Booster Bumpers was stopping one short of being applied to all the related locations. This has been corrected. * Restoring and clarifying designer's original level access intent The original creator of the AP version of Bumper Stickers intentionally set the Treasure Bumper requirements to logically reach each level 1 higher than the actual game requires, and logic tests were built based on this. This design decision has now been restored. * Revert "Restoring and clarifying designer's original level access intent" This reverts commit 5186c5fcc3229a60569cdb96d774d4ccac721a06. * Correct test logic for level 5 While 33 Treasure Bumpers are generated, only 32 are needed to reach level 5. This push corrects the unit test for the level 5 checks. * Rename generically-named variables Change variables from generic names (x, y, n) to more meaningful names, for ease of readability. --------- Co-authored-by: The T <thet113@gmail.com>
2024-03-10 14:36:42 +00:00
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"))
self.assertTrue(self.can_reach_location("Level 5 - Cleared all Hazards"))