--经验环

--脚本号
x200013_g_scriptId = 200013
--环id
x200013_g_RoundId = 13

--环区间 1,2-3,4-9,10
x200013_g_MissionRoundRange={1,2,3,4,5,6,8,100} 

--任务权重[环区间][概率,任务id(类型)]
x200013_g_MissionWeight={}
x200013_g_MissionWeight[1]={{chanceSum=100,id=11301}}
x200013_g_MissionWeight[2]={{chanceSum=100,id=11302}}
x200013_g_MissionWeight[3]={{chanceSum=100,id=11303}}
x200013_g_MissionWeight[4]={{chanceSum=100,id=11304}}
x200013_g_MissionWeight[5]={{chanceSum=100,id=11305}}
x200013_g_MissionWeight[6]={{chanceSum=100,id=11301}}
x200013_g_MissionWeight[7]={{chanceSum=60,id=11301},{chanceSum=100,id=11302}}
x200013_g_MissionWeight[8]={{chanceSum=60,id=11303},{chanceSum=100,id=11304}}

--奖励掉落包
x200013_g_DropId=80005

--是否可以接环，通用逻辑已判断
function x200013_CheckRoundAccept( scene,selfId )
	-- body
	return true
end

--当前环的任务id
function x200013_GetRoundMissionId( scene,selfId )
	-- body

	local roundInSection=GetMissionRoundInSection(scene,selfId,x200013_g_RoundId)+1

	local missionRange=1
	for i=1,#x200013_g_MissionRoundRange-1 do
		if roundInSection>x200013_g_MissionRoundRange[i] and roundInSection<=x200013_g_MissionRoundRange[i+1] then
			missionRange=i+1
		end
	end
	print("----------",roundInSection,missionRange)
	local missionWeight=x200013_g_MissionWeight[missionRange];
	local random = math.random(100)
	local  missionId = missionWeight[1].id
	for i=1,#missionWeight do
		if missionWeight[i].chanceSum>=random then
			missionId= missionWeight[i].id
		end	
	end
		print(missionId)
	return missionId 
end


function x200013_MissionRoundNext( scene,selfId,section,roundInSection,roundInCD )
			AcceptRoundMission(scene,selfId,x200013_g_RoundId)
end



--环奖励 round 本轮的环数 roundInCD 时间段内的环数（本日（周）的完成次数）
function x200013_OnRoundBouns( scene,selfId,section,round,roundInCD)
	-- body
	print("OnRoundBouns",round,roundInCD)
	round =round+1
	local  level = GetLevel(scene,selfId)	
	
	local money = math.ceil(level*12*1*100*(round+7)/5750)	
	local exp = math.ceil((level*120+240)*1*100*(round+7)/5750)
	
	if round%10==0 then --每10环掉落包
		CreateItemToUserByDropBox(scene,selfId,x200013_g_DropId)
	end	
	
	
	AddMoney(scene,selfId,money)
	GainExp(scene,selfId,exp)

end


--轮数做完了
function x200013_OnRoundFinish( scene,selfId )
	-- body
	print("OnRound finish")
end