# 初心者 案内人
# Made by <dex125@gmail.com>
 
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 = "9998_NewbieGuide"

# ---------- 使用NPC ----------
# 話せる島の村		= 30598
# エルフの村		= 30599
# ダーク エルフ村	= 30600
# ドワーフ村		= 30601
# オーク村		    = 30602
# カマエル村        = 32135
# ------------------------------
NPC = [30598,30599,30600,30601,30602,32135]

# -------- 使用アイテム --------
# トラベラーズ トークン = 8542
# ------------------------------
travel_Token = 8542


#コード記述開始
class Quest (JQuest) :

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

 def myEvent (self,htmltext,npc,player) :
   npcId = npc.getNpcId()
   # ヒューマン
   if npcId == 30598 :
     if player.getRace().ordinal() != 0 :
       htmltext = "hu_only.htm"
     elif player.getClassId().isMage() :
       htmltext = "hu_0-2.htm"
     else :
       htmltext = "hu_0-1.htm"
   # エルフ
   elif npcId == 30599 :
     if player.getRace().ordinal() != 1 :
       htmltext = "elf_only.htm"
     elif player.getClassId().isMage() :
       htmltext = "elf_0-2.htm"
     else :
       htmltext = "elf_0-1.htm"
   # DE
   elif npcId == 30600 :
     if player.getRace().ordinal() != 2 :
       htmltext = "de_only.htm"
     elif player.getClassId().isMage() :
       htmltext = "de_0-2.htm"
     else :
       htmltext = "de_0-1.htm"
   # オーク
   elif npcId == 30602 :
     if player.getRace().ordinal() != 3 :
       htmltext = "orc_only.htm"
     elif player.getClassId().isMage() :
       htmltext = "orc_0-2.htm"
     else :
       htmltext = "orc_0-1.htm"
   # ドワーフ
   elif npcId == 30601 :
     if player.getRace().ordinal() != 4 :
       htmltext = "dw_only.htm"
     else :
       htmltext = "dw_0-1.htm"
   # カマエル
   elif npcId == 32135 :
     if player.getRace().ordinal() != 5 :
       htmltext = "ka_only.htm"
     elif player.getClassId().isMage() :
       htmltext = "ka_0-2.htm"
     else :
       htmltext = "ka_0-1.htm"
   return htmltext

 def onTalk (self,npc,player) :
   st = player.getQuestState(qn)
   st.setState(State.STARTED)
   htmltext = "<html><body>クエストを遂行していないか条件が合いません。</body></html>"
   return self.myEvent(htmltext,npc,player)

 def onAdvEvent (self,event,npc,player) :
   if event.endswith(".htm") : return event
   return self.myEvent(event,npc,player)

QUEST = Quest(9998,qn,"custom") #"初心者案内人"

for npcs in NPC:
  QUEST.addStartNpc(npcs)
  QUEST.addTalkId(npcs)
