Compare commits
2 Commits
e03911b78a
...
ec8b33ac00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec8b33ac00 | ||
|
|
c02aa3f736 |
@@ -55,6 +55,14 @@ class Gameplay():
|
|||||||
(research,)))
|
(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):
|
def queue_villager(self, action_time, initial_task):
|
||||||
self._check_time(action_time)
|
self._check_time(action_time)
|
||||||
self.actions[action_time].append((self.world.queue_villager,
|
self.actions[action_time].append((self.world.queue_villager,
|
||||||
|
|||||||
@@ -43,8 +43,13 @@ class World():
|
|||||||
# to farms with the highest capacity.
|
# to farms with the highest capacity.
|
||||||
# We keep track of only the closest upcoming farm deletion.
|
# 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 require market to use market buy/sell
|
||||||
# TODO what happens if you take away a builder while building?
|
|
||||||
# TODO allow automation:
|
# TODO allow automation:
|
||||||
# reseeding of farms
|
# reseeding of farms
|
||||||
# queuing of villagers
|
# queuing of villagers
|
||||||
|
|||||||
@@ -58,6 +58,17 @@ class TestWorld(unittest.TestCase):
|
|||||||
self.assertResourcesMatch([150, 200, 100, 200], game.world)
|
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):
|
def test_build_villager_leave_idle(self):
|
||||||
game = Gameplay()
|
game = Gameplay()
|
||||||
game.queue_villager(5, Tasks.IDLE)
|
game.queue_villager(5, Tasks.IDLE)
|
||||||
|
|||||||
Reference in New Issue
Block a user