(version 2)
(include "sci.sh")
(exports
    0 rm280
)
(use "Main")
(use "Class_255_0")
(use "Game")
(use "User")
(use "Obj")
(script 280)


(local
    local0
    local1
    local2
    local3
    local4
    local5 =     30
    local6[12] = (27 35 43 51 59 67 91 99 123 131 139 147 )
    local18[12] = (32 40 48 56 64 72 96 104 128 136 144 152 )

)
(instance public rm280 of Rm
    (properties
        picture 32
    )

    (method (init)
        (var temp0[50])
        Load(129 32)
        (super:init())
        = global193 1
        (User:
            canInput(0)
            canControl(0)
        )
        (User:mapKeyToDir(0))
        = global592 1
        (send global1:setCursor(global20 HaveMouse()))
        Display(280 0 100 10 27 106 310 102 0 105 600)
        Display(280 0 100 11 28 106 310 102 15 105 600)
        (if (== gNorth 25)
            Display(280 1 100 30 175 106 200 102 0 105 600)
            Display(280 1 100 31 176 106 200 102 15 105 600)
        )
        Display(280 2 100 200 175 106 200 102 0 105 600)
        Display(280 2 100 201 176 106 200 102 15 105 600)
    )


    (method (doit)
        (super:doit())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 1
                (if (== gNorth 25)
                    (if ((((<= 190 (send pEvent:x)) and (<= (send pEvent:x) 275)) and (<= 170 (send pEvent:y))) and (<= (send pEvent:y) 183))
                        (send pEvent:claimed(1))
                        (send global2:setScript(Quitting))
                    )(else
                        (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[0] (send pEvent:y))) and (<= (send pEvent:y) local18[0]))
                            = local3 1
                            (send global2:setScript(ChooseFood))
                        )(else
                            (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[1] (send pEvent:y))) and (<= (send pEvent:y) local18[1]))
                                = local3 2
                                (send global2:setScript(ChooseFood))
                            )(else
                                (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[2] (send pEvent:y))) and (<= (send pEvent:y) local18[2]))
                                    = local3 3
                                    (send global2:setScript(ChooseFood))
                                )(else
                                    (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[3] (send pEvent:species))) and (<= (send pEvent:species) local18[3]))
                                        = local3 4
                                        (send global2:setScript(ChooseFood))
                                    )(else
                                        (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[4] (send pEvent:y))) and (<= (send pEvent:y) local18[4]))
                                            = local3 5
                                            (send global2:setScript(ChooseFood))
                                        )(else
                                            (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[5] (send pEvent:y))) and (<= (send pEvent:y) local18[5]))
                                                = local3 6
                                                (send global2:setScript(ChooseFood))
                                            )(else
                                                (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[6] (send pEvent:y))) and (<= (send pEvent:y) local18[6]))
                                                    = local3 7
                                                    (send global2:setScript(ChooseFood))
                                                )(else
                                                    (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[7] (send pEvent:y))) and (<= (send pEvent:y) local18[7]))
                                                        = local3 8
                                                        (send global2:setScript(ChooseFood))
                                                    )(else
                                                        (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[8] (send pEvent:y))) and (<= (send pEvent:y) local18[8]))
                                                            = local3 9
                                                            (send global2:setScript(ChooseFood))
                                                        )(else
                                                            (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[9] (send pEvent:y))) and (<= (send pEvent:y) local18[9]))
                                                                = local3 10
                                                                (send global2:setScript(ChooseFood))
                                                            )(else
                                                                (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[10] (send pEvent:y))) and (<= (send pEvent:y) local18[10]))
                                                                    = local3 11
                                                                    (send global2:setScript(ChooseFood))
                                                                )(else
                                                                    (if ((((<= local4 (send pEvent:x)) and (<= (send pEvent:x) local5)) and (<= local6[11] (send pEvent:y))) and (<= (send pEvent:y) local18[11]))
                                                                        = local3 12
                                                                        (send global2:setScript(ChooseFood))
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if ((((<= 190 (send pEvent:x)) and (<= (send pEvent:x) 275)) and (<= 170 (send pEvent:y))) and (<= (send pEvent:y) 183))
                        (send pEvent:claimed(1))
                        (send global2:setScript(Quitting))
                    )
                )
            )
            (case 4
                (if (== gNorth 25)
                    (if ((== (send pEvent:message) 81) or (== (send pEvent:message) 113))
                        (send global2:setScript(Quitting))
                    )(else
                        (if ((>= (send pEvent:message) 49) and (<= (send pEvent:message) 57))
                            = local3 (- (send pEvent:message) 48)
                            (send global2:setScript(ChooseFood))
                        )(else
                            (if ((>= (send pEvent:message) 65) and (<= (send pEvent:message) 67))
                                = local3 (- (send pEvent:message) 55)
                                (send global2:setScript(ChooseFood))
                            )(else
                                (if ((>= (send pEvent:message) 97) and (<= (send pEvent:message) 99))
                                    = local3 (- (send pEvent:message) 87)
                                    (send global2:setScript(ChooseFood))
                                )
                            )
                        )
                    )
                )(else
                    (if ((== (send pEvent:message) 81) or (== (send pEvent:message) 113))
                        (send global2:setScript(Quitting))
                    )
                )
            )
        )
    )

)
(instance ChooseFood of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (switch (local3)
                    (case 0
                    )
                    (case 1
                        = global244 (+ global244 1)
                        = local2 1
                    )
                    (case 2
                        = global244 (+ global244 2)
                        = local2 1
                    )
                    (case 3
                        = global244 (+ global244 3)
                        = local2 1
                    )
                    (case 4
                        = global244 (+ global244 2)
                        = local2 1
                    )
                    (case 5
                        = global244 (+ global244 5)
                        = local2 1
                    )
                    (case 6
                        = global244 (+ global244 9)
                        = local2 1
                        = global101 1
                    )
                    (case 7
                        = global244 (+ global244 7)
                        (if (not (send gEgo:has(7)))
                            = global249 1
                        )
                        = local2 1
                    )
                    (case 8
                        = global244 (+ global244 1)
                        = local2 1
                    )
                    (case 9
                        = global244 (+ global244 1)
                        = local1 1
                    )
                    (case 10
                        = global244 (+ global244 2)
                        = local1 1
                    )
                    (case 11
                        = global244 (+ global244 3)
                        = local1 1
                    )
                    (case 12
                        = global244 (+ global244 4)
                        = local1 1
                    )
                )
                proc255_0(280 3 67 -1 95 70 50 33 600 91)
                = cycles 30
            )
            (case 1
                proc0_12()
                (send global2:setScript(0))
            )
        )
    )

)
(instance Quitting of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if ((== gNorth 25) and global244)
                    (if (not local1)
                        proc255_0(280 4 82 38 4 0 30 1 80 "Pushy Counter Clerk" 81 " Yes " 1 81 " Yes " 2)
                    )
                    proc255_0(280 5 82 38 4 1 30 1 80 "Pushy Counter Clerk" 81 " Yes " 1 81 " Yes " 2)
                    proc255_0(280 6 82 38 4 2 30 1 80 "Pushy Counter Clerk" 81 " Yes " 1 81 " Yes " 2)
                    (if (not local1)
                        proc255_0(280 7 82 38 4 0 30 1 80 "While Supplies Last" 81 " Okay " 1)
                    )
                    (if (not local2)
                        proc255_0(280 8 82 38 4 0 30 1 80 "While Supplies Last" 81 " Okay " 1)
                    )
                    = global592 0
                    = global193 0
                    (if (> global244 9999)
                        = global244 9999
                    )
                    (User:mapKeyToDir(1))
                    proc0_12()
                    (send global2:newRoom(25))
                )(else
                    = global592 0
                    = global193 0
                    (User:mapKeyToDir(1))
                    (send global2:newRoom(gNorth))
                )
            )
        )
    )

)
