local LogDefine = require("common.LogDefine")
local Log = require("common.Log")
local CreateRole = require("role.CreateRole")
local RoleHeadLogic = require("role.RoleHeadLogic")
local RoleStrongLogic = require("role.RoleStrongLogic")
local RoleLogic = require("role.RoleLogic")
local NewLogic = require("role.NewLogic")

function CG_ROLE_CHANGE_NAME(human, msg)
	CreateRole.changeName(human, msg.roleName)
end

function CG_ROLE_RANDOM_NAME(human, msg)
   CreateRole.randomName(human, msg.sex)
end

function CG_ROLE_HEAD_QUERY(human, msg)
	RoleHeadLogic.query(human, msg.type)
end

function CG_ROLE_BG_LH_QUERY(human)
    RoleHeadLogic.bgAndLhQuery(human)
end

function CG_ROLE_HEAD_SET(human, msg)
	RoleHeadLogic.setHead(human, msg.headID, msg.headType)
end

function CG_ROLE_CHANGE_NAME_QUERY(human)
	CreateRole.changeNameQuery(human)
end

function CG_CREATE_LOST_OSS(human, msg)
	local step = msg.step
	if step ~= LogDefine.HUMAN_LOST.ENTER_MAIN_CITY then
		return
	end
	
	if human.db.changeNameCnt ~= nil then
		-- 已经起过名了 不用再统计了
		return
	end

	--Log.write(Log.LOGID_OSS_CREATELOSS,human.db.account, human.db.name, step, human.db.ip,human.pf or "",human.appid, human.phpChanelID)
	Log.write(Log.LOGID_OSS_CREATELOSS,human.db.newUniqueTag, human.db.name, step, human.db.ip,human.pf or "",human.appid, human.phpChanelID)
end

function CG_ROLE_COMBATHERO_QUERY(human, msg)
	RoleHeadLogic.CG_ROLE_COMBATHERO_QUERY(human, msg.type)
end

function CG_HERO_STRONG_QUERY(human, msg)
    RoleStrongLogic.query(human, msg.father)
end

function CG_ROLE_CHANGE_BASEINFO_QUERY(human,msg)
    RoleLogic.changeBaseInfoQuery(human,msg.type)
end


function CG_ROLE_CHANGE_BASEINFO(human,msg)
	if(msg.type > 9) then
		NewLogic.NewProto(human,msg.type,msg.param)
		return
	end	
    RoleLogic.changeBaseInfo(human,msg.type,msg.param)
end

function CG_ROLE_CREATE_ROLE_CHANGE_MSG(human,msg)
    CreateRole.createRoleChangeInfo(human,msg.name,msg.sex,msg.friendCode)
end

function CG_ROLE_INFO_ICON_QUERY(human,msg)
    RoleLogic.roleInfoIconQuery(human,msg.type,msg.param)
end


function CG_ONLINETIME_REPORT(human, msg)
	print("[CG_ONLINETIME_REPORT] 收到请求下发在线时间的协议")
	RoleLogic.RoleLogic_GetOnlineTime(human, msg.nType)
end

function CG_COMMON_HUMAN_INFO(human, msg)
	RoleLogic.RoleLogic_QueryHumanInfo(human)
end