def update(self, world, events): if self.fx: if self.reverse: self.fx -= 1 if not self.fx: self.reverse = False else: self.fx += 1 if self.fx == 64: if self.order in world.orders: world.remove_order(self.order) self.contents = None if self.order.double: self.combo.contents = None plate = Food.Plate() plate.dirty = world.washing world.returned.append([plate, 360]) world.del_updates(self) money.play() self.locked = False plate = Food.Plate() plate.dirty = world.washing world.returned.append([plate, 360]) else: self.reverse = True self.order = None elif self.contents: for o in world.orders: if o.double: if self.combo and self.contents == o.os[ 0].plate and self.combo.contents and self.combo.contents == o.os[ 1].plate: self.fx = 1 self.locked = True self.order = o elif o.plate == self.contents: self.fx = 1 self.locked = True self.order = o else: self.locked = False else: self.locked = False world.del_updates(self)
def __init__(self, components, double=False): self.c = [] for c in components: if c.contents: self.c.extend(c.contents) else: self.c.append(c) try: baseimg = orderframes[len(self.c) - 1] except IndexError: while len(orderframes) < len(self.c): img = orderframes[-1] w = img.get_width() toblit = img.subsurface(pygame.Rect(w - 36, 0, 36, 106)) new_img = pygame.Surface((w + 34, 106)) new_img.blit(img, (0, 0)) new_img.blit(toblit, (w - 2, 0)) orderframes.append(new_img) baseimg = orderframes[len(self.c) - 1] self.img = pygame.Surface((baseimg.get_width(), 138), pygame.SRCALPHA, 32).convert_alpha() self.img.blit(baseimg, (0, 0)) if len(self.c) == 1: self.img.blit(self.c[0].raw_img, (19, 74)) if self.c[0].state != "normal": self.img.blit(states[self.c[0].state], (17, 104)) else: for n, c in enumerate(self.c): self.img.blit(c.raw_img, (2 + n * 34, 74)) if c.state != "normal": self.img.blit(states[c.state], (n * 34, 104)) self.plate = Food.Plate() for c in components: assert self.plate.combine(c), "INVALID RECIPE: " + str( components) + " OFFENDING INGREDIENT: " + str(c) if len(self.c) < 3: subsurf = self.img.subsurface(pygame.Rect(3, 8, 64, 64)) else: subsurf = self.img.subsurface( pygame.Rect(3 + 17 * len(self.c) - 34, 8, 64, 64)) subsurf.blit(self.plate.get_img(), (0, -self.plate.o3d * 4)) self.time = int( (900 + len(self.c) * 900) * self.plate.contents.ordermultiplier) if double: self.time *= 1.5 self.time = int(self.time) self.stime = self.time self.img = Img.xn(self.img, 2) self.width = self.img.get_width()