import pygame from models.Object import Object from models.Table import Table class Waiter(Object): def __init__(self, square_size, screen_size, left_square, top_square): super().__init__( 'waiter', square_size, screen_size, left_square, top_square ) self.orders_limit = 3 self.orders_list = [] def do_smth(self, table: Table): if table.is_order(): self.take_order(table) elif table.is_done(): self.deliver_order(table) def take_order(self, table: Table): if self.orders_limit <= 0: return if not table.is_order(): return self.orders_limit -= 1 self.orders_list.append(table) table.wait_order() def deliver_order(self, table: Table): if table.is_done() and table in self.orders_list: self.orders_limit += 1 self.orders_list.remove(table) table.reset_order() def get_order_list(self) -> list[Table]: return self.orders_list