Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- [x] Select order to deliver
- [x] Cook any dessert included in selected order if dessert not already in the kitchen
- [x] If dessert is cooked, put it on a table
- [x] When no more dessert to cook, fetch a dish, and pick desserts included in order (following order)
- '''
- def play_wood2(self):
- myChef: Player = self.players[0]
- # GAME LOGIC
- # Select order to deliver
- order: Order = max(self.orders, key=lambda x: x.award)
- desserts_to_cook: List[Dessert] = order.desserts_to_cook(tables=self.tables)
- debug(f'desserts_to_cook = {desserts_to_cook}')
- if myChef.can_deliver(order):
- self.use(pos=self.Window.pos)
- else:
- if myChef.cooking_dessert:
- debug(f'cooking dessert {myChef.cooking_dessert}')
- if myChef.cooking_dessert.name == myChef.item.content:
- # dessert finished, put dessert on table
- myChef.cooking_dessert = False
- debug(f'leaving dessert {myChef.item.content} on table')
- # if dessert ready (my chef carries it), find available table to put it on
- available_tables: List[Table] = [t for t in self.tables if not t.item]
- closest_table: Table = min(available_tables, key=lambda t: t.pos.manhattan(myChef.pos))
- self.use(pos=closest_table.pos)
- else:
- self.cook_action(player=myChef, dessert=myChef.cooking_dessert)
- else:
- # if my check is not already cooking a dessert, check if my chef needs to cook a dessert
- if desserts_to_cook:
- myChef.cooking_dessert = random.choice(desserts_to_cook)
- self.cook_action(player=myChef, dessert=myChef.cooking_dessert)
- else:
- # No more dessert to cook, start collecting them
- self.collect_action(order=order)
- def play_wood3(self):
- myChef: Player = self.players[0]
- # GAME LOGIC
- # fetch a dish, pick ice cream and drop the dish on an empty table
- if not myChef.item.has_plate:
- self.use(self.Dishwasher.pos)
- elif ICE_CREAM not in myChef.item.content:
- self.use(self.IceCream.pos)
- elif BLUEBERRIES not in myChef.item.content:
- self.use(self.Blueberry.pos)
- else:
- # once ready, put it on the first empty table for now
- self.use(self.Window.pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement