--[[ ģ: ݼ¼

ʹ˵:

-- 꿪ʼģ
DungeonLog = DungeonLog or load("Lib/ݼ¼.lua")	--ַʽΪ˷ֹظ

-- ʵͬص, ת¼, 
function OnCast(CasterID, SkillName, SkillID, SkillLevel, TargetType, TargetID, PosY, PosZ, StartFrame, FrameCount)
	
	-------------- ش

	--ģ, ȫģ
	if getopt("¼") and DungeonLog then
		DungeonLog.OnCast(CasterID, SkillName, SkillID, SkillLevel, TargetType, TargetID, PosY, PosZ, StartFrame, FrameCount)
	end
end

-- ûʵͬصֱӰģĻصΪĻص
-- ע: ַʽḲͬ, ͬļӵ
if getopt("¼") and DungeonLog then
	OnEnterMap = DungeonLog.OnEnterMap
	OnNpcEnter = DungeonLog.OnNpcEnter
	OnNpcLeave = DungeonLog.OnNpcLeave
	OnPrepare = DungeonLog.OnPrepare
	OnChannel = DungeonLog.OnChannel
	OnCast = DungeonLog.OnCast
	OnBuff = DungeonLog.OnBuff
	OnSay = DungeonLog.OnSay
	OnWarning = DungeonLog.OnWarning
	OnFight = DungeonLog.OnFight
end

-- ע: ģжкҪֱӻӵĵ
-- 긱, ־еҼ Ϊ 浽һļ, ںڷBossļѭ
--]]


-- Ҫ¼ļ
local tSkill = {
[28] = "(NPCսͨ⹦)",
[6746] = "(_ŵѪ)",
}

--Ҫ¼Buff
local tBuff = {
[14321] = "쫷Ʒ˺",
}

-- Boss
local tBoss = {}

-- BossٻNPC
local tNpc = {}


-- һΪģ, еĳΪģĽӿ
local DungeonLog = {}


-- ͼ
DungeonLog.OnEnterMap = function(MapID, MapName)
	print("------------------------------ ͼ:"..MapName, MapID)
end

-- NPC
DungeonLog.OnNpcEnter = function(NpcID, NpcName, NpcTemplateID, NpcModelID, EmployerID, Intensity)
	if dungeon() then	--ڸ
		if Intensity == 6 and NpcName and #NpcName > 0 then		--Boss
			tBoss[NpcID] = NpcName
			print("Boss->["..NpcName.."]", "ģID:"..NpcTemplateID, NpcID)
		end
		if tBoss[EmployerID] then	--Boss
			tNpc[NpcID] = NpcName
			print("OnNpcEnter->["..NpcName.."]", NpcID, NpcTemplateID, NpcModelID, EmployerID, Intensity)
		end
	end
end

-- NPCʧ
DungeonLog.OnNpcLeave = function(NpcID, NpcName, NpcTemplateID, NpcModelID, EmployerID, Intensity)
	tBoss[NpcID] = nil	--BossƳ
	tNpc[NpcID] = nil	--NPCƳ
end

-- ʼ
DungeonLog.OnPrepare = function(CasterID, SkillName, SkillID, SkillLevel, TargetType, TargetID, PosY, PosZ, Frame, StartFrame, FrameCount)
	if tSkill[SkillID] then return end
	local szName = tBoss[CasterID] or tNpc[CasterID]
	if szName then		--Boss
		local t = {}
		t[#t+1] = "OnPrepare->["..szName.."]"
		t[#t+1] = ":"..SkillName
		t[#t+1] = "ID:"..SkillID
		t[#t+1] = "ܵȼ:"..SkillLevel
		if TargetType == 2 then
			t[#t+1] = "Ŀ:"..TargetID.."|"..PosY.."|"..PosZ
		else
			t[#t+1] = "Ŀ:"..TargetID
		end
		t[#t+1] = "֡:"..Frame
		t[#t+1] = "ʼ֡:"..StartFrame
		t[#t+1] = "ǰ֡:"..FrameCount
		print(table.concat(t, ", "))
	end
end

-- ʼ
DungeonLog.OnChannel = function(CasterID, SkillName, SkillID, SkillLevel, TargetType, TargetID, PosY, PosZ, Frame, StartFrame, FrameCount)
	if tSkill[SkillID] then return end
	local szName = tBoss[CasterID] or tNpc[CasterID]
	if szName then		--Boss
		local t = {}
		t[#t+1] = "OnChannel->["..szName.."]"
		t[#t+1] = ":"..SkillName
		t[#t+1] = "ID:"..SkillID
		t[#t+1] = "ܵȼ:"..SkillLevel
		if TargetType == 2 then
			t[#t+1] = "Ŀ:"..TargetID.."|"..PosY.."|"..PosZ
		else
			t[#t+1] = "Ŀ:"..TargetID
		end
		t[#t+1] = "֡:"..Frame
		t[#t+1] = "ʼ֡:"..StartFrame
		t[#t+1] = "ǰ֡:"..FrameCount
		print(table.concat(t, ", "))
	end
end

-- ͷż
DungeonLog.OnCast = function(CasterID, SkillName, SkillID, SkillLevel, TargetType, TargetID, PosY, PosZ, StartFrame, FrameCount)
	if tSkill[SkillID] then return end
	local szName = tBoss[CasterID] or tNpc[CasterID]
	if szName then		--Boss
		local t = {}
		t[#t+1] = "OnCast->["..szName.."]"
		t[#t+1] = ":"..SkillName
		t[#t+1] = "ID:"..SkillID
		t[#t+1] = "ܵȼ:"..SkillLevel
		if TargetType == 2 then
			t[#t+1] = "Ŀ:"..TargetID.."|"..PosY.."|"..PosZ
		else
			t[#t+1] = "Ŀ:"..TargetID
		end
		t[#t+1] = "ʼ֡:"..StartFrame
		t[#t+1] = "ǰ֡:"..FrameCount
		print(table.concat(t, ", "))
	end
end

-- Buff
DungeonLog.OnBuff = function(CharacterID, BuffName, BuffID, BuffLevel, StackNum, SkillSrcID, StartFrame, EndFrame, FrameCount)
	if StackNum > 0 and SkillSrcID and SkillSrcID ~= 0 then	--, Դɫ
		if tBoss[SkillSrcID] or tNpc[SkillSrcID] then	--Bossʩӵbuff
			local t = {}
			t[#t+1] = "OnBuff->buff:"..BuffName
			t[#t+1] = "buffID:"..BuffID
			t[#t+1] = "buffȼ:"..BuffLevel
			t[#t+1] = "buff:"..StackNum
			t[#t+1] = "Ŀ:"..CharacterID
			t[#t+1] = "ʼ֡:"..StartFrame
			t[#t+1] = "֡:"..EndFrame
			t[#t+1] = "ʱ:"..(EndFrame - StartFrame) / 16
			print(table.concat(t, ", "))
		end
	end
end

-- Boss
DungeonLog.OnSay = function(Name, SayText, CharacterID)
	if tBoss[CharacterID] then
		print("OnSay->["..Name.."]˵:"..SayText)
	end
end

-- Ϣ
DungeonLog.OnWarning = function(szText, szType)
	if dungeon() then
		print("OnWarning->"..szText, szType)
	end
end

-- ս״̬ı
DungeonLog.OnFight = function(bFight)
	if dungeon() then
		if bFight then
			print("-------------------- ս")
		else
			print("-------------------- ս")
		end
	end
end

-- ģ
return DungeonLog
