Idle builders start queued repairs on tick
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c5b0c490cd
commit
cf8c717ef0
2 changed files with 14 additions and 0 deletions
3
game.py
3
game.py
|
|
@ -5712,6 +5712,9 @@ def _tick_city(world: World, now: float, rng: random.Random) -> bool:
|
|||
construction = city["construction"]
|
||||
if construction and construction["labour"] >= construction["needed"]:
|
||||
_finish_construction(world, now)
|
||||
changed = True
|
||||
# Idle builders take the next funded job. Damage can queue one with nobody to start it.
|
||||
if not city["construction"] and city["queue"]:
|
||||
_start_next(world, now)
|
||||
changed = True
|
||||
while city["tier"] + 1 < len(TIERS) and city["population"] >= TIERS[city["tier"] + 1]["pop"]:
|
||||
|
|
|
|||
|
|
@ -453,6 +453,17 @@ class CityTest(unittest.TestCase):
|
|||
game.tick(world, T0 + 2, random.Random(1))
|
||||
self.assertEqual(city["tier"], 1)
|
||||
|
||||
def test_damage_with_the_repair_already_funded_starts_on_the_next_tick(self):
|
||||
world = world_with(("fred", "commoner"))
|
||||
city = world["city"]
|
||||
city["buildings"]["walls"].update(level=1, fund=game.repair_cost("walls", 1))
|
||||
self.assertEqual(game._damage_building(world, T0, random.Random(1)), "Walls")
|
||||
self.assertEqual(city["queue"], ["walls"])
|
||||
self.assertIsNone(city["construction"])
|
||||
self.assertTrue(game.tick(world, T0 + 1, random.Random(1)))
|
||||
self.assertEqual(city["queue"], [])
|
||||
self.assertTrue(city["construction"]["repair"])
|
||||
|
||||
def test_damage_turns_the_fund_towards_repairs_and_keeps_the_rest(self):
|
||||
world = world_with(("fred", "commoner"))
|
||||
p = world["players"]["fred"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue