GmAction.lua 2.17 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)
	if not role:addHero({type = heroType}) then
		return "失败"
	end
	return "成功"
end

function _M.equip(role, pms)
	local typ = tonum(pms.pm1)
	local level = tonum(pms.pm2)
	local count = tonum(pms.pm3)
	role:addEquip({type = typ,level = level,count = count})
	return "成功"
end

function _M.rune(role, pms)
	local typ = tonum(pms.pm1)
	local id = tonum(pms.pm2)
	local result = role:addRune({type = typ,id = id})
	return result
end

function _M.get(role, pms)
	if pms.pm1 == "ALL" then
		for itemId = 1, 100 do
			if csvdb["itemCsv"][itemId] then
				role:award({[itemId] = 1000000})
			end
		end
	elseif pms.pm1 == "EQUIP" then
		for itemId = 7000 , 8000 do
			if csvdb["itemCsv"][itemId] then
				role:award({[itemId] = 100})
			end
		end
	elseif pms.pm1 == "RUNE" then
		for itemId = 2000 , 3000 do
			if csvdb["itemCsv"][itemId] then
				role:award({[itemId] = 100})
			end
		end
	elseif pms.pm1 == "FRAG" then
		for itemId = 100 , 400 do
			if csvdb["itemCsv"][itemId] then
				role:award({[itemId] = 100})
			end
		end
	else
		local itemId = tonum(pms.pm1)
		if not csvdb["itemCsv"][itemId] then
			return "物品不存在"
		end
		local count = tonum(pms.pm2, 1)
		role:award({[itemId] = count})
	end
	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