| 
									
										
										
										
											2024-11-11 23:27:43 -05:00
										 |  |  | from typing import List | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | from unittest import TestCase | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  | from BaseClasses import CollectionState, Location, Region | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  | from ...stardew_rule import StardewRule, false_, MISSING_ITEM, Reach | 
					
						
							|  |  |  | from ...stardew_rule.rule_explain import explain | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class RuleAssertMixin(TestCase): | 
					
						
							|  |  |  |     def assert_rule_true(self, rule: StardewRule, state: CollectionState): | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |         expl = explain(rule, state) | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             self.assertTrue(rule(state), expl) | 
					
						
							|  |  |  |         except KeyError as e: | 
					
						
							|  |  |  |             raise AssertionError(f"Error while checking rule {rule}: {e}" | 
					
						
							|  |  |  |                                  f"\nExplanation: {expl}") | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-11 23:27:43 -05:00
										 |  |  |     def assert_rules_true(self, rules: List[StardewRule], state: CollectionState): | 
					
						
							|  |  |  |         for rule in rules: | 
					
						
							|  |  |  |             self.assert_rule_true(rule, state) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |     def assert_rule_false(self, rule: StardewRule, state: CollectionState): | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |         expl = explain(rule, state, expected=False) | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             self.assertFalse(rule(state), expl) | 
					
						
							|  |  |  |         except KeyError as e: | 
					
						
							|  |  |  |             raise AssertionError(f"Error while checking rule {rule}: {e}" | 
					
						
							|  |  |  |                                  f"\nExplanation: {expl}") | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-11 23:27:43 -05:00
										 |  |  |     def assert_rules_false(self, rules: List[StardewRule], state: CollectionState): | 
					
						
							|  |  |  |         for rule in rules: | 
					
						
							|  |  |  |             self.assert_rule_false(rule, state) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 15:05:14 +03:00
										 |  |  |     def assert_rule_can_be_resolved(self, rule: StardewRule, complete_state: CollectionState): | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |         expl = explain(rule, complete_state) | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             self.assertNotIn(MISSING_ITEM, repr(rule)) | 
					
						
							|  |  |  |             self.assertTrue(rule is false_ or rule(complete_state), expl) | 
					
						
							|  |  |  |         except KeyError as e: | 
					
						
							|  |  |  |             raise AssertionError(f"Error while checking rule {rule}: {e}" | 
					
						
							|  |  |  |                                  f"\nExplanation: {expl}") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  |     def assert_can_reach_location(self, location: Location | str, state: CollectionState) -> None: | 
					
						
							|  |  |  |         location_name = location.name if isinstance(location, Location) else location | 
					
						
							|  |  |  |         expl = explain(Reach(location_name, "Location", 1), state) | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |         try: | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  |             can_reach = state.can_reach_location(location_name, 1) | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |             self.assertTrue(can_reach, expl) | 
					
						
							|  |  |  |         except KeyError as e: | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  |             raise AssertionError(f"Error while checking location {location_name}: {e}" | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |                                  f"\nExplanation: {expl}") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  |     def assert_cannot_reach_location(self, location: Location | str, state: CollectionState) -> None: | 
					
						
							|  |  |  |         location_name = location.name if isinstance(location, Location) else location | 
					
						
							|  |  |  |         expl = explain(Reach(location_name, "Location", 1), state, expected=False) | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |         try: | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  |             can_reach = state.can_reach_location(location_name, 1) | 
					
						
							|  |  |  |             self.assertFalse(can_reach, expl) | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |         except KeyError as e: | 
					
						
							| 
									
										
										
										
											2025-02-04 02:27:23 -05:00
										 |  |  |             raise AssertionError(f"Error while checking location {location_name}: {e}" | 
					
						
							|  |  |  |                                  f"\nExplanation: {expl}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def assert_can_reach_region(self, region: Region | str, state: CollectionState) -> None: | 
					
						
							|  |  |  |         region_name = region.name if isinstance(region, Region) else region | 
					
						
							|  |  |  |         expl = explain(Reach(region_name, "Region", 1), state) | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             can_reach = state.can_reach_region(region_name, 1) | 
					
						
							|  |  |  |             self.assertTrue(can_reach, expl) | 
					
						
							|  |  |  |         except KeyError as e: | 
					
						
							|  |  |  |             raise AssertionError(f"Error while checking region {region_name}: {e}" | 
					
						
							|  |  |  |                                  f"\nExplanation: {expl}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def assert_cannot_reach_region(self, region: Region | str, state: CollectionState) -> None: | 
					
						
							|  |  |  |         region_name = region.name if isinstance(region, Region) else region | 
					
						
							|  |  |  |         expl = explain(Reach(region_name, "Region", 1), state, expected=False) | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             can_reach = state.can_reach_region(region_name, 1) | 
					
						
							|  |  |  |             self.assertFalse(can_reach, expl) | 
					
						
							|  |  |  |         except KeyError as e: | 
					
						
							|  |  |  |             raise AssertionError(f"Error while checking region {region_name}: {e}" | 
					
						
							| 
									
										
										
											
												Stardew Valley 6.x.x: The Content Update (#3478)
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
											
										 
											2024-07-07 16:04:25 +03:00
										 |  |  |                                  f"\nExplanation: {expl}") |