def test_ticket_979(s, p): settlement, island = settle(s) storage_collectors = settlement.warehouse.get_component(CollectingComponent).get_local_collectors() farm = _build_farm(30, 30, island, settlement, p, BUILDINGS.POTATO_FIELD) # Let it work for a bit s.run(seconds=60) assert farm.get_component(StorageComponent).inventory[RES.FOOD] # Depending on auto unloading (which we aren't interested in here), # the settlement inventory may already be full of food: dispose of it settlement.get_component(StorageComponent).inventory.alter(RES.FOOD, -settlement.get_component(StorageComponent).inventory[RES.FOOD]) assert settlement.get_component(StorageComponent).inventory[RES.FOOD] == 0 # Build a road, connecting farm and warehouse for y in range(23, 30): assert Build(BUILDINGS.TRAIL, 30, y, island, settlement=settlement)(p) # Step forward in time until a collector picked a job got_job = False while not got_job: s.run() if any(c.job for c in storage_collectors): got_job = True Tear(farm)(p) # Let the collector reach the not existing target s.run(seconds=10)
def test_ticket_1523(s, p): settlement, island = settle(s) farm = _build_farm(30, 30, island, settlement, p, BUILDINGS.POTATO_FIELD, BUILDINGS.POTATO_FIELD, BUILDINGS.POTATO_FIELD, BUILDINGS.POTATO_FIELD) # Let it work for a bit s.run(seconds=60) assert farm.get_component(StorageComponent).inventory[RES.FOOD] assert isinstance(farm.get_component(Producer)._Producer__utilization, FieldUtilization) # Should be 0.5 assert not farm.get_component(Producer).capacity_utilization_below(0.4) assert farm.get_component(Producer).capacity_utilization > 0.4
def test_ticket_1016(s, p): settlement, island = settle(s) farm = _build_farm(30, 30, island, settlement, p, BUILDINGS.POTATO_FIELD) # tear down job target, then home building (in the same tick) torn_down = False while not torn_down: s.run(seconds=1) for col in farm.get_component(CollectingComponent)._CollectingComponent__collectors: if col.job: Tear(col.job.object)(p) Tear(farm)(p) torn_down = True break s.run(seconds=30)