Skip to content
Snippets Groups Projects
Commit 636263c2 authored by Annika Österdiekhoff's avatar Annika Österdiekhoff
Browse files

current status, missing possibility to drop tomato on plate return

parent 085defd6
No related branches found
No related tags found
1 merge request!8Resolve "Can put tomatos on returned plate"
Pipeline #41451 passed
......@@ -122,13 +122,37 @@ class PlateReturn(Counter):
self.occupied_by = Plate()
def pick_up(self):
return Plate()
"""Gets called upon a player performing the pickup action. Gives back a plate (possibly with ingredient.
def drop_off(self, item):
return 0
Returns: A plate possibly with an ingredient on it.
def can_drop_off(self, item):
return False
"""
give_player = self.occupied_by
self.occupied_by = Plate()
return give_player
def drop_off(self, item: HoldableItem):
"""Takes the ingredient dropped of by the player.
Args:
item: The ingredient to be placed on the counter.
"""
if item is Plate() and self.occupied_by is Plate():
self.occupied_by = None
def can_drop_off(self, item: HoldableItem):
"""Checks whether an ingredient by the player can be dropped of.
Args:
item: The ingredient for which to check, if it can be placed on the counter.
Returns: True if the ingredient can be placed on the counter, False if not.
"""
# possibility to drop off empty plate on empty plate return
return (
isinstance(self.occupied_by, Plate) and isinstance(item, Plate)
) or self.occupied_by.can_combine(item)
def __repr__(self):
return "PlateReturn"
......
......@@ -18,7 +18,7 @@ class Plate(HoldableItem):
super().__init__()
def can_combine(self, other: HoldableItem):
return self.holds is None
return self.holds is None and not isinstance(other, Plate)
def combine(self, other):
self.holds = other
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment