reading fucking cells

This commit is contained in:
2023-01-24 15:15:53 +01:00
parent 89dc8ed54a
commit be83cbd988
31 changed files with 340 additions and 80 deletions

View File

@@ -5,12 +5,19 @@ class AutoProductionAgent(BaseAgent):
"""
def __init__(self,sim,business) -> None:
def __init__(self,sim,business,worker=1,employment_rate=0) -> None:
super().__init__(sim)
self.business=business
self.prod=business.production
self.worker=worker
self.employment_rate=employment_rate
self.employment_index=worker
def set_worker(self,workers):
if workers>1:
self.worker=workers
else:
self.worker=1
def can_produce(self):
# If can produce item
@@ -19,11 +26,15 @@ class AutoProductionAgent(BaseAgent):
return False
return True
def tick(self):
if not self.can_produce():
return
# remove cost from inventory
for k,cost in self.prod["craft"].items():
self.business.inventory[k]-=cost
# add commodity
self.business.inventory[self.prod['name']]+=self.prod["amount"]
def tick(self,step,epi):
for i in range(self.worker):
if not self.can_produce():
self.employment_index-=self.employment_rate
continue
self.employment_index+=self.employment_rate
self.set_worker(int(self.employment_index))
# remove cost from inventory
for k,cost in self.prod["craft"].items():
self.business.inventory[k]-=cost
# add commodity
self.business.inventory[self.prod['name']]+=self.prod["amount"]