Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
a983d27e
Commit
a983d27e
authored
10 months ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Added more information to some hook regarding how items were before the hook
parent
a59d109a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!96
More hook updates
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cooperative_cuisine/counters.py
+25
-15
25 additions, 15 deletions
cooperative_cuisine/counters.py
cooperative_cuisine/items.py
+6
-2
6 additions, 2 deletions
cooperative_cuisine/items.py
cooperative_cuisine/player.py
+2
-2
2 additions, 2 deletions
cooperative_cuisine/player.py
with
33 additions
and
19 deletions
cooperative_cuisine/counters.py
+
25
−
15
View file @
a983d27e
...
...
@@ -34,6 +34,7 @@ The defined counter classes are:
"""
from
__future__
import
annotations
import
copy
import
dataclasses
import
logging
import
uuid
...
...
@@ -69,7 +70,7 @@ from cooperative_cuisine.hooks import (
PRE_PLATE_DISPENSER_PICK_UP
,
POST_PLATE_DISPENSER_PICK_UP
,
DISPENSER_ITEM_RETURNED
,
DROP_OFF_ON_COOKING_EQUIPMENT_PLATE_DISPENSER
,
DROP_OFF_ON_COOKING_EQUIPMENT_PLATE_DISPENSER
,
PICK_UP_ON_COOKING_EQUIPMENT
,
)
from
cooperative_cuisine.state_representation
import
CounterState
...
...
@@ -150,7 +151,7 @@ class Counter:
self
.
orientation
=
orientation
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
|
Iterable
[
Item
]:
"""
Gets called upon a player performing the pickup action. If the counter can give something to
the player, it does so. In the standard counter this is when an item is on the counter.
...
...
@@ -158,6 +159,7 @@ class Counter:
Args:
on_hands: Will the item be put on empty hands or on a cooking equipment.
player: The player name that tries to pick up from the counter.
player_holding: What the player is currently holding.
Returns:
The item which the counter is occupied by. None if nothing is there.
...
...
@@ -172,18 +174,20 @@ class Counter:
counter
=
self
,
on_hands
=
on_hands
,
return_this
=
occupied_by
,
player
=
player
player
=
player
,
player_holding
=
player_holding
,
)
return
occupied_by
return
None
if
self
.
occupied_by
and
isinstance
(
self
.
occupied_by
,
CookingEquipment
):
return_this
=
self
.
occupied_by
.
release
()
self
.
hook
(
POST_COUNTER_PICK_UP
,
counter
=
self
,
on_hands
=
on_hands
,
PICK_UP_ON_COOKING_EQUIPMENT
,
return_this
=
return_this
,
occupied_by
=
self
.
occupied_by
,
counter
=
self
,
player
=
player
,
player_holding
=
player_holding
,
)
return
return_this
occupied_by
=
self
.
occupied_by
...
...
@@ -194,6 +198,7 @@ class Counter:
on_hands
=
on_hands
,
return_this
=
occupied_by
,
player
=
player
,
player_holding
=
player_holding
,
)
return
occupied_by
...
...
@@ -236,12 +241,15 @@ class Counter:
item
=
item
,
)
elif
self
.
occupied_by
.
can_combine
(
item
):
before_combine
=
copy
.
copy
(
item
)
occupied_before_combine
=
copy
.
deepcopy
(
self
.
occupied_by
)
return_this
=
self
.
occupied_by
.
combine
(
item
)
self
.
hook
(
DROP_OFF_ON_COOKING_EQUIPMENT
,
item
=
item
,
item
=
before_combine
,
equipment
=
self
.
occupied_by
,
counter
=
self
,
occupied_before
=
occupied_before_combine
,
player
=
player
,
return_this
=
return_this
,
)
...
...
@@ -419,11 +427,12 @@ class CuttingBoard(Counter):
passed_time
=
passed_time
,
)
if
self
.
occupied_by
.
progress_percentage
==
1.0
:
item_before
=
copy
.
copy
(
self
.
occupied_by
)
self
.
occupied_by
.
reset
()
self
.
occupied_by
.
name
=
self
.
inverted_transition_dict
[
self
.
occupied_by
.
name
].
name
self
.
hook
(
CUTTING_BOARD_100
,
counter
=
self
,
item
=
self
.
occupied_by
,
player
=
player
)
self
.
hook
(
CUTTING_BOARD_100
,
counter
=
self
,
item
=
self
.
occupied_by
,
player
=
player
,
before
=
item_before
)
class
ServingWindow
(
Counter
):
...
...
@@ -489,7 +498,7 @@ class ServingWindow(Counter):
or
(
len
(
item
.
content_list
)
==
1
and
item
.
content_list
[
0
].
name
in
self
.
meals
)
)
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
:
pass
def
add_plate_dispenser
(
self
,
plate_dispenser
):
...
...
@@ -524,7 +533,7 @@ class Dispenser(Counter):
**
kwargs
,
)
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
:
self
.
hook
(
PRE_DISPENSER_PICK_UP
,
counter
=
self
,
on_hands
=
on_hands
,
player
=
player
)
return_this
=
self
.
occupied_by
self
.
occupied_by
=
self
.
create_item
()
...
...
@@ -534,6 +543,7 @@ class Dispenser(Counter):
on_hands
=
on_hands
,
return_this
=
return_this
,
player
=
player
,
player_holding
=
player_holding
,
)
return
return_this
...
...
@@ -628,7 +638,7 @@ class PlateDispenser(Counter):
"""
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
:
self
.
hook
(
PRE_PLATE_DISPENSER_PICK_UP
,
counter
=
self
,
...
...
@@ -757,7 +767,7 @@ class Trashcan(Counter):
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
:
pass
def
drop_off
(
self
,
item
:
Item
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
...
...
@@ -921,7 +931,7 @@ class Sink(Counter):
self
.
hook
(
ADDED_PLATE_TO_SINK
,
counter
=
self
,
item
=
item
,
player
=
player
)
return
None
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
:
return
None
def
set_addon
(
self
,
sink_addon
:
SinkAddon
):
...
...
@@ -947,14 +957,14 @@ class SinkAddon(Counter):
return
self
.
occupied_by
and
self
.
occupied_by
[
-
1
].
can_combine
(
item
)
def
drop_off
(
self
,
item
:
Item
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
self
.
hook
(
DROP_ON_SINK_ADDON
,
counter
=
self
,
item
=
item
,
player
=
player
)
self
.
hook
(
DROP_ON_SINK_ADDON
,
counter
=
self
,
item
=
item
,
occupied_by
=
self
.
occupied_by
[
-
1
],
player
=
player
)
return
self
.
occupied_by
[
-
1
].
combine
(
item
)
def
add_clean_plate
(
self
,
plate
:
Plate
):
"""
Called from the `Sink` after a plate is cleaned / the progress is complete.
"""
self
.
occupied_by
.
appendleft
(
plate
)
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
)
->
Item
|
None
:
def
pick_up
(
self
,
on_hands
:
bool
=
True
,
player
:
str
=
"
0
"
,
player_holding
:
Item
|
None
=
None
,
)
->
Item
|
None
:
if
self
.
occupied_by
:
self
.
hook
(
PICK_UP_FROM_SINK_ADDON
,
...
...
This diff is collapsed.
Click to expand it.
cooperative_cuisine/items.py
+
6
−
2
View file @
a983d27e
...
...
@@ -23,6 +23,7 @@ Additionally, the `Effect` class is defined for the `Fire` effect.
from
__future__
import
annotations
import
collections
import
copy
import
dataclasses
import
datetime
import
logging
...
...
@@ -186,6 +187,7 @@ class Item:
self
.
active_effects
:
list
[
Effect
]
=
[]
"""
The effects that affect the item.
"""
@property
def
extra_repr
(
self
)
->
str
|
Literal
[
""
]:
"""
Additional string to add to the representation of the item (in __repr__).
"""
...
...
@@ -343,8 +345,9 @@ class CookingEquipment(Item):
self
.
active_transition
[
"
result
"
],
self
)
else
:
before
=
copy
.
copy
(
self
)
self
.
content_list
=
[
self
.
active_transition
[
"
result
"
]]
self
.
hook
(
PROGRESS_FINISHED
,
item
=
self
)
self
.
hook
(
PROGRESS_FINISHED
,
item
=
self
,
before
=
before
)
self
.
reset
()
self
.
check_active_transition
()
...
...
@@ -379,8 +382,9 @@ class CookingEquipment(Item):
if
ingredients
==
transition
.
recipe
:
# TODO here hook?
if
transition
.
seconds
==
0
:
self
.
hook
(
CONTENT_READY
,
result
=
result
,
before
=
self
)
before
=
copy
.
deepcopy
(
self
)
self
.
content_ready
=
Item
(
name
=
result
,
item_info
=
transition
)
self
.
hook
(
CONTENT_READY
,
result
=
self
,
before
=
before
)
else
:
self
.
active_transition
=
{
"
seconds
"
:
transition
.
seconds
,
...
...
This diff is collapsed.
Click to expand it.
cooperative_cuisine/player.py
+
2
−
2
View file @
a983d27e
...
...
@@ -162,7 +162,7 @@ class Player:
"""
if
self
.
holding
is
None
:
self
.
holding
=
counter
.
pick_up
(
player
=
self
.
name
)
self
.
holding
=
counter
.
pick_up
(
player
=
self
.
name
,
player_holding
=
self
.
holding
)
elif
counter
.
can_drop_off
(
self
.
holding
):
self
.
holding
=
counter
.
drop_off
(
self
.
holding
,
player
=
self
.
name
)
...
...
@@ -170,7 +170,7 @@ class Player:
elif
not
isinstance
(
counter
.
occupied_by
,
(
list
,
deque
)
)
and
self
.
holding
.
can_combine
(
counter
.
occupied_by
):
returned_by_counter
=
counter
.
pick_up
(
on_hands
=
False
,
player
=
self
.
name
)
returned_by_counter
=
counter
.
pick_up
(
on_hands
=
False
,
player
=
self
.
name
,
player_holding
=
self
.
holding
)
self
.
holding
.
combine
(
returned_by_counter
)
log
.
debug
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment