GmAction.lua 1.22 KB
local _M = {}
local redisproxy = redisproxy
function _M.clientRequest(agent, data)
	local msg = MsgPack.unpack(data)
	local role = agent.role
	local action = _M[msg.cmd]
	local bin = MsgPack.pack({ cmd = "指令失败" })
	if not action then
		SendPacket(actionCodes.Gm_receiveResponse, bin)
		return true
	end
	local ret = action(role, msg)
	bin = MsgPack.pack({ cmd = ret })
	SendPacket(actionCodes.Gm_receiveResponse, bin)
	return true
end


function _M.hero(role, pms)
	local heroType = tonum(pms.pm1)
	role:addHero({type = heroType})
	return "成功"
end

function _M.get(role, pms)
	local itemId = tonum(pms.pm1)
	if not csvdb["itemCsv"][itemId] then
		return "物品不存在"
	end
	local count = tonum(pms.pm2)
	role:award({[itemId] = count})
	return "成功"
end

function _M.advc(role, pms)
	role:updateProperty({field = "advInfo", value = {}})
	role:updateProperty({field = "advItems", value = ""})
	role:updateProperty({field = "advTeam", value = {}})
	role.advData = nil
	return "成功"
end

function _M.idlec(role, pms)
	role:updateProperty({field = "hangTeam", value = {}})
	role:updateProperty({field = "hangInfo", value = {}})
	role:updateProperty({field = "hangBag", value = {}})
	role.advData = nil
	return "成功"
end

return _M