import random from src.obj.Object import Object class Table(Object): 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 waiting_for_dish(self): return self.agent_role in ["wait", "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 if diff < 200: return "good" elif diff < 400: return "medium" else: return "bad" def action(self, waiter): if self.is_order(): waiter.collect_order(self) elif self.is_done(): waiter.deliver_dish(self)