From d437f0105a6f8579ab3f4361f912fbd527d3fb8a Mon Sep 17 00:00:00 2001 From: Brad Humphrey Date: Thu, 30 Dec 2021 10:50:18 -0700 Subject: [PATCH] Test remaining locations after swapping --- test/base/TestFill.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/base/TestFill.py b/test/base/TestFill.py index f1da0d66..38447b62 100644 --- a/test/base/TestFill.py +++ b/test/base/TestFill.py @@ -92,6 +92,31 @@ class TestBase(unittest.TestCase): self.assertEqual(locations[0].item, items[0]) self.assertEqual(locations[1].item, items[1]) + def test_fill_restrictive_remaining_locations(self): + multi_world = generate_multi_world() + player1 = generate_player_data(multi_world, 1, 3, 2) + + item0 = player1.prog_items[0] + item1 = player1.prog_items[1] + loc0 = player1.locations[0] + loc1 = player1.locations[1] + loc2 = player1.locations[2] + + multi_world.completion_condition[player1.id] = lambda state: state.has( + item0.name, player1.id) and state.has(item1.name, player1.id) + set_rule(loc1, lambda state: state.has( + item0.name, player1.id)) + #forces a swap + set_rule(loc2, lambda state: state.has( + item0.name, player1.id)) + fill_restrictive(multi_world, multi_world.state, + player1.locations, player1.prog_items) + + self.assertEqual(loc0.item, item0) + self.assertEqual(loc1.item, item1) + self.assertEqual(1, len(player1.locations)) + self.assertEqual(player1.locations[0], loc2) + def test_minimal_fill_restrictive(self): multi_world = generate_multi_world() player1 = generate_player_data(multi_world, 1, 2, 2) @@ -202,7 +227,7 @@ class TestBase(unittest.TestCase): 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)) - + self.assertRaises(FillError, fill_restrictive, multi_world, multi_world.state, player1.locations.copy(), player1.prog_items.copy())