-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipe.py
91 lines (76 loc) · 2.48 KB
/
recipe.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
from ingredients import *
class Recipe:
def __init__(self, location, index=-1):
self.layers = 0
self.index = index
self.contains = []
self.name = 'Recipe'
self.holded = False
self.location = location
self.delivered = False
def __str__(self):
return f"{self.name}: {self._str_list(self.contains)}"
def _str_list(self, item_list):
item_list = [str(item) for item in item_list]
return ", ".join(item_list)
def __eq__(self, other):
if not isinstance(other, Recipe) or self.layers != other.layers:
return False
return self._str_list(self.contains) == self._str_list(other.contains)
def add(self, obj):
self.contains.append(obj)
self.layers += 1
def move_to(self, location):
self.location = location
def trim(self, layers):
recipe = Recipe(self.location)
recipe.contains = self.contains[:layers]
recipe.layers = layers
return recipe
def full(self):
return self.layers >= 7
class VeggieBurger(Recipe):
def __init__(self):
super().__init__(None)
self.name = 'VeggieBurger'
self.add(Bread(None))
# self.add(Tomato(None).chop())
# self.add(Lettuce(None).chop())
self.add(Tomato(None))
self.add(Lettuce(None))
self.add(Bread(None))
class CheeseVeggieBurger(Recipe):
def __init__(self):
super().__init__(None)
self.name = 'CheeseVeggieBurger'
self.add(Bread(None))
# self.add(Tomato(None).chop())
# self.add(Lettuce(None).chop())
self.add(Tomato(None))
self.add(Cheese(None))
self.add(Lettuce(None))
self.add(Bread(None))
class DoubleCheeseBurger(Recipe):
def __init__(self):
super().__init__(None)
self.name = 'DoubleCheeseBurger'
self.add(Bread(None))
self.add(Cheese(None))
self.add(Pork(None).grill())
self.add(Cheese(None))
self.add(Bread(None))
class ClassicBurger(Recipe):
def __init__(self):
super().__init__(None)
self.name = 'ClassicBurger'
self.add(Bread(None))
self.add(Lettuce(None).chop())
self.add(Pork(None).grill())
self.add(Tomato(None).chop())
self.add(Cheese(None))
self.add(Bread(None))
class JustBread(Recipe):
def __init__(self):
super().__init__(None)
self.name = 'JustBread'
self.add(Bread(None))