Advertisement
Guest User

bon vieux philRG :-D

a guest
Jul 6th, 2022
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.59 KB | None | 0 0
  1.         '''    
  2.            [x] Select order to deliver
  3.                [x] Cook any dessert included in selected order if dessert not already in the kitchen
  4.                [x] If dessert is cooked, put it on a table
  5.                [x] When no more dessert to cook, fetch a dish, and pick desserts included in order (following order)
  6.        '''
  7.  
  8.     def play_wood2(self):
  9.         myChef: Player = self.players[0]
  10.         # GAME LOGIC
  11.         # Select order to deliver
  12.         order: Order = max(self.orders, key=lambda x: x.award)
  13.         desserts_to_cook: List[Dessert] = order.desserts_to_cook(tables=self.tables)
  14.         debug(f'desserts_to_cook = {desserts_to_cook}')
  15.         if myChef.can_deliver(order):
  16.             self.use(pos=self.Window.pos)
  17.         else:
  18.             if myChef.cooking_dessert:
  19.                 debug(f'cooking dessert {myChef.cooking_dessert}')
  20.                 if myChef.cooking_dessert.name == myChef.item.content:
  21.                     # dessert finished, put dessert on table
  22.                     myChef.cooking_dessert = False
  23.                     debug(f'leaving dessert {myChef.item.content} on table')
  24.                     # if dessert ready (my chef carries it), find available table to put it on
  25.                     available_tables: List[Table] = [t for t in self.tables if not t.item]
  26.                     closest_table: Table = min(available_tables, key=lambda t: t.pos.manhattan(myChef.pos))
  27.                     self.use(pos=closest_table.pos)
  28.                 else:
  29.                     self.cook_action(player=myChef, dessert=myChef.cooking_dessert)
  30.             else:
  31.                 # if my check is not already cooking a dessert, check if my chef needs to cook a dessert
  32.                 if desserts_to_cook:
  33.                     myChef.cooking_dessert = random.choice(desserts_to_cook)
  34.                     self.cook_action(player=myChef, dessert=myChef.cooking_dessert)
  35.                 else:
  36.                     # No more dessert to cook, start collecting them
  37.                     self.collect_action(order=order)
  38.  
  39.     def play_wood3(self):
  40.         myChef: Player = self.players[0]
  41.         # GAME LOGIC
  42.         # fetch a dish, pick ice cream and drop the dish on an empty table
  43.         if not myChef.item.has_plate:
  44.             self.use(self.Dishwasher.pos)
  45.         elif ICE_CREAM not in myChef.item.content:
  46.             self.use(self.IceCream.pos)
  47.         elif BLUEBERRIES not in myChef.item.content:
  48.             self.use(self.Blueberry.pos)
  49.         else:
  50.             # once ready, put it on the first empty table for now
  51.             self.use(self.Window.pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement