diff --git a/.idea/ProjektAI.iml b/.idea/ProjektAI.iml
index fc82b32..d9e6024 100644
--- a/.idea/ProjektAI.iml
+++ b/.idea/ProjektAI.iml
@@ -2,10 +2,7 @@
-
+
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 2ba285b..a5061af 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/kelner/images/kitchen.png b/kelner/images/kitchen.png
new file mode 100644
index 0000000..f26d55a
Binary files /dev/null and b/kelner/images/kitchen.png differ
diff --git a/kelner/main.py b/kelner/main.py
index 041ebda..602d3d7 100644
--- a/kelner/main.py
+++ b/kelner/main.py
@@ -2,6 +2,7 @@ import pygame
from kelner.src.components.GridBoard import GridBoard
from kelner.src.components.Waiter import Waiter
from kelner.src.components.Table import Table
+from kelner.src.components.Kitchen import Kitchen
from kelner.src.managers.DrawableCollection import DrawableCollection
from kelner.src.managers.MenuManager import MenuManager
from kelner.src.managers.TableManager import TableManager
@@ -61,19 +62,24 @@ else:
print("test4: fail")
-
# initialize waiter component
waiter1 = Waiter(0, 0, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
-waiter2 = Waiter(0, GridCountY - 1, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
-waiter3 = Waiter(GridCountX - 1, 0, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
-waiter4 = Waiter(GridCountX - 1, GridCountY - 1, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
+# waiter2 = Waiter(0, GridCountY - 1, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
+# waiter3 = Waiter(GridCountX - 1, 0, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
+# waiter4 = Waiter(GridCountX - 1, GridCountY - 1, 0, GridCountX - 1, 0, GridCountY - 1, CellSize, PaintOffset)
# adds waiter to drawable collection
drawableManager.add(waiter1)
-drawableManager.add(waiter2)
-drawableManager.add(waiter3)
-drawableManager.add(waiter4)
+# drawableManager.add(waiter2)
+# drawableManager.add(waiter3)
+# drawableManager.add(waiter4)
+
+
+# TODO: create kitchen
+#kitchen = Kitchen(5, GridCountX-5, 5, GridCountY-5, CellSize, PaintOffset)
+#drawableManager.add(kitchen)
+
#My comment
# initialize a number of tables given in range
for i in range(0, 40):
@@ -89,14 +95,14 @@ tableTask.start()
waiter1Task = WaiterManager(drawableManager, [waiter1])
waiter1Task.start()
-waiter2Task = WaiterManager(drawableManager, [waiter2])
-waiter2Task.start()
-
-waiter3Task = WaiterManager(drawableManager, [waiter3])
-waiter3Task.start()
-
-waiter4Task = WaiterManager(drawableManager, [waiter4])
-waiter4Task.start()
+# waiter2Task = WaiterManager(drawableManager, [waiter2])
+# waiter2Task.start()
+#
+# waiter3Task = WaiterManager(drawableManager, [waiter3])
+# waiter3Task.start()
+#
+# waiter4Task = WaiterManager(drawableManager, [waiter4])
+# waiter4Task.start()
# main loop
running = True
@@ -106,9 +112,9 @@ while running:
if event.type == pygame.QUIT:
tableTask.stop()
waiter1Task.stop()
- waiter2Task.stop()
- waiter3Task.stop()
- waiter4Task.stop()
+ # waiter2Task.stop()
+ # waiter3Task.stop()
+ # waiter4Task.stop()
running = False
# handles keyboard events
diff --git a/kelner/src/components/Drawable.py b/kelner/src/components/Drawable.py
index 694a226..f8da18c 100644
--- a/kelner/src/components/Drawable.py
+++ b/kelner/src/components/Drawable.py
@@ -1,3 +1,6 @@
+from kelner.src.managers.ImageCache import ImageCache, Images
+
+
class Drawable:
def __init__(self, x, y, minX, maxX, minY, maxY, cellSize, offset):
@@ -56,3 +59,12 @@ class Drawable:
def drawAux(self, screen):
pass
+
+ def getImage(self, imageKind):
+ if imageKind in [Images.Guest1, Images.Guest2, Images.Guest3, Images.Plate]:
+ size = int(self.getCellSize() / 3)
+ elif imageKind in [Images.Kitchen]:
+ size = int(self.getCellSize())
+ else:
+ size = int(1.4 * self.getCellSize())
+ return ImageCache.getInstance().getImage(imageKind, size, size)
diff --git a/kelner/src/components/Kitchen.py b/kelner/src/components/Kitchen.py
new file mode 100644
index 0000000..8591573
--- /dev/null
+++ b/kelner/src/components/Kitchen.py
@@ -0,0 +1,32 @@
+import random
+from enum import Enum
+from threading import Lock
+from kelner.src.components.Drawable import Drawable
+from kelner.src.managers.ImageCache import ImageCache, Images
+from kelner.src.algorithms.DecisionTree import Tree_Builder
+import os
+
+
+class Kitchen(Drawable):
+ def __init__(self, minX, maxX, minY, maxY, cellSize, offset):
+ # call base class constructor
+ super().__init__(0, 0, minX, maxX, minY, maxY, cellSize, offset)
+ self._preparing_orders = []
+ self._ready_orders = []
+ self._photos_path = os.path.join(os.getcwd(), 'foodImages')
+
+ def get_new_orders(self, orders):
+ self._preparing_orders.append(orders)
+
+ def draw(self, screen):
+ xBase = self.getX() * self.getCellSize() + self.getOffset()
+ yBase = self.getY() * self.getCellSize() + self.getOffset()
+ tableXYOffset = int(0.2 * self.getCellSize())
+ image = self.getImage(Images.Kitchen)
+ screen.blit(image, (xBase - tableXYOffset, yBase - tableXYOffset))
+
+
+ def drawAux(self, screen):
+ pass
+
+
diff --git a/kelner/src/components/Waiter.py b/kelner/src/components/Waiter.py
index a9e3e4d..ffda9da 100644
--- a/kelner/src/components/Waiter.py
+++ b/kelner/src/components/Waiter.py
@@ -104,6 +104,9 @@ class Waiter(Drawable):
# accepts orders from the table and stores them in queue
def addOrder(self, table, order):
self.__acceptedOrders += [(table, order)]
+
+ def getAcceptedOrders(self):
+ return self.__acceptedOrders
def isPathEmpty(self):
return self.__currentPath == []
diff --git a/kelner/src/managers/ImageCache.py b/kelner/src/managers/ImageCache.py
index f1ad355..a34aa77 100644
--- a/kelner/src/managers/ImageCache.py
+++ b/kelner/src/managers/ImageCache.py
@@ -21,6 +21,7 @@ class Images(Enum):
Guest2 = 14
Guest3 = 15
ToolTip = 16
+ Kitchen = 17
class ImageCache:
@@ -56,7 +57,8 @@ class ImageCache:
Images.Guest1: './images/wiking_blond.png',
Images.Guest2: './images/wiking_rudy.png',
Images.Guest3: './images/wiking_rudy2.png',
- Images.ToolTip: './images/tooltip.png'}
+ Images.ToolTip: './images/tooltip.png',
+ Images.Kitchen: './images/kitchen.png'}
def __getFont(self):
if self.__font is None:
diff --git a/kelner/src/managers/KitchenManager.py b/kelner/src/managers/KitchenManager.py
new file mode 100644
index 0000000..d615369
--- /dev/null
+++ b/kelner/src/managers/KitchenManager.py
@@ -0,0 +1,23 @@
+import threading
+import time
+import sys
+
+
+# creates new thread
+class KitchenManager(threading.Thread):
+
+ def __init__(self, drawable_manager, images_storage):
+ super().__init__()
+ self._drawable_manager = drawable_manager
+ self._runThread = True
+ self._images_storage = images_storage
+
+ def prepare_dish(self):
+ pass
+
+ def run(self):
+ while self._runThread:
+ pass
+
+ def stop(self):
+ self._runThread = False
diff --git a/kelner/src/managers/TableManager.py b/kelner/src/managers/TableManager.py
index c824a00..7e3339c 100644
--- a/kelner/src/managers/TableManager.py
+++ b/kelner/src/managers/TableManager.py
@@ -20,7 +20,7 @@ class TableManager (threading.Thread):
if tables:
tableIndex = random.randint(0, len(tables) - 1)
table = tables[tableIndex]
- time.sleep(3)
+ time.sleep(5)
table.setOrder(self.__menuManager.generateOrder())
table.setStatus(Status.Ready)
self.__drawableManager.forceRepaint()
diff --git a/kelner/src/managers/WaiterManager.py b/kelner/src/managers/WaiterManager.py
index 056f00a..e3e74f9 100644
--- a/kelner/src/managers/WaiterManager.py
+++ b/kelner/src/managers/WaiterManager.py
@@ -82,16 +82,19 @@ class WaiterManager (threading.Thread):
while self.__runThread:
if self.__waiters:
for waiter in self.__waiters:
- path = self.__getNearestTargetPath(waiter)
- waiter.setPath([] if path is None else path)
+ if len(waiter.getAcceptedOrders()) < 5:
+ path = self.__getNearestTargetPath(waiter)
+ waiter.setPath([] if path is None else path)
- if not waiter.isPathEmpty():
- step = waiter.popStepFromPath()
- self.__changeWaiterDirection(waiter, step[0], step[1])
- self.__moveWaiter(waiter, step[0], step[1])
+ if not waiter.isPathEmpty():
+ step = waiter.popStepFromPath()
+ self.__changeWaiterDirection(waiter, step[0], step[1])
+ self.__moveWaiter(waiter, step[0], step[1])
- if waiter.isPathEmpty():
- self.__collectOrder(waiter)
+ if waiter.isPathEmpty():
+ self.__collectOrder(waiter)
+ else:
+ waiter.goToKitchen()
def stop(self):
self.__runThread = False