Blame view

src/actions/PvpAction.lua 1.46 KB
440aa055   zhouhaihai   聊天
1
2
3
4
5
6
7
8
9
10
11
12
  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
fa565e0c   zhouhaihai   优化结构
13
  	local roleId = role:getProperty("id")
440aa055   zhouhaihai   聊天
14
  	local msg = MsgPack.unpack(data)
fa565e0c   zhouhaihai   优化结构
15
  	local pvpTC = role:getProperty("pvpTC")
440aa055   zhouhaihai   聊天
16
17
18
19
20
  	for slot, heroId in pairs(msg.heros) do
  		if not role.heros[heroId] then
  			return
  		end
  	end
fa565e0c   zhouhaihai   优化结构
21
22
  	if not next(msg.heros) then
  		return
440aa055   zhouhaihai   聊天
23
  	end
440aa055   zhouhaihai   聊天
24
  
fa565e0c   zhouhaihai   优化结构
25
26
27
28
29
30
31
32
  	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)
440aa055   zhouhaihai   聊天
33
34
35
36
37
38
39
  	SendPacket(actionCodes.Pvp_formatCommonRpc, '')
  	return true
  end
  
  function _M.formatHighRpc(agent , data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
fa565e0c   zhouhaihai   优化结构
40
  	local pvpTH = role.pvpData:getProperty("pvpTH")
440aa055   zhouhaihai   聊天
41
42
  
  
fa565e0c   zhouhaihai   优化结构
43
  	role.pvpData:updateProperty({field = "pvpTH", value = pvpTH}) 
440aa055   zhouhaihai   聊天
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  	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