Skip to content
Snippets Groups Projects
Commit 1af37406 authored by Florian Schröder's avatar Florian Schröder
Browse files

combine and drop off of stove and tomatos

parent 87ba0c35
No related branches found
No related tags found
1 merge request!10Resolve "Pot and stove and cooking tomato soup"
......@@ -15,6 +15,7 @@ from overcooked_simulator.game_items import (
Plate,
Tomato,
Pot,
Pan,
)
......@@ -208,11 +209,16 @@ class Stove(Counter):
occupied_by = Pot()
super().__init__(pos, occupied_by)
def pick_up(self):
pass
def drop_off(self, item) -> Item | None:
pass
if isinstance(item, (Pot, Pan)):
self.occupied_by = item
else:
self.occupied_by.combine(item)
return None
def can_drop_off(self, item) -> bool:
if isinstance(item, (Pot, Pan)):
return not self.occupied_by
if self.occupied_by:
return self.occupied_by.can_combine(item)
return False
......@@ -28,10 +28,10 @@ class Plate(Item):
class ProgressibleItem(Item):
"""Class for items which need to be processed (cut, cooked, ...)"""
def __init__(self, steps_needed):
self.progressed_steps = 0
def __init__(self, finished: bool = False, steps_needed: int = 1500):
self.progressed_steps = steps_needed if finished else 0
self.steps_needed = steps_needed
self.finished = False
self.finished = finished
super().__init__()
def progress(self):
......@@ -44,9 +44,9 @@ class ProgressibleItem(Item):
def __repr__(self):
if self.finished:
return "CutTomato"
return f"{self.__class__.__name__}()"
else:
return f"{self.__class__.__name__}({int(self.progressed_steps / self.steps_needed * 100)}%)"
return f"{self.__class__.__name__}(progress={int(self.progressed_steps / self.steps_needed * 100)}%)"
class CuttableItem(ProgressibleItem):
......@@ -66,28 +66,29 @@ class Tomato(CuttableItem):
class Pot(ProgressibleItem):
def can_combine(self, other):
return False
def __init__(self):
def __init__(self, holds: Item = None):
self.holds = [] if holds is None else holds
super().__init__(steps_needed=1500)
def combine(self, other):
pass
def can_combine(self, other):
# TODO based on recipes
return (
isinstance(other, Tomato)
# and other.finished
and len(self.holds) < 3
and all([isinstance(h, Tomato) for h in self.holds])
)
def __repr__(self):
return f"{self.__class__.__name__}()"
def combine(self, other):
self.holds.append(other)
class Pan(ProgressibleItem):
def can_combine(self, other):
return False
def __init__(self):
super().__init__(steps_needed=1500)
def can_combine(self, other):
return False
def combine(self, other):
pass
def __repr__(self):
return f"{self.__class__.__name__}()"
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