-
Notifications
You must be signed in to change notification settings - Fork 3
/
profiles.py
231 lines (179 loc) · 7.4 KB
/
profiles.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import database as d
import copy
class PersonProfile(object):
birthday = None
job = (None, 0)
spouse = (None, 0)
house = (None, 0)
person = None
salary = (0, 0)
def __init__(self, person, father=(None, 0), mother=(None, 0), spouse=(None, 0), siblings = (None, 0), children = (None, 0)):
dayNum = person.getLocality().model.getDayNum()
# self.name = person.name
self.firstname = person.firstname
self.lastname = person.lastname
self.locality = person.locality
self.meton = person.locality.date()
self.children = (dayNum)
self.person = person
self.muList = ([0 for i in d.getMaterials()], 0)
# self.skills = ([0 for i in d.getSkills()], 0)
self.father = father
self.mother = mother
self.spouse = spouse
self.siblings = siblings
self.children = children
self.opinion = 0
@property
def name(self):
return self.firstname + " " + self.lastname
@name.setter
def name(self, value):
if len(value.split()) >= 2:
self.firstname, self.lastname = value.split(maxsplit=1)
else:
self.firstname = value
def getOpinion(self):
return self.opinion
def updateOpinion(self, change):
if self.opinion <= 99:
self.opinion = (self.opinion + change if self.opinion + change <= 100 else 100)
def updateBirthday(self, birthday):
self.birthday = birthday
def updateJob(self, job, dayNum):
self.job = (job, dayNum)
def updateSalary(self, salary, dayNum):
self.salary = (salary, dayNum)
def getFamily(self):
return (self.father, self.mother, self.spouse, self.siblings, self.children)
#if you don't care how they're related
def getFamilyList(self):
siblings = [sibling for sibling in self.siblings[:-1]]
children = [child for child in self.children[:-1]]
family = [self.father[0], self.mother[0], self.spouse[0]] + siblings + children
family = [mem for mem in family if mem is not None]
return family
#daynums in params
#this method is a sin
def updateFamily(self, father=(None, 0), mother=(None, 0), spouse=(None, 0), siblings=(None, 0), children=(None, 0)):
family = {"father" : father, "mother" : mother, "spouse": spouse, "siblings" : siblings, "children" : children}
for title, relative in family.items():
#compare daynum
if relative[-1] > getattr(self, title)[-1]:
setattr(self, title, relative)
def updateHouse(self, p_house, dayNum):
self.house = (p_house, dayNum)
def updateMuList(self, muList, dayNum):
self.muList = (copy.copy(muList), dayNum)
def getBirthday(self):
return self.birthday
def getHouse(self):
return self.house
def getJob(self):
return self.job
def getSalary(self):
return self.salary
# def getSkills(self):
# return self.skills
def getFather(self):
return self.father
def getMother(self):
return self.mother
def getSpouse(self):
return self.spouse
def getSiblings(self):
return self.siblings
def getChildren(self):
return self.children
def getMuList(self):
return self.muList
def getPerson(self):
return self.person
def get_values(self):
spreadsheet = []
spreadsheet.append(["name", "job", "locality", "birthday", "spouse", "house"])
spreadsheet.append([str(self.name), str(self.job), str(self.locality), str(self.birthday), str(self.spouse), str(self.house)])
return spreadsheet
def attribute_list(self, array, name):
att_array = []
for item in array:
att = getattr(item, name)
att_array.append(att)
return att_array
def get_values_dict(self):
values_dict = {}
empty = "???"
values_dict["name"] = str(self.name)
values_dict["locality"] = str(self.locality.name)
values_dict["birthday"] = (str(self.birthday) if self.birthday is not None else empty)
values_dict["job"] = (str(self.job[0].jobType + " at " + self.job[0].unit.name) if self.job[0] is not None else empty)
values_dict["father"] = (str(self.father[0].name) if self.father[0] is not None else empty)
values_dict["mother"] = (str(self.mother[0].name) if self.mother[0] is not None else empty)
# values_dict["siblings"] = str(self.siblings)
# values_dict["children"] = str(self.children)
values_dict["spouse"] = (str(self.spouse[0].name) if self.spouse[0] is not None else empty)
values_dict["house"] = (str(self.house[0].location) if self.house[0] is not None else empty)
values_dict["mu"] = str([round(x, 2) for x in self.muList[0]])
# values_dict["skills"] = (str(self.skills) if self.skills[1] != 0 else empty)
values_dict["opinion"] = (str(self.opinion))
values_dict["meton"] = (str(self.meton))
return values_dict
class StoreProfile(object):
name = None
locality = None #city
location = None #address
#fam and exp should never be negative. Fam increases by 1 EVERY VISIT and is updated BEFORE avgPrices
familiarity = 1
experience = 1
store = None
def __init__(self, store, heardabout=None):
dayNum = store.getLocality().getDayNum()
self.store = store
self.location = store.getLocation()
self.locality = store.getLocality()
self.name = store.name
self.avgPrices = ([0 for i in d.getMaterials()], dayNum)
self.heardabout = str(heardabout.name if heardabout is not None else "Discovered") + " on " + str(store.getLocality().date())
def get_values_dict(self):
values_dict = {}
values_dict["name"] = str(self.name)
values_dict["prices"] = str(self.avgPrices)
values_dict["familiarity"] = str(self.familiarity)
values_dict["experience"] = str(self.experience)
values_dict["locality"] = str(self.locality)
values_dict["location"] = str(self.location)
values_dict["heardabout"] = str(self.heardabout)
return values_dict
def updatePrices(self, prices, dayNum):
n = self.familiarity
newAvgPrices = self.avgPrices[0]
#if first visit, avg prices are today's prices
if n == 1:
newAvgPrices = prices
else:
#We don't store the individual values, so we have to "unpack" the old avg and repack it. (ie find common denominator)
for i in range(len(prices)):
newAvgPrices[i] = ((newAvgPrices[i] * (n-1)/n)) + prices[i]/n
self.avgPrices = (newAvgPrices, dayNum)
def updateLocation(self, location):
self.location = location
def updateLocality(self, locality):
self.locality = locality
def updateFamiliarity(self):
self.familiarity = self.familiarity + 1
def updateExperience(self, experience):
self.experience = experience
def getPricesWithDayNum(self):
return self.avgPrices
def getPrices(self):
return self.avgPrices[0]
def getLocation(self):
return self.location
def getLocality(self):
return self.locality
def getFamiliarity(self):
return self.familiarity
def getExperience(self):
return self.experience
def getStore(self):
return self.store