forked from ArchipelagoMW/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stardew Valley: Fix masteries logic so it requires levels and tools (A…
…rchipelagoMW#3640) * fix and add test * add test to make sure we check xp can be earned * fix python 3.8 test my god I hope it gets removed soon * fixing some review comments * curse you monstersanity * move month rule to has_level vanilla, so next level is in logic once the previous item is received * use progressive masteries to skills in test alsanity * rename reset_collection_state * add more tests around skill and masteries rules * progressive level issue --------- Co-authored-by: agilbert1412 <[email protected]>
- Loading branch information
1 parent
e4a5ed1
commit cabfef6
Showing
4 changed files
with
137 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,113 @@ | ||
from ... import HasProgressionPercent | ||
from ... import HasProgressionPercent, StardewLogic | ||
from ...options import ToolProgression, SkillProgression, Mods | ||
from ...strings.skill_names import all_skills | ||
from ...strings.skill_names import all_skills, all_vanilla_skills, Skill | ||
from ...test import SVTestBase | ||
|
||
|
||
class TestVanillaSkillLogicSimplification(SVTestBase): | ||
class TestSkillProgressionVanilla(SVTestBase): | ||
options = { | ||
SkillProgression.internal_name: SkillProgression.option_vanilla, | ||
ToolProgression.internal_name: ToolProgression.option_progressive, | ||
} | ||
|
||
def test_skill_logic_has_level_only_uses_one_has_progression_percent(self): | ||
rule = self.multiworld.worlds[1].logic.skill.has_level("Farming", 8) | ||
self.assertEqual(1, sum(1 for i in rule.current_rules if type(i) == HasProgressionPercent)) | ||
rule = self.multiworld.worlds[1].logic.skill.has_level(Skill.farming, 8) | ||
self.assertEqual(1, sum(1 for i in rule.current_rules if type(i) is HasProgressionPercent)) | ||
|
||
def test_has_mastery_requires_month_equivalent_to_10_levels(self): | ||
logic: StardewLogic = self.multiworld.worlds[1].logic | ||
rule = logic.skill.has_mastery(Skill.farming) | ||
time_rule = logic.time.has_lived_months(10) | ||
|
||
class TestAllSkillsRequirePrevious(SVTestBase): | ||
self.assertIn(time_rule, rule.current_rules) | ||
|
||
|
||
class TestSkillProgressionProgressive(SVTestBase): | ||
options = { | ||
SkillProgression.internal_name: SkillProgression.option_progressive_with_masteries, | ||
SkillProgression.internal_name: SkillProgression.option_progressive, | ||
Mods.internal_name: frozenset(Mods.valid_keys), | ||
} | ||
|
||
def test_all_skill_levels_require_previous_level(self): | ||
for skill in all_skills: | ||
self.collect_everything() | ||
self.remove_by_name(f"{skill} Level") | ||
|
||
for level in range(1, 11): | ||
location_name = f"Level {level} {skill}" | ||
location = self.multiworld.get_location(location_name, self.player) | ||
|
||
with self.subTest(location_name): | ||
can_reach = self.can_reach_location(location_name) | ||
if level > 1: | ||
self.assertFalse(can_reach) | ||
self.assert_reach_location_false(location, self.multiworld.state) | ||
self.collect(f"{skill} Level") | ||
can_reach = self.can_reach_location(location_name) | ||
self.assertTrue(can_reach) | ||
self.multiworld.state = self.original_state.copy() | ||
|
||
self.assert_reach_location_true(location, self.multiworld.state) | ||
|
||
self.reset_collection_state() | ||
|
||
def test_has_level_requires_exact_amount_of_levels(self): | ||
logic: StardewLogic = self.multiworld.worlds[1].logic | ||
rule = logic.skill.has_level(Skill.farming, 8) | ||
level_rule = logic.received("Farming Level", 8) | ||
|
||
self.assertEqual(level_rule, rule) | ||
|
||
def test_has_previous_level_requires_one_less_level_than_requested(self): | ||
logic: StardewLogic = self.multiworld.worlds[1].logic | ||
rule = logic.skill.has_previous_level(Skill.farming, 8) | ||
level_rule = logic.received("Farming Level", 7) | ||
|
||
self.assertEqual(level_rule, rule) | ||
|
||
def test_has_mastery_requires_10_levels(self): | ||
logic: StardewLogic = self.multiworld.worlds[1].logic | ||
rule = logic.skill.has_mastery(Skill.farming) | ||
level_rule = logic.received("Farming Level", 10) | ||
|
||
self.assertIn(level_rule, rule.current_rules) | ||
|
||
|
||
class TestSkillProgressionProgressiveWithMasteryWithoutMods(SVTestBase): | ||
options = { | ||
SkillProgression.internal_name: SkillProgression.option_progressive_with_masteries, | ||
ToolProgression.internal_name: ToolProgression.option_progressive, | ||
Mods.internal_name: frozenset(), | ||
} | ||
|
||
def test_has_mastery_requires_the_item(self): | ||
logic: StardewLogic = self.multiworld.worlds[1].logic | ||
rule = logic.skill.has_mastery(Skill.farming) | ||
received_mastery = logic.received("Farming Mastery") | ||
|
||
self.assertEqual(received_mastery, rule) | ||
|
||
def test_given_all_levels_when_can_earn_mastery_then_can_earn_mastery(self): | ||
self.collect_everything() | ||
|
||
for skill in all_vanilla_skills: | ||
with self.subTest(skill): | ||
location = self.multiworld.get_location(f"{skill} Mastery", self.player) | ||
self.assert_reach_location_true(location, self.multiworld.state) | ||
|
||
self.reset_collection_state() | ||
|
||
def test_given_one_level_missing_when_can_earn_mastery_then_cannot_earn_mastery(self): | ||
for skill in all_vanilla_skills: | ||
with self.subTest(skill): | ||
self.collect_everything() | ||
self.remove_one_by_name(f"{skill} Level") | ||
|
||
location = self.multiworld.get_location(f"{skill} Mastery", self.player) | ||
self.assert_reach_location_false(location, self.multiworld.state) | ||
|
||
self.reset_collection_state() | ||
|
||
def test_given_one_tool_missing_when_can_earn_mastery_then_cannot_earn_mastery(self): | ||
self.collect_everything() | ||
|
||
self.remove_one_by_name(f"Progressive Pickaxe") | ||
location = self.multiworld.get_location("Mining Mastery", self.player) | ||
self.assert_reach_location_false(location, self.multiworld.state) | ||
|
||
self.reset_collection_state() |