Blame view

src/rdsscripts/rankDetails.lua 861 Bytes
314bc5df   zhengshouren   提交服务器初始代码
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
  local field = KEYS[1]
  local roleId = tonumber(KEYS[2])
  
  local formationJson = redis.call("hget", string.format("role:%d", roleId), field .. "FormationJson")
  
  local formation = cjson.decode(formationJson)
  
  local response = {formation = {}, heros = {}}
  
  if formation.heros then
  	for _, hero in ipairs(formation.heros) do
  		table.insert(response.formation, hero.id)
  	end
  end
  
  local heroIds = redis.call("smembers", string.format("role:%d:heroIds", roleId))
  
  local heroFields = {"type", "level", "star", "evolveCount", "wake", "breakLevel"}
  for _, heroId in ipairs(heroIds) do
  	local heroId = tonumber(heroId)
  	local heroInfo = redis.call("hmget", string.format("hero:%d:%d", roleId, heroId), unpack(heroFields))
  
  	local tb = {}
  	for k, v in ipairs(heroInfo) do
  		tb[heroFields[k]] = tonumber(v)
  	end
  	response.heros[heroId] = tb
  end
  
  return cmsgpack.pack(response)