Stardew Valley: Fix a logic bug and a documentation typo (#1722)

Typo in the documentation
Logic error for help wanted quests
This commit is contained in:
agilbert1412
2023-04-16 05:22:33 -04:00
committed by GitHub
parent 50d9ab041a
commit ea03c90152
6 changed files with 103 additions and 75 deletions

View File

@@ -17,54 +17,57 @@ class TestBaseItemGeneration(SVTestBase):
if item.classification is classification}
for item in all_classified_items:
assert item in self.multiworld.itempool
self.assertIn(item, self.multiworld.itempool)
def test_creates_as_many_item_as_non_event_locations(self):
non_event_locations = [location for location in self.multiworld.get_locations(self.player) if
not location.event]
assert len(non_event_locations), len(self.multiworld.itempool)
self.assertEqual(len(non_event_locations), len(self.multiworld.itempool))
class TestGivenProgressiveBackpack(SVTestBase):
options = {options.BackpackProgression.internal_name: options.BackpackProgression.option_progressive}
def test_when_generate_world_then_two_progressive_backpack_are_added(self):
assert self.multiworld.itempool.count(self.world.create_item("Progressive Backpack")) == 2
self.assertEqual(self.multiworld.itempool.count(self.world.create_item("Progressive Backpack")), 2)
def test_when_generate_world_then_backpack_locations_are_added(self):
created_locations = {location.name for location in self.multiworld.get_locations(1)}
assert all(location.name in created_locations for location in locations.locations_by_tag[LocationTags.BACKPACK])
backpacks_exist = [location.name in created_locations
for location in locations.locations_by_tag[LocationTags.BACKPACK]]
all_exist = all(backpacks_exist)
self.assertTrue(all_exist)
class TestRemixedMineRewards(SVTestBase):
def test_when_generate_world_then_one_reward_is_added_per_chest(self):
# assert self.world.create_item("Rusty Sword") in self.multiworld.itempool
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_10])
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_20])
assert self.world.create_item("Slingshot") in self.multiworld.itempool
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_50])
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_60])
assert self.world.create_item("Master Slingshot") in self.multiworld.itempool
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_80])
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_90])
assert self.world.create_item("Stardrop") in self.multiworld.itempool
assert any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_110])
assert self.world.create_item("Skull Key") in self.multiworld.itempool
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_10]))
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_20]))
self.assertIn(self.world.create_item("Slingshot"), self.multiworld.itempool)
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_50]))
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_60]))
self.assertIn(self.world.create_item("Master Slingshot"), self.multiworld.itempool)
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_80]))
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_90]))
self.assertIn(self.world.create_item("Stardrop"), self.multiworld.itempool)
self.assertTrue(any(self.world.create_item(item) in self.multiworld.itempool
for item in items_by_group[Group.MINES_FLOOR_110]))
self.assertIn(self.world.create_item("Skull Key"), self.multiworld.itempool)
# This test as 1 over 90,000 changes to fail... Sorry in advance
# This test has a 1/90,000 chance to fail... Sorry in advance
def test_when_generate_world_then_rewards_are_not_all_vanilla(self):
assert not all(self.world.create_item(item) in self.multiworld.itempool
self.assertFalse(all(self.world.create_item(item) in self.multiworld.itempool
for item in
["Leather Boots", "Steel Smallsword", "Tundra Boots", "Crystal Dagger", "Firewalker Boots",
"Obsidian Edge", "Space Boots"])
"Obsidian Edge", "Space Boots"]))
class TestProgressiveElevator(SVTestBase):
@@ -81,11 +84,11 @@ class TestProgressiveElevator(SVTestBase):
self.collect([self.get_item_by_name("Combat Level")] * 4)
self.collect(self.get_item_by_name("Adventurer's Guild"))
assert not self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state)
self.assertFalse(self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state))
self.collect(self.get_item_by_name("Progressive Mine Elevator"))
assert self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state)
self.assertTrue(self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state))
def test_given_access_to_floor_115_when_find_another_pickaxe_and_sword_then_has_access_to_floor_120(self):
self.collect([self.get_item_by_name("Progressive Pickaxe")] * 2)
@@ -94,14 +97,14 @@ class TestProgressiveElevator(SVTestBase):
self.collect([self.get_item_by_name("Combat Level")] * 4)
self.collect(self.get_item_by_name("Adventurer's Guild"))
assert not self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state)
self.assertFalse(self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state))
self.collect(self.get_item_by_name("Progressive Pickaxe"))
self.collect(self.multiworld.create_item("Steel Falchion", self.player))
self.collect(self.get_item_by_name("Combat Level"))
self.collect(self.get_item_by_name("Combat Level"))
assert self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state)
self.assertTrue(self.multiworld.get_region("The Mines - Floor 120", self.player).can_reach(self.multiworld.state))
class TestLocationGeneration(SVTestBase):
@@ -109,7 +112,7 @@ class TestLocationGeneration(SVTestBase):
def test_all_location_created_are_in_location_table(self):
for location in self.multiworld.get_locations(self.player):
if not location.event:
assert location.name in location_table
self.assertIn(location.name, location_table)
class TestLocationAndItemCount(SVTestBase):
@@ -130,7 +133,7 @@ class TestLocationAndItemCount(SVTestBase):
}
def test_minimal_location_maximal_items_still_valid(self):
assert len(self.multiworld.get_locations()) >= len(self.multiworld.get_items())
self.assertGreaterEqual(len(self.multiworld.get_locations()), len(self.multiworld.get_items()))
class TestFriendsanityNone(SVTestBase):
@@ -140,11 +143,11 @@ class TestFriendsanityNone(SVTestBase):
def test_no_friendsanity_items(self):
for item in self.multiworld.get_items():
assert not item.name.endswith(": 1 <3")
self.assertFalse(item.name.endswith(": 1 <3"))
def test_no_friendsanity_locations(self):
for location in self.multiworld.get_locations():
assert not location.name.startswith("Friendsanity")
self.assertFalse(location.name.startswith("Friendsanity"))
class TestFriendsanityBachelors(SVTestBase):
@@ -159,7 +162,7 @@ class TestFriendsanityBachelors(SVTestBase):
for item in self.multiworld.get_items():
if item.name.endswith(suffix):
villager_name = item.name[:item.name.index(suffix)]
assert villager_name in self.bachelors
self.assertIn(villager_name, self.bachelors)
def test_friendsanity_only_bachelor_locations(self):
prefix = "Friendsanity: "
@@ -171,8 +174,8 @@ class TestFriendsanityBachelors(SVTestBase):
parts = name_trimmed.split(" ")
name = parts[0]
hearts = parts[1]
assert name in self.bachelors
assert int(hearts) <= 8
self.assertIn(name, self.bachelors)
self.assertLessEqual(int(hearts), 8)
class TestFriendsanityStartingNpcs(SVTestBase):
@@ -186,7 +189,7 @@ class TestFriendsanityStartingNpcs(SVTestBase):
for item in self.multiworld.get_items():
if item.name.endswith(suffix):
villager_name = item.name[:item.name.index(suffix)]
assert villager_name not in self.excluded_npcs
self.assertNotIn(villager_name, self.excluded_npcs)
def test_friendsanity_only_starting_npcs_locations(self):
prefix = "Friendsanity: "
@@ -198,14 +201,14 @@ class TestFriendsanityStartingNpcs(SVTestBase):
parts = name_trimmed.split(" ")
name = parts[0]
hearts = parts[1]
assert name not in self.excluded_npcs
assert name in all_villagers_by_name or name == "Pet"
self.assertNotIn(name, self.excluded_npcs)
self.assertTrue(name in all_villagers_by_name or name == "Pet")
if name == "Pet":
assert int(hearts) <= 5
self.assertLessEqual(int(hearts), 5)
elif all_villagers_by_name[name].bachelor:
assert int(hearts) <= 8
self.assertLessEqual(int(hearts), 8)
else:
assert int(hearts) <= 10
self.assertLessEqual(int(hearts), 10)
class TestFriendsanityAllNpcs(SVTestBase):
@@ -218,7 +221,7 @@ class TestFriendsanityAllNpcs(SVTestBase):
for item in self.multiworld.get_items():
if item.name.endswith(suffix):
villager_name = item.name[:item.name.index(suffix)]
assert villager_name in all_villagers_by_name or villager_name == "Pet"
self.assertTrue(villager_name in all_villagers_by_name or villager_name == "Pet")
def test_friendsanity_all_locations(self):
prefix = "Friendsanity: "
@@ -230,13 +233,13 @@ class TestFriendsanityAllNpcs(SVTestBase):
parts = name_trimmed.split(" ")
name = parts[0]
hearts = parts[1]
assert name in all_villagers_by_name or name == "Pet"
self.assertTrue(name in all_villagers_by_name or name == "Pet")
if name == "Pet":
assert int(hearts) <= 5
self.assertLessEqual(int(hearts), 5)
elif all_villagers_by_name[name].bachelor:
assert int(hearts) <= 8
self.assertLessEqual(int(hearts), 8)
else:
assert int(hearts) <= 10
self.assertLessEqual(int(hearts), 10)
class TestFriendsanityAllNpcsWithMarriage(SVTestBase):
@@ -249,7 +252,7 @@ class TestFriendsanityAllNpcsWithMarriage(SVTestBase):
for item in self.multiworld.get_items():
if item.name.endswith(suffix):
villager_name = item.name[:item.name.index(suffix)]
assert villager_name in all_villagers_by_name or villager_name == "Pet"
self.assertTrue(villager_name in all_villagers_by_name or villager_name == "Pet")
def test_friendsanity_all_with_marriage_locations(self):
prefix = "Friendsanity: "
@@ -261,10 +264,10 @@ class TestFriendsanityAllNpcsWithMarriage(SVTestBase):
parts = name_trimmed.split(" ")
name = parts[0]
hearts = parts[1]
assert name in all_villagers_by_name or name == "Pet"
self.assertTrue(name in all_villagers_by_name or name == "Pet")
if name == "Pet":
assert int(hearts) <= 5
self.assertLessEqual(int(hearts), 5)
elif all_villagers_by_name[name].bachelor:
assert int(hearts) <= 14
self.assertLessEqual(int(hearts), 14)
else:
assert int(hearts) <= 10
self.assertLessEqual(int(hearts), 10)