-- local Util = require("common.Util")
local CombatLogic = require("combat.CombatLogic")
local CombatPosLogic = require("combat.CombatPosLogic")
-- local CombatDefine = require("combat.CombatDefine")
local CombatVideo = require("combat.CombatVideo")
local JjcLogic = require("jjc.JjcLogic")
local JibanLogic = require("combat.JibanLogic")
-- local Lang  = require("common.Lang")
-- local Broadcast = require("broadcast.Broadcast")
local Msg = require("core.Msg")
local Config = require("Config")
local MiddleCommonLogic = require("middle.MiddleCommonLogic")
local TriggerLogic = require("trigger.TriggerLogic")
local TriggerDefine = require("trigger.TriggerDefine")

--阵法 begin
function CG_COMBAT_POS_QUERY(human,msg)
	CombatPosLogic.posQuery(human,msg.type,msg.groupID, msg.param, 1)
end

function CG_COMBAT_POS_UPDATE(human,msg)
	CombatPosLogic.updatePos(human,msg)
end

function CG_COMBAT_FORMATION_QUERY(human)
	CombatPosLogic.formationQuery(human)
end 

function CG_COMBAT_POS_ATTR_QUERY(human)
	CombatPosLogic.posAttrQuery(human)
end

--阵法 end
function CG_COMBAT_SET_QUICK(human, msg)
	CombatPosLogic.setQuick(human, msg.combatType, msg.isQuick)
end

function CG_COMBAT_BEGIN(human, msg)
	local nServerIndex = msg.nServerIndex
	print("[CG_COMBAT_BEGIN] nServerIndex = "..nServerIndex)
	-- 不是跨服或者是本服
	if -1 >= nServerIndex or nServerIndex == Config.SVR_INDEX then
		CombatLogic.tryCombatBegin(human, msg.combatType, msg.param)
	else
		MiddleCommonLogic.MiddleCommonLogic_CombatBegin_LW(human, msg)
	end
end

function CG_COMBAT_SPEED(human, msg)
	human.db.combatSpeed = msg.speed
    local msgRet = Msg.gc.GC_COMBAT_SPEED
    msgRet.speed = msg.speed
    Msg.send(msgRet,human.fd)

	TriggerLogic.PublishEvent(TriggerDefine.COMBAT_CHANGE_SPEED, human.db._id, 1)
end

function CG_COMBAT_VIDEO_QUERY(human)
	CombatVideo.sendCombatVideoQuery(human)
end

function CG_COMBAT_SAVE_VIDEO(human)
	CombatVideo.saveCombatVideo(human, false)
end

function CG_COMBAT_DEL_VIDEO(human, msg)
	CombatVideo.deleteCombatVideo(human, msg.videoUuid)
end

function CG_COMBAT_LOOK_VIDEO(human, msg)
	CombatVideo.lookCombatVideo(human, msg.videoUuid, msg.lookType)
end

function CG_COMBAT_CLIENT_FINISH(human, msg)
	CombatLogic.clientFinish(human, msg.type)
end

function CG_COMBAT_CLIENT_PASS_TIME(human, msg)
	CombatLogic.clientPassTime(human, msg.type, msg.passTime)
end

function CG_JIBAN_QUERY(human,msg)
	JibanLogic.query(human,msg.combatType,msg.heroID)
end

function CG_JIBAN_PREVIEW(human,msg)
	JibanLogic.preview(human)
end

function CG_JIBAN_UPDATE(human,msg)
	JibanLogic.update(human,msg.combatType,msg.jibanList, msg.heroIdArr)
end

function CG_HERO_UPDATE_ALL_POS(human,msg)
   CombatPosLogic.updateAllPos(human,msg.uuid)
end

function CG_HERO_UPDATE_ZDL(human,msg)
	CombatPosLogic.updateZdl(human,msg.uuid)
end


--------------------精灵---------------------------

function CG_COMBAT_ELFPOS_QUERY(human,msg)
	CombatPosLogic.Elf_Pos_Query(human, msg.combatType)
end

function CG_COMBAT_ELFPOS_DO(human,msg)
	CombatPosLogic.Elf_Pos_Update(human, msg.combatType, msg.elfPosArr)
end