Stop as soon as materials run out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-20 19:43:45 +01:00
parent 16f0384483
commit 8dd33cbb40
2 changed files with 17 additions and 0 deletions

View file

@ -91,6 +91,16 @@ class ActionTest(unittest.TestCase):
self.assertIsNone(p["action"])
self.assertEqual(summary["stopped"], "Out of copper ore")
def test_crafting_stops_as_the_last_one_finishes(self):
world = world_with(("ann", "commoner"))
p = world["players"]["ann"]
p["bank"] = {"copper_ore": 1, "logs": 10}
game.start_action(world, p, "smith_copper_bar", T0)
duration = game.action_time(world, p, game.ACTION_BY_ID["smith_copper_bar"])
summary = game.process_player(world, p, T0 + duration + 0.1, random.Random(1))
self.assertIsNone(p["action"])
self.assertEqual(summary["stopped"], "Out of copper ore")
def test_level_and_city_requirements(self):
world = world_with(("ann", "commoner"))
p = world["players"]["ann"]