Compare commits

..

2 Commits

Author SHA1 Message Date
Nate Bowman
ec8b33ac00 Add ability to automatically queue villagers 2026-11-08 21:00:32 -05:00
Nate Bowman
c02aa3f736 Add warning about builders 2026-11-08 20:55:00 -05:00
3 changed files with 25 additions and 1 deletions

View File

@@ -55,6 +55,14 @@ class Gameplay():
(research,)))
def queue_villagers_over_time(self, from_time, until_time, initial_task):
train_time = self.world.build_times.build_times[Units.VILLAGER]
duration = max(0, until_time - from_time)
for i in range(duration//train_time + 1):
self.queue_villager(from_time + i*train_time, initial_task)
def queue_villager(self, action_time, initial_task):
self._check_time(action_time)
self.actions[action_time].append((self.world.queue_villager,

View File

@@ -43,8 +43,13 @@ class World():
# to farms with the highest capacity.
# We keep track of only the closest upcoming farm deletion.
# Note: If you move away a builder while building is in progress, it will
# not slow down or stop the building. I do not plan to change this, so
# don't manually move workers away from build tasks if you want accurate
# results. Similarly, adding builders in the middle of building something
# is not supported
# TODO require market to use market buy/sell
# TODO what happens if you take away a builder while building?
# TODO allow automation:
# reseeding of farms
# queuing of villagers

View File

@@ -58,6 +58,17 @@ class TestWorld(unittest.TestCase):
self.assertResourcesMatch([150, 200, 100, 200], game.world)
def test_build_villagers_regularly(self):
game = Gameplay()
game.world._add_building(Buildings.HOUSE, {}, {})
game.queue_villagers_over_time(0, 75, Tasks.IDLE)
game.play_until(100)
self.assertEqual(8, game.world.population)
self.assertResourcesMatch([0, 200, 100, 200], game.world)
def test_build_villager_leave_idle(self):
game = Gameplay()
game.queue_villager(5, Tasks.IDLE)