Пример #1
0
class Hob(Counter):
    img = img4("Cooker")
    darkimg = img4("CookerDark")
    d3d = 4

    def can_place(self, item):
        return item.name in ("Pot", "Pan")

    def on_place(self, world):
        world.reg_updates(self)

    def update(self, world, events):
        if self.contents:
            self.contents.heat()
            if self.contents.contents:
                self.warn = self.contents.contents.warn
                self.progress = self.contents.contents.progress
            else:
                self.warn = False
                self.progress = None

    def on_take(self, world):
        world.del_updates(self)
        self.warn = False
        self.progress = None
Пример #2
0
class Counter(Object):
    img = img4("Counter")
    o3d = 4

    def __init__(self, x, y, contents=None):
        self.contents = contents
        self.place(x, y)
Пример #3
0
class Tile(object):
    img = None
    ppassable = True
    passable = True
    slippery = False
    no_spawn = False
    backwall = img4("Tiles/BackWall")

    def get_img(self):
        return self.img
Пример #4
0
class Trash(Object):
    img = img4("Trash")
    o3d = 4

    def on_place(self, world):
        voids[self.contents.utensil].play()
        if self.contents.utensil:
            world.cash -= 5
            world.returned.append([self.contents.__class__(), 0])
        self.contents = None
        return True
Пример #5
0
class Spawner(Object):
    img = img4("Spawner")
    o3d = 4
    placeable = True

    def __init__(self, x, y, food):
        self.contents = food
        self.foodspawn = food.__class__
        self.place(x, y)

    def on_take(self, world):
        self.contents = self.foodspawn()
Пример #6
0
class Grill(Hob):
    img = img4("GrillBase")
    oimgs = [img4("GrillTop" + s) for s in ["Off", "On"]]
    darkimg = img4("GrillDark")
    on = False
    over3d = 8
    d3d = 8
    ignore_dark_contents = True

    def can_place(self, item):
        return item.can_change_state("grilled")

    def on_place(self, world):
        world.reg_updates(self)
        self.on = True

    def update(self, world, events):
        if self.contents:
            self.contents.grill()
            self.warn = self.contents.warn
            self.progress = self.contents.progress
            if self.contents.burnprog == self.contents.burningtime:
                self.contents = None

    def on_take(self, world):
        world.del_updates(self)
        self.warn = False
        self.progress = None
        self.on = False

    def get_overimg(self, world):
        return self.oimgs[self.on]

    def get_darkimg(self, world):
        if self.on:
            return self.darkimg
Пример #7
0
class FlickerLight(Object):
    exists = False
    img = img4("BulbIcon")
    ttd = randint(600, 1200)

    def update(self, world, events):
        if self.ttd:
            self.ttd -= 1
        else:
            world.dark = not world.dark
            if world.dark:
                self.ttd = randint(180, 240)
                poff.play()
            else:
                self.ttd = randint(600, 1200)
                pon.play()
Пример #8
0
class Returner(Object):
    img = img4("Entrance")
    o3d = 4
    updates = True

    def update(self, world, events):
        if not self.contents:
            for r in world.returned:
                if not r[1]:
                    self.contents = r[0]
                    world.returned.remove(r)
                    self.fx = 64
                    break
        elif self.fx:
            self.fx -= 1
        elif self.locked:
            self.locked = False
Пример #9
0
class Fryer(Hob):
    img = img4("Fryer")
    cookingimgs = imgstrip4f("FryerCooking", 16)
    render_contents = False

    def can_place(self, item):
        return item.name == "Basket"

    def update(self, world, events):
        if self.contents:
            self.contents.heat()
            if self.contents.contents:
                self.warn = self.contents.contents.warn
                self.progress = self.contents.contents.progress

    def get_img(self, world):
        return self.cookingimgs[world.anitick // 4 %
                                4] if self.contents else self.img
Пример #10
0
class Sink(Object):
    img = img4("Sink")
    name = "Sink"
    o3d = 7
    fy = 12
    mp = 0
    mode = "clean"

    def interact(self, world, p):
        if self.contents and self.contents.name == "Plate" and self.contents.dirty:
            p.task = self
            self.locked = True
            self.progress = 0
            self.mode = "clean"
        elif self.contents and self.contents.name == "Pot" and self.contents.contents.is_burnt:
            p.task = self
            self.locked = True
            self.progress = 0
            self.mode = "soupscrub"
        elif self.contents and self.contents.name == "Pan" and self.contents.burnt:
            p.task = self
            self.locked = True
            self.progress = 0
            self.mode = "panscrub"

    def tupdate(self, p):
        self.mp += 1
        if self.mp == 8:
            self.mp = 0
            self.progress += 1
            if self.progress == 15:
                p.task = False
                self.locked = False
                if self.mode == "clean":
                    self.contents.dirty = False
                elif self.mode == "panscrub":
                    self.contents.burnt = False
                    self.contents.re_img()
                else:
                    self.contents.contents = None
                    self.contents.re_img()
                self.progress = None
            elif self.progress % 4 == 3:
                wash.play()
Пример #11
0
 def init(cls):
     convs = imgrot(img4("Conv"))
     cls.imgs = []
     for d in range(4):
         rimgs = []
         for n in range(14):
             i = cls.img.copy()
             ss = i.subsurface(pygame.Rect(4, 4, 56, 56))
             ss.blit(convs[d],
                     ((n * 4 if d == 1 else n * -4 if d == 3 else 0),
                      (n * 4 if d == 2 else n * -4 if d == 0 else 0)))
             if n != 0:
                 ss.blit(convs[d], ((n * 4 - 56 if d == 1 else n * -4 +
                                     56 if d == 3 else 0),
                                    (n * 4 - 56 if d == 2 else n * -4 +
                                     56 if d == 0 else 0)))
             rimgs.append(i)
         cls.imgs.append(rimgs)
     cls.img = cls.imgs[0]
Пример #12
0
 def __init__(self, imgname, backwall=None):
     self.img = img4("Tiles/" + imgname)
     if backwall:
         self.backwall = img4("Tiles/" + backwall)
Пример #13
0
class Player(Object):
    d = 2
    updates = True
    name = "Player"
    o3d = 3
    overimg = img4("ChefHat")
    over3d = 11
    placeable = False
    task = None
    inv = None
    himg = None
    img = True

    def __init__(self, x, y, col, mt, c):
        self.place(x, y)
        self.imgs = new_man(mt, col)
        try:
            self.over3d -= smallmen[mt]
        except KeyError:
            pass
        self.c = c
        self.col = col

    def update(self, world, events):
        bpress = self.c.get_buttons(events)
        sinv = self.tag_or_none()
        soverride = False
        if not self.moving and not self.task:
            bpressc = self.c.get_pressed()
            o = world.get_o(*D.offset(self.d, self))
            for d in self.c.get_dirs():
                self.d = D.index(d)
                if not bpressc[1] and self.move(d[0], d[1], world):
                    break
            if bpress[0]:
                if o and o.placeable and not o.locked:
                    if self.inv and not o.contents:
                        if o.can_place(self.inv):
                            o.contents = self.inv
                            self.inv = None
                            soverride = o.on_place(world)
                    elif not self.inv and o.contents:
                        self.inv = o.contents
                        o.contents = None
                        o.on_take(world)
                    elif self.inv and o.contents:
                        if self.inv.is_supply:
                            if o.contents.combine(self.inv.supply()):
                                pick.play()
                        else:
                            if o.contents.combine(self.inv):
                                self.inv = None
            if bpress[1]:
                if o and not o.locked:
                    o.do_interact(world, self)
            if sinv != self.tag_or_none() and not soverride:
                pick.play()
            if sinv != self.tag_or_none():
                self.re_himg()
        elif self.task:
            self.task.tupdate(self)

    def tag_or_none(self):
        return None if self.inv is None else self.inv.maketag()

    def get_img(self, world):
        return self.imgs[self.d]

    def re_himg(self):
        if self.inv:
            self.himg = xn(self.inv.get_img(), 0.5)
        else:
            self.himg = None
Пример #14
0
class ChoppingBoard(XBoard):
    img = img4("ChoppingBoard")
    recipe = "chopped"
    sound = chop
Пример #15
0
class RollingBoard(XBoard):
    img = img4("RollingBoard")
    recipe = "rolled"
    sound = roll
    mpmax = 8
Пример #16
0
class HammerBoard(XBoard):
    img = img4("HittingBoard")
    recipe = "hammered"
    sound = hit
Пример #17
0
class Wasser(Tile):
    img = img4("Tiles/Wasser")
    passable = False
    no_spawn = True
    backwall = blank64
Пример #18
0
class FoodExit(Object):
    img = img4("Exit")
    cimg = imgstrip4f("ComboExit", 16)[0]
    o3d = 4
    reverse = False
    combo = False
    name = "Exit"

    def on_place(self, world):
        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
                    break
            elif o.plate == self.contents:
                self.fx = 1
                self.locked = True
                self.order = o
                break
        else:
            self.fx = 0
        world.reg_updates(self)

    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 get_img(self, world):
        return self.cimg if self.combo else self.img
Пример #19
0
class Button(Counter):
    img = img4("Button")

    def interact(self, world, p):
        world.p_button()
Пример #20
0
class FixedCounter(Counter):
    img = img4("FixedBlock")
    name = "Fixed"
    fy = -4
Пример #21
0
class Pit(Tile):
    img = img4("Tiles/Void")
    ppassable = False
    no_spawn = True
Пример #22
0
class Wall(Object):
    img = img4("WallBottom")
    overimg = img4("WallTop")
    o3d = -12
    over3d = 8
    placeable = False
Пример #23
0
class Tree(Object):
    overimg = img4("Tree")
    over3d = 12
    placeable = False
Пример #24
0
class Ice(Tile):
    img = img4("Tiles/Ice")
    slippery = True
Пример #25
0
class Grater(XBoard):
    img = img4("Grater")
    recipe = "grated"
    sound = grate
    mpmax = 10