rankDetails.lua
861 Bytes
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)