2023-05-26 03:02:16 +02:00
|
|
|
import random
|
2023-05-05 02:56:22 +02:00
|
|
|
from src.obj.Object import Object
|
|
|
|
|
|
|
|
|
|
|
|
class Table(Object):
|
2023-05-26 03:02:16 +02:00
|
|
|
def __init__(self, position, orientation, square_size, screen_size):
|
|
|
|
super().__init__("order", position, orientation, square_size, screen_size)
|
|
|
|
self.order_time = 0
|
|
|
|
self.customers = 0
|
|
|
|
# roles = ["table", "order", "wait", "done"]
|
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
self.change_role("table")
|
|
|
|
self.order_time = 0
|
|
|
|
self.customers = 0
|
|
|
|
|
|
|
|
def set_order(self, current_time):
|
|
|
|
if self.agent_role == "table":
|
|
|
|
self.change_role("order")
|
|
|
|
self.customers = random.randint(1, 6)
|
|
|
|
self.order_time = current_time
|
|
|
|
|
|
|
|
def set_wait(self):
|
|
|
|
if self.agent_role == "order":
|
|
|
|
self.change_role("wait")
|
|
|
|
|
|
|
|
def set_done(self):
|
|
|
|
if self.agent_role == "wait":
|
|
|
|
self.change_role("done")
|
|
|
|
|
|
|
|
def is_order(self):
|
|
|
|
return self.agent_role == "order"
|
|
|
|
|
|
|
|
def is_wait(self):
|
|
|
|
return self.agent_role == "wait"
|
|
|
|
|
|
|
|
def is_done(self):
|
|
|
|
return self.agent_role == "done"
|
|
|
|
|
|
|
|
def get_customers_count(self) -> int:
|
|
|
|
return self.customers
|
|
|
|
|
|
|
|
def get_mood(self, current_time) -> str:
|
|
|
|
if self.agent_role == "table":
|
|
|
|
return None
|
|
|
|
|
|
|
|
diff = current_time - self.order_time
|
2023-06-01 12:44:29 +02:00
|
|
|
if diff < 100:
|
|
|
|
return (0, "good")
|
|
|
|
elif diff < 200:
|
|
|
|
return (1, "medium")
|
2023-05-26 03:02:16 +02:00
|
|
|
else:
|
2023-06-01 12:44:29 +02:00
|
|
|
return (2, "bad")
|
2023-05-26 03:02:16 +02:00
|
|
|
|
|
|
|
def action(self, waiter):
|
|
|
|
if self.is_order():
|
|
|
|
waiter.collect_order(self)
|
|
|
|
elif self.is_done():
|
|
|
|
waiter.deliver_dish(self)
|