--天墉城
--藏宝图

--脚本号
x101002_g_scriptId=101002
--环任务id MissionRoundConfigId
-- 普通宝图
x101002_g_missionRoundConfigId1 = 2
--高级宝图
x101002_g_missionRoundConfigId2 = 3
--普通宝图道具接取
x101002_g_missionRoundConfigIdItem=4
--宝图等级限制
x101002_g_MinLevel=25

--手绢
x101002_g_CommonTreasure_Item=105200001
x101002_g_SeniorTreasure_Items={105200002,105200003,105200004,105200005,105200006}
--事件交互入口
function x101002_OnDefaultEvent( scene,selfId ,targetId)
	-- body
	BeginEvent(scene)
	AddText(scene,"[43596b]小爺我走過多少名山大川，尋寶那是我的強項，想要知道寶藏的下落，就來問我吧[-]")

	AddNumText(scene,x101002_g_scriptId,"普通寶藏",-1,0)
	AddNumText(scene,x101002_g_scriptId,"神秘寶藏",-1,1)
	AddNumText(scene,x101002_g_scriptId,"精美的手絹",-1,2)
	EndEvent(scene)
	DispatchEventList(scene,selfId,targetId,true)
end




--事件列表选中一项

function x101002_OnEventRequest( scene,selfId,targetId,eventId ,index)
	-- body
	if index==0 then
		BeginEvent(scene)
			AddText(scene,"[43596b]看在你這麽誠心請教的份上，本寶寶就大發慈悲的告訴你寶藏的下落，按照我給你的信息去尋找寶藏吧[-]")
			AddNumText(scene,x101002_g_scriptId,"接受",-2,101)
		EndEvent(scene)	
		DispatchEventList(scene,selfId,targetId)
	elseif index==1 then	
		BeginEvent(scene)
			AddText(scene,"[43596b]噓！聽說了嗎，最近出了個大寶藏，裏面都是寶貝，不過本小爺可不吃虧，你給我麒麟血、玄武甲、青龍鱗、白虎爪、朱雀羽 ，我就告訴你它在哪[-]")
			AddNumText(scene,x101002_g_scriptId,"接受",-2,102)
		EndEvent(scene)		
		DispatchEventList(scene,selfId,targetId)
	elseif index==2 then
		BeginEvent(scene)	
			AddText(scene,"[43596b]哎，城里的小姐姐们又要过生日了，我需要一条精美的手絹，给我一条精美的手絹，我就告诉你一个新的宝藏信息[-]")
			AddNumText(scene,x101002_g_scriptId,"遞一條手絹",-2,103)
		EndEvent(scene)		
		DispatchEventList(scene,selfId,targetId)	
	elseif index==101 then	
	if GetLevel(scene,selfId) >=x101002_g_MinLevel then
		AcceptRoundMission(scene,selfId,x101002_g_missionRoundConfigId1)
		else 
			--等级不足
			SendServerTips(scene,selfId,"#{31006}",-1,false)
		end
	elseif index==102 then	
		if GetLevel(scene,selfId) >=x101002_g_MinLevel then
		x101002_g_SeniorTreasure(scene,selfId)
		else 
			--等级不足
			SendServerTips(scene,selfId,"#{31006}",-1,false)
		end
		
	elseif index==103 then	
		if GetLevel(scene,selfId) >=x101002_g_MinLevel then
		x101002_g_CommonTreasureByItem(scene,selfId)
		else 
			--等级不足
			SendServerTips(scene,selfId,"#{31006}",-1,false)
		end
	end

end
--普通宝图 手绢
function  x101002_g_CommonTreasureByItem( scene,selfId )
	-- body
	--普通宝图还没做完
	if not IsSectionMax(scene,selfId,x101002_g_missionRoundConfigId1) then

		SendServerTips(scene,selfId,"#{500022}",-1,false)
		--有普通宝图道具
		elseif GetItemCount(scene,selfId,x101002_g_CommonTreasure_Item)>0 then
			--接任务 删道具
			if AcceptRoundMission(scene,selfId,x101002_g_missionRoundConfigIdItem) then
				DelItem(scene,selfId,x101002_g_CommonTreasure_Item,1)
			end
		else 
			--道具不足
			SendServerTips(scene,selfId,"#{500021}",-1,false)
		end

end
--高级宝图
function  x101002_g_SeniorTreasure( scene,selfId )
	-- body
	local itemCount = #x101002_g_SeniorTreasure_Items
	local ret=true
	for i=1,itemCount do

		if GetItemCount(scene,selfId,x101002_g_SeniorTreasure_Items[i])<=0 then
			ret=false
		end
	end

	if ret then
		if AcceptRoundMission(scene,selfId,x101002_g_missionRoundConfigId2) then
			for i=1,itemCount do
				DelItem(scene,selfId,x101002_g_SeniorTreasure_Items[i],1)
			end
		end

	else
		--道具不足
		SendServerTips(scene,selfId,"#{500020}",-1,false)
	end

end
