Skip to content

Commit c0121f3

Browse files
- updated can_earn_money rule with a list of AP Regions that are in a display region with combat (Sara Sara Beach e.g.) but the player can't actually fight things in them or reach other regions in that display region where they could fight things (all Sara Sara Beach East AP Regions have no fighting and you can't get to the west beach in regionsanity)
- also added a unit test to double check this change
1 parent 8c3ed0a commit c0121f3

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

worlds/crystal_project/locations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ def get_shop_locations(player: int, options: CrystalProjectOptions | None) -> Li
17561756
LocationData(POSEIDON_SHRINE_PROPER_AP_REGION, POSEIDON_SHRINE_PROPER_AP_REGION + " Shop - Attendant 3", 30631 + shop_index_offset),
17571757

17581758
#Sara Sara Bazaar
1759-
LocationData(SARA_SARA_BAZAAR_AP_REGION, SARA_SARA_BAZAAR_DISPLAY_NAME + " Shop - Old Nans Stew Subsidiary", 10957 + shop_index_offset),
1759+
LocationData(SARA_SARA_BAZAAR_AP_REGION, SARA_SARA_BAZAAR_DISPLAY_NAME + " Shop - Old Nan's Stew Subsidiary", 10957 + shop_index_offset),
17601760

17611761
LocationData(SARA_SARA_BAZAAR_AP_REGION, SARA_SARA_BAZAAR_DISPLAY_NAME + " Shop - Accessory Merchant 1", 11386 + shop_index_offset),
17621762
LocationData(SARA_SARA_BAZAAR_AP_REGION, SARA_SARA_BAZAAR_DISPLAY_NAME + " Shop - Accessory Merchant 2", 21386 + shop_index_offset),

worlds/crystal_project/rules.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ def has_jidamba_keys(self, state: CollectionState) -> bool:
160160
else:
161161
return False
162162

163+
apRegionsThatCantEarnMoney: list[str] = [MENU_AP_REGION, SARA_SARA_BEACH_EAST_AP_REGION, IBEK_CAVE_MOUTH_AP_REGION, BELOW_IBEK_CAVE_MOUTH_AP_REGION, BELOW_IBEK_CAVE_EAST_AP_REGION,
164+
BELOW_IBEK_CAVE_WEST_AP_REGION, MODDED_ZONE_AP_REGION]
165+
163166
def can_earn_money(self, state: CollectionState, shop_ap_region: str) -> bool:
164167
#Note: this rule is also used for the Sara Sara Bazaar innkeeper bc he charges money
165168
if shop_ap_region == MERCURY_SHRINE_AP_REGION:
@@ -175,10 +178,12 @@ def can_earn_money(self, state: CollectionState, shop_ap_region: str) -> bool:
175178

176179
for ap_region in state.multiworld.worlds[self.player].get_regions():
177180
region_checked += 1
178-
#checking if the player has access to money-earning zones that are higher than 6 regions below the shop's region, to make sure they're not expected to grind Spawning Meadows enemies to buy something in Neptune Shrine
179-
if region_checked > (shop_region_index - 6) and ap_region.can_reach(state) and ap_region.name != MENU_AP_REGION and ap_region.name != MODDED_ZONE_AP_REGION:
181+
#checking if the player has access to money-earning zones that are higher than 6 regions below the shop's region, to make sure they're not expected to grind Spawning Meadows enemies
182+
#to buy something in Neptune Shrine
183+
if region_checked > (shop_region_index - 6) and ap_region.can_reach(state) and ap_region.name not in self.apRegionsThatCantEarnMoney:
180184
enemy_level = display_region_levels_dictionary[ap_region_to_display_region_dictionary[ap_region.name]][0]
181-
if enemy_level > 0 or (ap_region.name == CAPITAL_SEQUOIA_AP_REGION and self.is_area_in_level_range(state, CAPITAL_SEQUOIA_ENEMY_LEVEL)) or (ap_region.name == QUINTAR_RESERVE_AP_REGION and self.is_area_in_level_range(state, QUINTAR_RESERVE_ENEMY_LEVEL)):
185+
if (enemy_level > 0 or (ap_region.name == CAPITAL_SEQUOIA_AP_REGION and self.is_area_in_level_range(state, CAPITAL_SEQUOIA_ENEMY_LEVEL)) or
186+
(ap_region.name == QUINTAR_RESERVE_AP_REGION and self.is_area_in_level_range(state, QUINTAR_RESERVE_ENEMY_LEVEL))):
182187
has_combat = True
183188
break
184189

worlds/crystal_project/test/test_shops.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from .bases import CrystalProjectTestBase
22
from ..constants.region_passes import *
3+
from ..constants.display_regions import *
4+
from ..constants.mounts import *
35

4-
class TestCanEarnMoney(CrystalProjectTestBase):
6+
class TestCanEarnMoneyBasic(CrystalProjectTestBase):
57
run_default_tests = False
68

79
options = {
@@ -15,4 +17,24 @@ def test_can_earn_money(self):
1517
self.assertTrue(self.can_reach_location("Proving Meadows Chest - Tarzan"))
1618
self.assertFalse(self.can_reach_location("Proving Meadows Shop - Item Merchant 1"))
1719
self.collect_by_name(THE_PALE_GROTTO_PASS)
18-
self.assertTrue(self.can_reach_location("Proving Meadows Shop - Item Merchant 1"))
20+
self.assertTrue(self.can_reach_location("Proving Meadows Shop - Item Merchant 1"))
21+
22+
class TestCanEarnMoneySaraSara(CrystalProjectTestBase):
23+
run_default_tests = False
24+
25+
options = {
26+
"shopsanity" : 1,
27+
"regionsanity" : 1,
28+
"start_inventory_from_pool": {SARA_SARA_BEACH_PASS : 1}
29+
}
30+
31+
def test_can_earn_money(self):
32+
self.collect_all_progressive_levels()
33+
#the default unit test setup does not process start inventory so i need to have the pass here too (and i have to add it bc it's not in the pool since it's in the starting inventory)
34+
self.multiworld.state.add_item(SARA_SARA_BEACH_PASS, self.player)
35+
self.collect(self.get_item_by_name(SARA_SARA_BAZAAR_PASS))
36+
self.assertFalse(self.can_reach_location(SARA_SARA_BEACH_DISPLAY_NAME + " Chest - Silver-crossed palm chest"))
37+
self.assertFalse(self.can_reach_location(SARA_SARA_BAZAAR_DISPLAY_NAME + " Shop - Old Nan's Stew Subsidiary"))
38+
self.collect(self.get_item_by_name(PROGRESSIVE_MOUNT))
39+
self.assertTrue(self.can_reach_location(SARA_SARA_BEACH_DISPLAY_NAME + " Chest - Silver-crossed palm chest"))
40+
self.assertTrue(self.can_reach_location(SARA_SARA_BAZAAR_DISPLAY_NAME + " Shop - Old Nan's Stew Subsidiary"))

0 commit comments

Comments
 (0)