 9b22458f44
			
		
	
	9b22458f44
	
	
	
		
			
			Focus of the Update: Compatibility with Stardew Valley 1.6 Released on March 19th 2024 This includes randomization for pretty much all of the new content, including but not limited to - Raccoon Bundles - Booksanity - Skill Masteries - New Recipes, Craftables, Fish, Maps, Farm Type, Festivals and Quests This also includes a significant reorganisation of the code into "Content Packs", to allow for easier modularity of various game mechanics between the settings and the supported mods. This improves maintainability quite a bit. In addition to that, a few **very** requested new features have been introduced, although they weren't the focus of this update - Walnutsanity - Player Buffs - More customizability in settings, such as shorter special orders, ER without farmhouse - New Remixed Bundles
		
			
				
	
	
		
			93 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			93 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from . import SVTestCase, setup_multiworld
 | |
| from .. import True_
 | |
| from ..options import FestivalLocations, StartingMoney
 | |
| from ..strings.festival_check_names import FestivalCheck
 | |
| 
 | |
| 
 | |
| def get_access_rule(multiworld, player: int, location_name: str):
 | |
|     return multiworld.get_location(location_name, player).access_rule
 | |
| 
 | |
| 
 | |
| class TestDifferentSettings(SVTestCase):
 | |
| 
 | |
|     def test_different_festival_settings(self):
 | |
|         options_no_festivals = {FestivalLocations.internal_name: FestivalLocations.option_disabled}
 | |
|         options_easy_festivals = {FestivalLocations.internal_name: FestivalLocations.option_easy}
 | |
|         options_hard_festivals = {FestivalLocations.internal_name: FestivalLocations.option_hard}
 | |
| 
 | |
|         multiplayer_options = [options_no_festivals, options_easy_festivals, options_hard_festivals]
 | |
|         multiworld = setup_multiworld(multiplayer_options)
 | |
| 
 | |
|         self.check_location_rule(multiworld, 1, FestivalCheck.egg_hunt, False)
 | |
|         self.check_location_rule(multiworld, 2, FestivalCheck.egg_hunt, True, True)
 | |
|         self.check_location_rule(multiworld, 3, FestivalCheck.egg_hunt, True, True)
 | |
| 
 | |
|     def test_different_money_settings(self):
 | |
|         options_no_festivals_unlimited_money = {FestivalLocations.internal_name: FestivalLocations.option_disabled,
 | |
|                                                 StartingMoney.internal_name: -1}
 | |
|         options_no_festivals_limited_money = {FestivalLocations.internal_name: FestivalLocations.option_disabled,
 | |
|                                               StartingMoney.internal_name: 5000}
 | |
|         options_easy_festivals_unlimited_money = {FestivalLocations.internal_name: FestivalLocations.option_easy,
 | |
|                                                   StartingMoney.internal_name: -1}
 | |
|         options_easy_festivals_limited_money = {FestivalLocations.internal_name: FestivalLocations.option_easy,
 | |
|                                                 StartingMoney.internal_name: 5000}
 | |
|         options_hard_festivals_unlimited_money = {FestivalLocations.internal_name: FestivalLocations.option_hard,
 | |
|                                                   StartingMoney.internal_name: -1}
 | |
|         options_hard_festivals_limited_money = {FestivalLocations.internal_name: FestivalLocations.option_hard,
 | |
|                                                 StartingMoney.internal_name: 5000}
 | |
| 
 | |
|         multiplayer_options = [options_no_festivals_unlimited_money, options_no_festivals_limited_money,
 | |
|                                options_easy_festivals_unlimited_money, options_easy_festivals_limited_money,
 | |
|                                options_hard_festivals_unlimited_money, options_hard_festivals_limited_money]
 | |
|         multiworld = setup_multiworld(multiplayer_options)
 | |
| 
 | |
|         self.check_location_rule(multiworld, 1, FestivalCheck.rarecrow_4, False)
 | |
|         self.check_location_rule(multiworld, 2, FestivalCheck.rarecrow_4, False)
 | |
| 
 | |
|         self.check_location_rule(multiworld, 3, FestivalCheck.rarecrow_4, True, True)
 | |
|         self.check_location_rule(multiworld, 4, FestivalCheck.rarecrow_4, True, False)
 | |
| 
 | |
|         self.check_location_rule(multiworld, 5, FestivalCheck.rarecrow_4, True, True)
 | |
|         self.check_location_rule(multiworld, 6, FestivalCheck.rarecrow_4, True, False)
 | |
| 
 | |
|     def test_money_rule_caching(self):
 | |
|         options_festivals_limited_money = {FestivalLocations.internal_name: FestivalLocations.option_easy,
 | |
|                                            StartingMoney.internal_name: 5000}
 | |
|         options_festivals_limited_money = {FestivalLocations.internal_name: FestivalLocations.option_easy,
 | |
|                                            StartingMoney.internal_name: 5000}
 | |
| 
 | |
|         multiplayer_options = [options_festivals_limited_money, options_festivals_limited_money]
 | |
|         multiworld = setup_multiworld(multiplayer_options)
 | |
| 
 | |
|         player_1_rarecrow_2 = get_access_rule(multiworld, 1, FestivalCheck.rarecrow_2)
 | |
|         player_1_rarecrow_4 = get_access_rule(multiworld, 1, FestivalCheck.rarecrow_4)
 | |
|         player_2_rarecrow_2 = get_access_rule(multiworld, 2, FestivalCheck.rarecrow_2)
 | |
|         player_2_rarecrow_4 = get_access_rule(multiworld, 2, FestivalCheck.rarecrow_4)
 | |
| 
 | |
|         with self.subTest("Rules are not cached between players"):
 | |
|             self.assertNotEqual(id(player_1_rarecrow_2), id(player_2_rarecrow_2))
 | |
|             self.assertNotEqual(id(player_1_rarecrow_4), id(player_2_rarecrow_4))
 | |
| 
 | |
|         with self.subTest("Rules are cached for the same player"):
 | |
|             self.assertEqual(id(player_1_rarecrow_2), id(player_1_rarecrow_4))
 | |
|             self.assertEqual(id(player_2_rarecrow_2), id(player_2_rarecrow_4))
 | |
| 
 | |
|     def check_location_rule(self, multiworld, player: int, location_name: str, should_exist: bool, should_be_true: bool = False):
 | |
|         has = "has" if should_exist else "doesn't have"
 | |
|         rule = "without access rule" if should_be_true else f"with access rule"
 | |
|         rule_text = f" {rule}" if should_exist else ""
 | |
|         with self.subTest(f"Player {player} {has} {location_name}{rule_text}"):
 | |
|             locations = multiworld.get_locations(player)
 | |
|             locations_names = {location.name for location in locations}
 | |
|             if not should_exist:
 | |
|                 self.assertNotIn(location_name, locations_names)
 | |
|                 return None
 | |
| 
 | |
|             self.assertIn(location_name, locations_names)
 | |
|             access_rule = get_access_rule(multiworld, player, location_name)
 | |
|             if should_be_true:
 | |
|                 self.assertEqual(access_rule, True_())
 | |
|             else:
 | |
|                 self.assertNotEqual(access_rule, True_())
 | |
|             return access_rule
 |