diff --git a/overcooked_simulator/counters.py b/overcooked_simulator/counters.py index c91a62d08b4024626e6d093d5a5faa3f5b9da694..cff964c51dc8cd6f2cf55036814ac4989a7096da 100644 --- a/overcooked_simulator/counters.py +++ b/overcooked_simulator/counters.py @@ -142,10 +142,15 @@ class CuttingBoard(Counter): class ServingWindow(Counter): def __init__( - self, pos, game_score: GameScore, plate_dispenser: PlateDispenser = None + self, + pos, + game_score: GameScore, + meals: list[str], + plate_dispenser: PlateDispenser = None, ): self.game_score = game_score self.plate_dispenser = plate_dispenser + self.meals = meals super().__init__(pos) def drop_off(self, item) -> Item | None: @@ -157,22 +162,11 @@ class ServingWindow(Counter): self.plate_dispenser.update_plate_out_of_kitchen() return None - def can_score(self, item): - if ( - isinstance(item, CookingEquipment) - and "Plate" in item.name - and item.content is not None - ): - if isinstance(item.content, Meal) and item.content.progressed_steps: - return item.content.finished - if not item.content.item_info.steps_needed and len( - item.content.item_info.needs - ) == len(item.content.parts): - return True - return False - def can_drop_off(self, item: Item) -> bool: - return self.can_score(item) + return isinstance(item, CookingEquipment) and ( + (item.content_ready is not None and item.content_ready.name in self.meals) + or (len(item.content_list) == 1 and item.content_list[0].name in self.meals) + ) def pick_up(self, on_hands: bool = True): pass @@ -250,7 +244,7 @@ class PlateDispenser(Counter): return None def add_dirty_plate(self): - self.occupied_by.appendleft(self.dispensing.create_item()) + self.occupied_by.appendleft(self.create_item()) def update_plate_out_of_kitchen(self): """Is called from the serving window to add a plate out of kitchen.""" diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index b5b849c2ebf763225b9ee978955b2996ab86643f..43bb3994d14ba30b28f2c33e852f55a86783f1d2 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -112,7 +112,15 @@ class Environment: }, ), "X": Trash, - "W": lambda pos: ServingWindow(pos, self.game_score), + "W": lambda pos: ServingWindow( + pos, + self.game_score, + meals={ + item + for item, info in self.item_info.items() + if info.type == ItemType.Meal + }, + ), "T": lambda pos: Dispenser(pos, self.item_info["Tomato"]), "L": lambda pos: Dispenser(pos, self.item_info["Lettuce"]), "P": lambda pos: PlateDispenser(