Blame view

src/actions/HeroAction.lua 738 Bytes
0a07bdd9   zhouahaihai   角色升级 。gm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  local ipairs = ipairs
  local table = table
  local math = math
  local next = next
  local string = string
  local redisproxy = redisproxy
  local MsgPack = MsgPack
  local getRandomName = getRandomName
  local mcast_util = mcast_util
  local string_format = string.format
  local tonumber = tonumber
  local require = require
  local table_insert = table.insert
  local tconcat = table.concat
  
  local _M = {}
  function _M.levelUpRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local hero = role.heros[msg.id]
  	if not hero then return end
  
  	if hero:getProperty("level") >= hero:getMaxLevel() then return end
  	hero:updateProperty({field = "level", delta = 1})
  	
  	SendPacket(actionCodes.Hero_levelUpRpc, '')
  	return true
  end
  
  
  return _M