Don't allow items to swap infinitly

This commit is contained in:
Brad Humphrey
2021-12-20 18:14:50 -07:00
committed by Fabian Dill
parent 6a34fe5184
commit d719eb356f
2 changed files with 29 additions and 3 deletions

View File

@@ -149,4 +149,23 @@ class TestBase(unittest.TestCase):
set_rule(loc2, lambda state: state.has(item1.name, player1_id))
set_rule(loc0, lambda state: state.has(item2.name, player1_id))
with pytest.raises(FillError):
fill_restrictive(multi_world, multi_world.state, locations, items)
fill_restrictive(multi_world, multi_world.state, locations, items)
def test_competing_fill_restrictive(self):
multi_world = generate_multi_world()
player1_id = 1
player1_menu = multi_world.get_region("Menu", player1_id)
locations = generate_locations(2, player1_id, None, player1_menu)
items = generate_items(2, player1_id, True)
item0 = items[0]
item1 = items[1]
loc1 = locations[1]
multi_world.completion_condition[player1_id] = lambda state: state.has(
item0.name, player1_id) and state.has(item0.name, player1_id) and state.has(item1.name, player1_id)
set_rule(loc1, lambda state: state.has(item0.name, player1_id)
and state.has(item1.name, player1_id))
with pytest.raises(FillError):
fill_restrictive(multi_world, multi_world.state, locations, items)