--答题

--脚本号
x200020_g_scriptId = 200020
--环id
x200020_g_RoundId = 20


--任务[环数][任务id(类型)]
x200020_g_MissionId=12001

x200020_g_DropId=90010

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

--当前环的任务id
function x200020_GetRoundMissionId( scene,selfId )
	-- body
	return x200020_g_MissionId 
end


function x200020_MissionRoundNext( scene,selfId,section,roundInSection,roundInCD )
	AcceptRoundMission(scene,selfId,x200020_g_RoundId)
end

function x200020_OnRoundAccept(  scene,selfId,missionId )
	-- body
	ShowPuzzleNext(scene,selfId,x200020_g_RoundId)
end

function x200020_OnRoundClear(  scene,selfId )
	-- body
	ClearPuzzle(scene,selfId,x200020_g_RoundId)
end

--环奖励 round 本轮的环数 roundInCD 时间段内的环数（本日（周）的完成次数）
function x200020_OnRoundBouns( scene,selfId,section,round,roundInCD)
	-- body

	local result=GetPuzzleResult(scene,selfId,x200020_g_RoundId)
	print(result)
	print("OnRoundBouns",round,roundInCD)
	round =round+1
	local  level = GetLevel(scene,selfId)	
	
	local money = math.ceil(level*12*0.5*10*(0.056+0.008*round))	
	local exp = math.ceil((level*120+240)*0.5*10*(0.056+0.008*round))
	
	if result~=1 then  --答题错误
		money=math.ceil(level*12*0.5*10*(0.056+0.008*round)/4)
		exp=math.ceil((level*120+240)*0.5*10*(0.056+0.008*round)/4)
	end	
	if round%10==0 then --最后一环掉落包
		CreateItemToUserByDropBox(scene,selfId,x200020_g_DropId)
	end	
	SavePuzzle(scene,selfId,x200020_g_RoundId,money,exp)

	AddMoney(scene,selfId,money)
	GainExp(scene,selfId,exp)

end


--轮数做完了
function x200020_OnRoundFinish( scene,selfId )
	-- body
	print("OnRound finish")
	ShowPuzzleEnd(scene,selfId,x200020_g_RoundId,x200020_g_MissionId)
end