|
@@ -12,7 +12,15 @@ local MAX_CHANGE = 20000000000
|
|
|
|
|
|
local _M = schema.new(MODULE_NAME, {
|
|
|
data = {
|
|
|
- }
|
|
|
+ --[[
|
|
|
+ [pos]
|
|
|
+ {
|
|
|
+ tm = 可开启时间
|
|
|
+
|
|
|
+ }
|
|
|
+ ]]
|
|
|
+ },
|
|
|
+ history = {}
|
|
|
})
|
|
|
|
|
|
|
|
@@ -38,7 +46,8 @@ end
|
|
|
|
|
|
-- TODO: 类似泰利的 prepare 接口
|
|
|
function MODULE.launch(character)
|
|
|
- local d = _M.assert_get(character)
|
|
|
+ local d = _M.assert_get(character) or {}
|
|
|
+ d.history = d.history or {}
|
|
|
end
|
|
|
|
|
|
-- TODO: 与客户端同步数据
|
|
@@ -162,9 +171,19 @@ function THIS.time_box_get_award(character, args)
|
|
|
return STD_ERR.COMMON_CONF_ERR -- 配置异常
|
|
|
end
|
|
|
|
|
|
+ d.history[data.id] = (d.history[data.id] or 0)
|
|
|
+ local history_num = d.history[data.id] + 1
|
|
|
+ local awardID = conf.award
|
|
|
+ for k, v in ipairs(conf.single) do
|
|
|
+ if v == history_num then
|
|
|
+ awardID = conf.replace[k] or awardID
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
local now = os.time()
|
|
|
local pay_list = {}
|
|
|
- local errno, award_list = common_fun.get_award(conf.award)
|
|
|
+ local errno, award_list = common_fun.get_award(awardID)
|
|
|
if errno ~= 0 then
|
|
|
return errno
|
|
|
end
|
|
@@ -182,7 +201,7 @@ function THIS.time_box_get_award(character, args)
|
|
|
local receipt = {
|
|
|
module="box",
|
|
|
brief="开启宝箱",
|
|
|
- context="开启宝箱:"..data.id,
|
|
|
+ context=string.format("开启宝箱id:%d, 奖励库id%s, 开启次数%d", data.id, awardID or 0, history_num),
|
|
|
notify={
|
|
|
flags="time_box_get_award"
|
|
|
},
|
|
@@ -206,6 +225,7 @@ function THIS.time_box_get_award(character, args)
|
|
|
}
|
|
|
reward(character, desc)
|
|
|
d.data[pos] = nil
|
|
|
+ d.history[data.id] = history_num
|
|
|
_M.persist(character)
|
|
|
return 0, {pos = pos}
|
|
|
end
|