Example #1
0
 def demolish(self, r, c):     
     from resource  import singleton_resource
     '''attempts to demolish a building. Returns True if a building is sucessfully demolished'''
     if self.squares[r][c].destroyable() and (self.num_houses() > 1 or not (isinstance(self.squares[r][c], House))):
         # Free the workers
         singleton_resource.give({'Unemployed': self.squares[r][c].num_workers})
         # Replace building with grass patch
         self.squares[r][c] = Grass()
         return True
     return False
Example #2
0
 def harvest(self):
     ''' Called once per tick.  Updates the resources based on the production of the buildings in the grid.'''
     from resource import singleton_resource
     for row in self.squares:
         for square in row:
             singleton_resource.give(square.produce())