diff --git a/cooperative_cuisine/configs/environment_config.yaml b/cooperative_cuisine/configs/environment_config.yaml index e63620d0843c21a7f77e0dbf92538a5acc0c1779..e9188198069ad26875177645f39bcf8d39f1838d 100644 --- a/cooperative_cuisine/configs/environment_config.yaml +++ b/cooperative_cuisine/configs/environment_config.yaml @@ -183,6 +183,7 @@ hook_callbacks: - progress_started - progress_finished - content_ready + - dispenser_item_returned callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' callback_class_kwargs: diff --git a/cooperative_cuisine/configs/human_readable_print_templates.yaml b/cooperative_cuisine/configs/human_readable_print_templates.yaml index b190f6bccf1f0a3a3c580a8e37dd4c5f05e56365..cb9c47e9d634a2a320ec0456858e58a444e021fb 100644 --- a/cooperative_cuisine/configs/human_readable_print_templates.yaml +++ b/cooperative_cuisine/configs/human_readable_print_templates.yaml @@ -25,3 +25,4 @@ on_item_transition: "$item became $result." progress_started: "Item $item started progressing." progress_finished: "Item $item finished its progress." content_ready: "Meal $result was created on $before." +dispenser_item_returned: "Player $player returned $item to $counter." \ No newline at end of file diff --git a/cooperative_cuisine/counters.py b/cooperative_cuisine/counters.py index cd84be94e982e3c6e49ecefd501dbe075be84237..bf97c26b5886f738d122c282e8aa57cbcfe3d113 100644 --- a/cooperative_cuisine/counters.py +++ b/cooperative_cuisine/counters.py @@ -68,6 +68,7 @@ from cooperative_cuisine.hooks import ( PRE_PLATE_DISPENSER_DROP_OFF, PRE_PLATE_DISPENSER_PICK_UP, POST_PLATE_DISPENSER_PICK_UP, + DISPENSER_ITEM_RETURNED, ) from cooperative_cuisine.state_representation import CounterState @@ -511,6 +512,7 @@ class Dispenser(Counter): return return_this 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): return self.occupied_by.combine(item) diff --git a/cooperative_cuisine/hooks.py b/cooperative_cuisine/hooks.py index f16b10afe108fd2572ba801a01d0dca679882e21..c541562b25e7018c8442e3a0b562af5b8ae40b99 100644 --- a/cooperative_cuisine/hooks.py +++ b/cooperative_cuisine/hooks.py @@ -77,6 +77,8 @@ POST_PLATE_DISPENSER_PICK_UP = "post_plate_dispenser_pick_up" PRE_PLATE_DISPENSER_DROP_OFF = "pre_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_100 = "cutting_board_100" diff --git a/cooperative_cuisine/recording.py b/cooperative_cuisine/recording.py index a71cc0b3654b67f238798726e19c756a2f1f8111..2ed4f9ec8d8fc5c5ffea4059b8dc35f396790e7a 100644 --- a/cooperative_cuisine/recording.py +++ b/cooperative_cuisine/recording.py @@ -219,5 +219,5 @@ def print_recorded_events_human_readable(jsonl_path: Path): 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)