-
Notifications
You must be signed in to change notification settings - Fork 3
/
orders.py
84 lines (58 loc) · 2.33 KB
/
orders.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
import database as d
import abc
#Orders allow a Business to queue method calls from their Jobs in a particular order, to be performed daily.
class Order(object):
def __init__(self, business, job):
self.business = business
self.job = job
def getJob(self):
return self.job
class productOrder(Order):
def __init__(self, business, job, materialIndex, amount):
Order.__init__(self, business, job)
self.materialIndex = materialIndex
self.amount = amount
def getProductIndex(self):
return self.materialIndex
def getAmount(self):
return self.amount
def setAmount(self, amount):
self.amount = amount
class harvestOrder(productOrder):
def __init__(self, business, job, materialIndex):
productOrder.__init__(self, business, job, materialIndex, 1)
def execute(self):
self.job.harvest(self.materialIndex)
class craftOrder(productOrder):
def __init__(self, business, job, materialIndex, amount=1):
productOrder.__init__(self, business, job, materialIndex, amount)
def execute(self):
if d.is_planted(self.materialIndex):
self.job.plant(self.materialIndex, self.amount)
elif d.is_crafted(self.materialIndex):
self.job.craft(self.materialIndex, self.amount)
class transportOrder(productOrder):
def __init__(self, business, job, unit1, unit2, materialIndex, amount=1):
productOrder.__init__(self, business, job, materialIndex, amount)
self.unit1 = unit1
self.unit2 = unit2
def execute(self):
self.job.transportMats(self.unit1, self.unit2, self.materialIndex, self.amount)
def getStartUnit(self):
return self.unit1
def getEndUnit(self):
return self.unit2
class transferOrder(productOrder):
def __init__(self, business, job, unit, materialIndex, amount):
productOrder.__init__(self, business, job, materialIndex, amount)
self.unit = unit
def execute(self):
self.job.transferMats(self.unit, self.materialIndex, self.amount)
def getUnit(self):
return self.unit
class pricingOrder(Order):
def __init__(self, business, job, unit):
Order.__init__(self, business, job)
self.unit = unit
def execute(self):
self.job.updatePrices(self.unit)