Skip to content
Snippets Groups Projects
Commit 3fc8e4e2 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Added hook when returning items to dispensers.

parent a1f34c47
No related branches found
No related tags found
1 merge request!84Resolve "Hook when putting items back on dispenser"
Pipeline #48644 passed
This commit is part of merge request !84. Comments created here will be created in the context of that merge request.
...@@ -183,6 +183,7 @@ hook_callbacks: ...@@ -183,6 +183,7 @@ hook_callbacks:
- progress_started - progress_started
- progress_finished - progress_finished
- content_ready - content_ready
- dispenser_item_returned
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs: callback_class_kwargs:
......
...@@ -25,3 +25,4 @@ on_item_transition: "$item became $result." ...@@ -25,3 +25,4 @@ on_item_transition: "$item became $result."
progress_started: "Item $item started progressing." progress_started: "Item $item started progressing."
progress_finished: "Item $item finished its progress." progress_finished: "Item $item finished its progress."
content_ready: "Meal $result was created on $before." content_ready: "Meal $result was created on $before."
dispenser_item_returned: "Player $player returned $item to $counter."
\ No newline at end of file
...@@ -68,6 +68,7 @@ from cooperative_cuisine.hooks import ( ...@@ -68,6 +68,7 @@ from cooperative_cuisine.hooks import (
PRE_PLATE_DISPENSER_DROP_OFF, PRE_PLATE_DISPENSER_DROP_OFF,
PRE_PLATE_DISPENSER_PICK_UP, PRE_PLATE_DISPENSER_PICK_UP,
POST_PLATE_DISPENSER_PICK_UP, POST_PLATE_DISPENSER_PICK_UP,
DISPENSER_ITEM_RETURNED,
) )
from cooperative_cuisine.state_representation import CounterState from cooperative_cuisine.state_representation import CounterState
...@@ -511,6 +512,7 @@ class Dispenser(Counter): ...@@ -511,6 +512,7 @@ class Dispenser(Counter):
return return_this return return_this
def drop_off(self, item: Item, player: str = "0") -> Item | None: def drop_off(self, item: Item, player: str = "0") -> Item | None:
self.hook(DISPENSER_ITEM_RETURNED, player=player, counter=self, item=item)
if self.occupied_by.can_combine(item): if self.occupied_by.can_combine(item):
return self.occupied_by.combine(item) return self.occupied_by.combine(item)
......
...@@ -77,6 +77,8 @@ POST_PLATE_DISPENSER_PICK_UP = "post_plate_dispenser_pick_up" ...@@ -77,6 +77,8 @@ POST_PLATE_DISPENSER_PICK_UP = "post_plate_dispenser_pick_up"
PRE_PLATE_DISPENSER_DROP_OFF = "pre_plate_dispenser_drop_off" PRE_PLATE_DISPENSER_DROP_OFF = "pre_plate_dispenser_drop_off"
POST_PLATE_DISPENSER_DROP_OFF = "post_plate_dispenser_drop_off" POST_PLATE_DISPENSER_DROP_OFF = "post_plate_dispenser_drop_off"
DISPENSER_ITEM_RETURNED = "dispenser_item_returned"
CUTTING_BOARD_PROGRESS = "cutting_board_progress" CUTTING_BOARD_PROGRESS = "cutting_board_progress"
CUTTING_BOARD_100 = "cutting_board_100" CUTTING_BOARD_100 = "cutting_board_100"
......
...@@ -219,5 +219,5 @@ def print_recorded_events_human_readable(jsonl_path: Path): ...@@ -219,5 +219,5 @@ def print_recorded_events_human_readable(jsonl_path: Path):
if __name__ == "__main__": if __name__ == "__main__":
json_lines_path: Path = Path(sys.argv[0]) json_lines_path: Path = Path(sys.argv[1])
print_recorded_events_human_readable(json_lines_path) print_recorded_events_human_readable(json_lines_path)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment