PvpAction.lua 1.46 KB
local ipairs = ipairs
local table = table
local math = math
local redisproxy = redisproxy
local MsgPack = MsgPack


local _M = {}


function _M.formatCommonRpc(agent , data)
	local role = agent.role
	local roleId = role:getProperty("id")
	local msg = MsgPack.unpack(data)
	local pvpTC = role:getProperty("pvpTC")
	for slot, heroId in pairs(msg.heros) do
		if not role.heros[heroId] then
			return
		end
	end
	if not next(msg.heros) then
		return
	end

	table.clear(pvpTC)
	pvpTC.heros = {}
	for slot, heroId in pairs(msg.heros) do
		pvpTC.heros[slot] = heroId
	end
	pvpTC.leader = msg.leader
	
	role:savePvpCTeam(pvpTC)
	SendPacket(actionCodes.Pvp_formatCommonRpc, '')
	return true
end

function _M.formatHighRpc(agent , data)
	local role = agent.role
	local msg = MsgPack.unpack(data)
	local pvpTH = role.pvpData:getProperty("pvpTH")


	role.pvpData:updateProperty({field = "pvpTH", value = pvpTH}) 
	SendPacket(actionCodes.Pvp_formatHighRpc, '')
	return true
end

function _M.refreshMatchRpc(agent, data)
	local role = agent.role
	local msg = MsgPack.unpack(data)
	local pvpData = role.pvpData
	pvpData:refreshMatchC()

	SendPacket(actionCodes.Pvp_refreshMatchRpc, '')
	return true
end

function _M.buyCountRpc(agent, data)
	local role = agent.role
	local msg = MsgPack.unpack(data)


	SendPacket(actionCodes.Pvp_buyCountRpc, '')
	return true
end

function _M.startBattleRpc(agent, data)

end

function _M.endBattleRpc(agent, data)

end

function _M.matchListRpc(agent, data)
	
end

return _M