### ---------------------------------------------------------------------------
###			ポモナイベント　TSL鯖管理人　[GM] ティスエル
###			http://www.tslroom.net/
###			猫化　Evolution鯖管理人　[GM] ちびにゃん
###			http://l2je.ath.cx
###
### ---------------------------------------------------------------------------

import sys
from com.l2jserver.gameserver.model.quest import State
from com.l2jserver.gameserver.model.quest import QuestState
from com.l2jserver.gameserver.model.quest.jython import QuestJython as JQuest

qn = "5800_Pumpkin"

###＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠###

SMALL_PUMPKIN	= 6389
BIG_PUMPKIN		= 6390
NECTAR			= 6391

###＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠＠###

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(NECTAR) >= 1 :
              st.takeItems(NECTAR,1)
              st.giveItems(SMALL_PUMPKIN,1)
              htmltext = "OK.htm"
         else:
              htmltext = "NG.htm"

#大きなポモナの種と交換
    if event == "2":
         if st.getQuestItemsCount(NECTAR) >= 50 :
              st.takeItems(NECTAR,50)
              st.giveItems(BIG_PUMPKIN,1)
              htmltext = "OK.htm"
         else:
              htmltext = "NG.htm"

    if event == "0":
      htmltext = "Trade has been canceled."

    if htmltext != event:
      st.setState(State.COMPLETED)
      st.exitQuest(1)

    return htmltext

 def onTalk (self,npc,player):
    st = player.getQuestState(qn)
    st.setState(State.STARTED)
    return "main.htm"

QUEST       = Quest(-1,qn,"custom")
QUEST.addStartNpc(31227)
QUEST.addTalkId(31227)
