improved color indication of orders, added penalty points
This commit is contained in:
parent
f8b64076e2
commit
4f97da84bf
@ -25,6 +25,8 @@
|
||||
|
||||
> **F** - _show or hide fringes_
|
||||
|
||||
> **P** - _penalty time_
|
||||
|
||||
> **SPACE** - _pause or continue_
|
||||
|
||||
## TODO
|
||||
|
@ -123,10 +123,13 @@ class Engine:
|
||||
if self.waiter.on(o.position):
|
||||
o.action(self.waiter, self.action_clock)
|
||||
|
||||
if self.waiter.on(self.kitchen.position):
|
||||
self.kitchen.action(self.waiter, self.action_clock)
|
||||
self.kitchen.action(self.waiter, self.action_clock)
|
||||
|
||||
# STEP 6. Wait
|
||||
# STEP 6. Update kitchen state
|
||||
|
||||
self.kitchen.updateMark()
|
||||
|
||||
# STEP 7. Wait
|
||||
|
||||
time.sleep(self.action_duration)
|
||||
|
||||
|
@ -22,3 +22,6 @@ class UserController:
|
||||
print(colored("Paused", "red"))
|
||||
else:
|
||||
print(colored("Continued", "green"))
|
||||
elif event.key == pygame.K_p:
|
||||
print(colored("Penalty time: 100", "red"))
|
||||
engine.clock_increment(100)
|
||||
|
@ -1,5 +1,6 @@
|
||||
from src.obj.Object import Object
|
||||
from src.obj.Table import Table
|
||||
from src.obj.Mark import Mark
|
||||
|
||||
|
||||
class Kitchen(Object):
|
||||
@ -7,22 +8,44 @@ class Kitchen(Object):
|
||||
super().__init__("kitchen", position, orientation, square_size, screen_size, store)
|
||||
self.cooking: list(Table) = []
|
||||
self.done: list(Table) = []
|
||||
self.mark = None
|
||||
|
||||
def updateMark(self):
|
||||
if self.done:
|
||||
self.setMark("dish_done")
|
||||
elif self.cooking:
|
||||
self.setMark("dish_cooking")
|
||||
else:
|
||||
self.unsetMark()
|
||||
|
||||
def setMark(self, mark_type):
|
||||
self.mark = Mark(self, mark_type)
|
||||
|
||||
def unsetMark(self):
|
||||
self.mark = None
|
||||
|
||||
def blit(self, screen):
|
||||
super().blit(screen)
|
||||
if self.mark:
|
||||
self.mark.blit(screen)
|
||||
|
||||
def action(self, waiter, current_time):
|
||||
self.cook_dishes(current_time)
|
||||
waiter.combine_orders(current_time, self)
|
||||
waiter.recharge()
|
||||
if waiter.on(self.position):
|
||||
waiter.combine_orders(current_time, self)
|
||||
waiter.recharge()
|
||||
|
||||
def cook_dishes(self, current_time):
|
||||
for table in self.cooking:
|
||||
if table.dish_is_ready(current_time):
|
||||
self.done.append(table)
|
||||
table.setMark("dish_done")
|
||||
|
||||
for table in self.done:
|
||||
if table in self.cooking:
|
||||
self.cooking.remove(table)
|
||||
|
||||
self.updateMark()
|
||||
|
||||
def take_order(self, order):
|
||||
order.start_cooking()
|
||||
order.setMark("dish_cooking")
|
||||
|
@ -43,7 +43,7 @@ class Table(Object):
|
||||
self.change_role(new_role, current_time)
|
||||
|
||||
if self.agent_role == "wait":
|
||||
self.cooking_time = random.randint(0, 1000)
|
||||
self.cooking_time = random.randint(0, 500)
|
||||
|
||||
def dish_is_ready(self, current_time):
|
||||
return current_time - self.waiting_time > self.cooking_time
|
||||
@ -80,10 +80,11 @@ class Table(Object):
|
||||
|
||||
def start_cooking(self):
|
||||
if self.agent_role == "wait":
|
||||
self.cooking_time = random.randint(0, 1000)
|
||||
self.cooking_time = random.randint(0, 500)
|
||||
|
||||
def set_done(self, current_time):
|
||||
if self.agent_role == "wait":
|
||||
self.setMark("dish_done")
|
||||
self.change_role("done", current_time)
|
||||
|
||||
def is_order(self):
|
||||
|
Loading…
Reference in New Issue
Block a user