Mistři v programování na #hovnokod

Python #430

import sys
from ru.hastel.gameserver.model.quest import State
from ru.hastel.gameserver.model.quest import QuestState
from ru.hastel.gameserver.model.quest.jython import QuestJython as JQuest

qn = "2008_christmas"

class Quest (JQuest) :

 def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

 def onEvent (self,event,st) :
    htmltext = event

    if event == "1":
        if st.getQuestItemsCount(5556) >= 4 and st.getQuestItemsCount(5557) >= 4 and st.getQuestItemsCount(5558) >= 10 and st.getQuestItemsCount(5559) >= 1:
            st.takeItems(5556,4)
            st.takeItems(5557,4)
            st.takeItems(5558,10)
            st.takeItems(5559,1)
            st.giveItems(5560,1)
            htmltext = "<html><body>Merry Christmas.</body></html>"
        else:
             htmltext = "31863-2.htm"
    elif event == "2":
        if st.getQuestItemsCount(5560) >= 10 :
            st.takeItems(5560,10)
            st.giveItems(5561,1)
            htmltext = "<html><body>Merry Christmas.</body></html>"
        else:
             htmltext = "31863-3.htm"
    if htmltext != event:
      st.setState(COMPLETED)
      st.exitQuest(1)

    return htmltext


 def onTalk (self,npc,player):
    st = player.getQuestState(qn)
    if not st : return 
    npcId = npc.getNpcId()
    if npcId == 31863 :
       htmltext = "31863-1.htm"
       st.setState(STARTED)
    return htmltext



QUEST       = Quest(2008,qn,"custom")
CREATED     = State('Start', QUEST)
STARTED     = State('Started', QUEST)
COMPLETED   = State('Completed', QUEST)

QUEST.setInitialState(CREATED)

QUEST.addStartNpc(31863)
QUEST.addTalkId(31863)

HovnoKod,