Commit 54bd82e3e1b33c0c505e866697b4f58ff1b3e6ac

Authored by zhangqijia
1 parent 850c54f5

fix: 修复 查询抽奖ssr记录的gm指令的bug

src/actions/GmAction.lua
@@ -1101,7 +1101,8 @@ function _M.do_lua(role, pms) @@ -1101,7 +1101,8 @@ function _M.do_lua(role, pms)
1101 return "成功" 1101 return "成功"
1102 end 1102 end
1103 1103
1104 -function _M.getDrawHeroPro(role, pms) 1104 +table.insert(helpDes, {"抽英雄", "get_draw_hero_pro"})
  1105 +function _M.get_draw_hero_pro(role, pms)
1105 -- 普池 10 up池 207 心愿单 20 1106 -- 普池 10 up池 207 心愿单 20
1106 local poolDict = { 1107 local poolDict = {
1107 [10] = "普通卡池", 1108 [10] = "普通卡池",
@@ -1109,18 +1110,18 @@ function _M.getDrawHeroPro(role, pms) @@ -1109,18 +1110,18 @@ function _M.getDrawHeroPro(role, pms)
1109 [20] = "心愿单", 1110 [20] = "心愿单",
1110 } 1111 }
1111 local result = {} 1112 local result = {}
1112 - for k,v in poolDict do  
1113 - local unit = csvdb["build_unit"][k] 1113 + for k,v in pairs(poolDict) do
  1114 + local unit = csvdb["build_unitCsv"][k]
1114 if unit then 1115 if unit then
1115 - local w1 = unit["rare1"] or 0  
1116 - local w2 = unit["rare2"] or 0  
1117 - local w3 = unit["rare3"] or 0 1116 + local w1 = unit["rare_1"] or 0
  1117 + local w2 = unit["rare_2"] or 0
  1118 + local w3 = unit["rare_3"] or 0
1118 local up = unit["up_ssr_weight"] or 0 1119 local up = unit["up_ssr_weight"] or 0
1119 local total = w1 + w2 + w3 1120 local total = w1 + w2 + w3
1120 if total > 0 then 1121 if total > 0 then
1121 - local p1 = w1 / total  
1122 - local p2 = w2 / total  
1123 - local p3 = w3 / total 1122 + local p1 = string.format("%.2f", w1 / total)
  1123 + local p2 = string.format("%.2f",w2 / total)
  1124 + local p3 = string.format("%.2f",w3 / total)
1124 local tmp = {} 1125 local tmp = {}
1125 tmp["p1"] = p1 1126 tmp["p1"] = p1
1126 tmp["p2"] = p2 1127 tmp["p2"] = p2
@@ -1130,10 +1131,12 @@ function _M.getDrawHeroPro(role, pms) @@ -1130,10 +1131,12 @@ function _M.getDrawHeroPro(role, pms)
1130 end 1131 end
1131 end 1132 end
1132 end 1133 end
1133 -  
1134 - local ret = redisproxy:lrange("drawHeroRecord", 0, -1)  
1135 - result["history"] = ret  
1136 - json.encode(result) 1134 + result["history"] = {}
  1135 + local ret = redisproxy:lrange("drawHeroRecord", 0, 300)
  1136 + for _, v in ipairs(ret) do
  1137 + table.insert(result["history"], MsgPack.unpack(v))
  1138 + end
  1139 + return json.encode(result)
1137 end 1140 end
1138 1141
1139 return _M 1142 return _M
1140 \ No newline at end of file 1143 \ No newline at end of file
src/actions/HeroAction.lua
@@ -1055,7 +1055,8 @@ function _M.drawHeroRpc(agent, data) @@ -1055,7 +1055,8 @@ function _M.drawHeroRpc(agent, data)
1055 record["hero"] = itemData.name 1055 record["hero"] = itemData.name
1056 record["quality"] = itemData.quality 1056 record["quality"] = itemData.quality
1057 1057
1058 - redisproxy:lpush("drawHeroRecord", json.encode(record)) 1058 + redisproxy:lpush("drawHeroRecord", MsgPack.pack(record))
  1059 + redisproxy.ltrim("drawHeroRecord", 0, 10000)
1059 end 1060 end
1060 end 1061 end
1061 1062
src/actions/HttpAction.lua
@@ -258,4 +258,10 @@ function _M.account_init(query, body) @@ -258,4 +258,10 @@ function _M.account_init(query, body)
258 end 258 end
259 end 259 end
260 260
  261 +function _M.hero_draw_pro(query)
  262 + local gmFuncs = require "actions.GmAction"
  263 + if not query.cmd or not gmFuncs[query.cmd] then return "指令不存在" end
  264 + return gmFuncs[query.cmd]()
  265 +end
  266 +
261 return _M 267 return _M
262 \ No newline at end of file 268 \ No newline at end of file