def onEvent(self, event, st):
    id = st.getState()
    progress = st.getInt('progress')
    if (id == CREATED):
        st.set('cond', '0')
        if (event == 'ido'):
            st.setState(STARTING)
            st.set('progress', '0')
            st.set('cond', '1')
            st.set('dragon', '0')
            st.playSound('ItemSound.quest_accept')
            return 'Starting.htm'
    elif (id == STARTING):
        if (event == 'wait'):
            return craft_stone(st, progress)
        elif (event == 'cronos_2'):
            return '420_cronos_2.htm'
        elif (event == 'cronos_3'):
            return '420_cronos_3.htm'
        elif (event == 'cronos_4'):
            return '420_cronos_4.htm'
        elif (event == 'fsn'):
            st.set('cond', '2')
            if (progress == 0):
                st.set('progress', '1')
                st.giveItems(FSN_LIST, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_5.htm'
            elif (progress == 7):
                st.set('progress', '8')
                st.giveItems(FSN_LIST, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_12.htm'
        elif (event == 'fsn_dlx'):
            st.set('cond', '2')
            if (progress == 0):
                st.set('progress', '2')
                st.giveItems(FSN_LIST_DLX, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_6.htm'
            if (progress == 7):
                st.set('progress', '9')
                st.giveItems(FSN_LIST_DLX, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_13.htm'
        elif (event == 'showfsn'):
            return '420_byron_2.htm'
        elif (event == 'askmore'):
            st.set('cond', '4')
            if (progress == 3):
                st.set('progress', '5')
                return '420_byron_3.htm'
            elif (progress == 4):
                st.set('progress', '6')
                return '420_byron_4.htm'
        elif (event == 'give_fsn'):
            st.takeItems(FRY_STN, 1)
            return '420_mymyu_2.htm'
        elif (event == 'give_fsn_dlx'):
            st.takeItems(FRY_STN_DLX, 1)
            st.giveItems(FRY_DUST, 1)
            st.playSound('ItemSound.quest_itemget')
            return '420_mymyu_4.htm'
        elif (event == 'fry_ask'):
            return '420_mymyu_5.htm'
        elif (event == 'ask_abt'):
            st.setState(STARTED)
            st.set('cond', '5')
            st.giveItems(JUICE, 1)
            st.playSound('ItemSound.quest_itemget')
            return '420_mymyu_6.htm'
    elif (id == STARTED):
        if (event == 'exarion_1'):
            st.giveItems(SCALE_1, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('dragon', '1')
            st.set('cond', '6')
            st.set('progress', str((progress + 9)))
            return '420_exarion_2.htm'
        elif (event == 'kalibran_1'):
            st.set('dragon', '3')
            st.set('cond', '6')
            st.giveItems(SCALE_3, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_kalibran_2.htm'
        elif (event == 'kalibran_2'):
            if st.getQuestItemsCount(SCALE_3):
                if (progress in [14, 21]):
                    st.set('progress', '19')
                elif (progress in [15, 22]):
                    st.set('progress', '20')
                st.takeItems(SCALE_3, 1)
                st.giveItems(KA_EGG, 1)
                st.set('cond', '7')
                st.playSound('ItemSound.quest_itemget')
                return '420_kalibran_5.htm'
        elif (event == 'zwov_1'):
            st.set('dragon', '2')
            st.set('cond', '6')
            st.giveItems(SCALE_2, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_zwov_2.htm'
        elif (event == 'shamhai_1'):
            st.set('dragon', '5')
            st.set('cond', '6')
            st.giveItems(SCALE_5, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_shamhai_2.htm'
        elif (event == 'suzet_1'):
            return '420_suzet_2.htm'
        elif (event == 'suzet_2'):
            st.set('dragon', '4')
            st.set('cond', '6')
            st.giveItems(SCALE_4, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_suzet_3.htm'
        elif (event == 'hatch'):
            whom = int(st.get('dragon'))
            if (whom == 1):
                eggs = EX_EGG
            elif (whom == 2):
                eggs = ZW_EGG
            elif (whom == 3):
                eggs = KA_EGG
            elif (whom == 4):
                eggs = SU_EGG
            elif (whom == 5):
                eggs = SH_EGG
            if (st.getQuestItemsCount(eggs) and (progress in [19, 20])):
                st.takeItems(eggs, 1)
                st.set('cond', '8')
                if (progress == 19):
                    st.giveItems((3500 + st.getRandom(3)), 1)
                    st.exitQuest(True)
                    st.playSound('ItemSound.quest_finish')
                    return '420_mymyu_15.htm'
                elif (progress == 20):
                    return '420_mymyu_11.htm'
        elif (event == 'give_dust'):
            if st.getQuestItemsCount(FRY_DUST):
                st.takeItems(FRY_DUST, 1)
                luck = st.getRandom(2)
                if (luck == 0):
                    extra = ARMOR
                    qty = 1
                    htmltext = '420_mymyu_13.htm'
                else:
                    extra = FOOD
                    qty = 100
                    htmltext = '420_mymyu_14.htm'
                st.giveItems((3500 + st.getRandom(3)), 1)
                st.giveItems(extra, qty)
                st.exitQuest(True)
                st.playSound('ItemSound.quest_finish')
                return htmltext
        elif (event == 'no_dust'):
            st.giveItems((3500 + st.getRandom(3)), 1)
            st.exitQuest(True)
            st.playSound('ItemSound.quest_finish')
            return '420_mymyu_12.htm'
def onEvent(self, event, st):
    id = st.getState()
    progress = st.getInt('progress')
    if (id == CREATED):
        st.set('cond', '0')
        if (event == 'ido'):
            st.setState(STARTING)
            st.set('progress', '0')
            st.set('cond', '1')
            st.set('dragon', '0')
            st.playSound('ItemSound.quest_accept')
            return 'Starting.htm'
    elif (id == STARTING):
        if (event == 'wait'):
            return craft_stone(st, progress)
        elif (event == 'cronos_2'):
            return '420_cronos_2.htm'
        elif (event == 'cronos_3'):
            return '420_cronos_3.htm'
        elif (event == 'cronos_4'):
            return '420_cronos_4.htm'
        elif (event == 'fsn'):
            st.set('cond', '2')
            if (progress == 0):
                st.set('progress', '1')
                st.giveItems(FSN_LIST, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_5.htm'
            elif (progress == 7):
                st.set('progress', '8')
                st.giveItems(FSN_LIST, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_12.htm'
        elif (event == 'fsn_dlx'):
            st.set('cond', '2')
            if (progress == 0):
                st.set('progress', '2')
                st.giveItems(FSN_LIST_DLX, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_6.htm'
            if (progress == 7):
                st.set('progress', '9')
                st.giveItems(FSN_LIST_DLX, 1)
                st.playSound('ItemSound.quest_itemget')
                return '420_cronos_13.htm'
        elif (event == 'showfsn'):
            return '420_byron_2.htm'
        elif (event == 'askmore'):
            st.set('cond', '4')
            if (progress == 3):
                st.set('progress', '5')
                return '420_byron_3.htm'
            elif (progress == 4):
                st.set('progress', '6')
                return '420_byron_4.htm'
        elif (event == 'give_fsn'):
            st.takeItems(FRY_STN, 1)
            return '420_mymyu_2.htm'
        elif (event == 'give_fsn_dlx'):
            st.takeItems(FRY_STN_DLX, 1)
            st.giveItems(FRY_DUST, 1)
            st.playSound('ItemSound.quest_itemget')
            return '420_mymyu_4.htm'
        elif (event == 'fry_ask'):
            return '420_mymyu_5.htm'
        elif (event == 'ask_abt'):
            st.setState(STARTED)
            st.set('cond', '5')
            st.giveItems(JUICE, 1)
            st.playSound('ItemSound.quest_itemget')
            return '420_mymyu_6.htm'
    elif (id == STARTED):
        if (event == 'exarion_1'):
            st.giveItems(SCALE_1, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('dragon', '1')
            st.set('cond', '6')
            st.set('progress', str((progress + 9)))
            return '420_exarion_2.htm'
        elif (event == 'kalibran_1'):
            st.set('dragon', '3')
            st.set('cond', '6')
            st.giveItems(SCALE_3, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_kalibran_2.htm'
        elif (event == 'kalibran_2'):
            if st.getQuestItemsCount(SCALE_3):
                if (progress in [14, 21]):
                    st.set('progress', '19')
                elif (progress in [15, 22]):
                    st.set('progress', '20')
                st.takeItems(SCALE_3, 1)
                st.giveItems(KA_EGG, 1)
                st.set('cond', '7')
                st.playSound('ItemSound.quest_itemget')
                return '420_kalibran_5.htm'
        elif (event == 'zwov_1'):
            st.set('dragon', '2')
            st.set('cond', '6')
            st.giveItems(SCALE_2, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_zwov_2.htm'
        elif (event == 'shamhai_1'):
            st.set('dragon', '5')
            st.set('cond', '6')
            st.giveItems(SCALE_5, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_shamhai_2.htm'
        elif (event == 'suzet_1'):
            return '420_suzet_2.htm'
        elif (event == 'suzet_2'):
            st.set('dragon', '4')
            st.set('cond', '6')
            st.giveItems(SCALE_4, 1)
            st.playSound('ItemSound.quest_itemget')
            st.set('progress', str((progress + 9)))
            return '420_suzet_3.htm'
        elif (event == 'hatch'):
            whom = int(st.get('dragon'))
            if (whom == 1):
                eggs = EX_EGG
            elif (whom == 2):
                eggs = ZW_EGG
            elif (whom == 3):
                eggs = KA_EGG
            elif (whom == 4):
                eggs = SU_EGG
            elif (whom == 5):
                eggs = SH_EGG
            if (st.getQuestItemsCount(eggs) and (progress in [19, 20])):
                st.takeItems(eggs, 1)
                st.set('cond', '8')
                if (progress == 19):
                    st.giveItems((3500 + st.getRandom(3)), 1)
                    st.exitQuest(True)
                    st.playSound('ItemSound.quest_finish')
                    return '420_mymyu_15.htm'
                elif (progress == 20):
                    return '420_mymyu_11.htm'
        elif (event == 'give_dust'):
            if st.getQuestItemsCount(FRY_DUST):
                st.takeItems(FRY_DUST, 1)
                luck = st.getRandom(2)
                if (luck == 0):
                    extra = ARMOR
                    qty = 1
                    htmltext = '420_mymyu_13.htm'
                else:
                    extra = FOOD
                    qty = 100
                    htmltext = '420_mymyu_14.htm'
                st.giveItems((3500 + st.getRandom(3)), 1)
                st.giveItems(extra, qty)
                st.exitQuest(True)
                st.playSound('ItemSound.quest_finish')
                return htmltext
        elif (event == 'no_dust'):
            st.giveItems((3500 + st.getRandom(3)), 1)
            st.exitQuest(True)
            st.playSound('ItemSound.quest_finish')
            return '420_mymyu_12.htm'