-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignments.py
26 lines (26 loc) · 1.1 KB
/
assignments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class AsgnHandler(object):
def __init__(self, bld, vlgr):
self.bld = bld
self.vlgr = vlgr
def assign(self, villager, building):
"""
Adds the villager to asgns under that building name
"""
if self.bld.built[str(building)].assignments < self.bld.built[str(building)].slots:
self.bld.built[str(building)].assignments += 1
self.bld.asgns[str(building)].add(villager)
print villager, "assigned to", building
else:
print "That location is full"
def auto_assign(self):
for building in self.bld.built.itervalues():
for person in self.vlgr.vlgrList.itervalues():
if building.assignments < building.slots:
if person.sector == building.sector:
if person.workplace == '':
self.assign(person, building)
person.workplace = str(building)
print self.bld.asgns
def get_workplaces(self):
for person in self.vlgr.vlgrList.itervalues():
print person.workplace