|
|
@@ -79,14 +79,19 @@ function query(human, mainType)
|
|
|
local oldCnt = getCntByType(human, mainType)
|
|
|
|
|
|
local oldLuck
|
|
|
+ local tOldStatus = nil
|
|
|
if human.db.zhuanpan and human.db.zhuanpan[mainType] then
|
|
|
oldLuck = human.db.zhuanpan[mainType].luck
|
|
|
+ if human.db.zhuanpan[mainType].luckStatus then
|
|
|
+ tOldStatus = Util.copyTable(human.db.zhuanpan[mainType].luckStatus)
|
|
|
+ end
|
|
|
end
|
|
|
+
|
|
|
-- 更新
|
|
|
update(human, mainType)
|
|
|
|
|
|
-- 初始化
|
|
|
- initDB(human, mainType, oldCnt,oldLuck)
|
|
|
+ initDB(human, mainType, oldCnt,oldLuck, tOldStatus)
|
|
|
|
|
|
local zuanpan = human.db.zhuanpan[mainType]
|
|
|
|
|
|
@@ -204,21 +209,26 @@ function query(human, mainType)
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
|
|
|
-function refresh(human, mainType, needTime)
|
|
|
+function refresh(human, mainType, needTime, bRefreshLuck)
|
|
|
if not ZhuanpanExcel[mainType] then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
local oldCnt = getCntByType(human, mainType)
|
|
|
local oldLuck
|
|
|
+ local tOldStatus = nil
|
|
|
if human.db.zhuanpan and human.db.zhuanpan[mainType] then
|
|
|
oldLuck = human.db.zhuanpan[mainType].luck
|
|
|
+ if human.db.zhuanpan[mainType].luckStatus and not bRefreshLuck then
|
|
|
+ tOldStatus = Util.copyTable(human.db.zhuanpan[mainType].luckStatus)
|
|
|
+ end
|
|
|
end
|
|
|
+
|
|
|
-- 更新
|
|
|
update(human, mainType)
|
|
|
|
|
|
-- 初始化
|
|
|
- initDB(human, mainType, oldCnt,oldLuck)
|
|
|
+ initDB(human, mainType, oldCnt,oldLuck,tOldStatus)
|
|
|
|
|
|
-- 判断是否免费
|
|
|
if needTime then
|
|
|
@@ -290,14 +300,19 @@ function getReward(human, mainType, cnt)
|
|
|
|
|
|
local oldCnt = getCntByType(human, mainType)
|
|
|
local oldLuck
|
|
|
- if human.db.zhuanpan and human.db.zhuanpan[mainType] then
|
|
|
+ local tOldStatus = nil
|
|
|
+ if human.db.zhuanpan and human.db.zhuanpan[mainType] then
|
|
|
oldLuck = human.db.zhuanpan[mainType].luck
|
|
|
+ if human.db.zhuanpan[mainType].luckStatus then
|
|
|
+ tOldStatus = Util.copyTable(human.db.zhuanpan[mainType].luckStatus)
|
|
|
+ end
|
|
|
end
|
|
|
+
|
|
|
-- 更新
|
|
|
update(human, mainType)
|
|
|
|
|
|
-- 初始化
|
|
|
- initDB(human, mainType, oldCnt,oldLuck)
|
|
|
+ initDB(human, mainType, oldCnt,oldLuck, tOldStatus)
|
|
|
|
|
|
local zhuanpan = human.db.zhuanpan[mainType]
|
|
|
if not BagLogic.checkItemCnt(human, needItemID, needItemCnt) then
|
|
|
@@ -504,21 +519,28 @@ function getLuckDrawSingle(human, mainType)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-function initDB(human, mainType, cnt,oldluck)
|
|
|
+function initDB(human, mainType, cnt, oldluck, tOldStatus)
|
|
|
if human.db.zhuanpan ~= nil and
|
|
|
human.db.zhuanpan[mainType] ~= nil then
|
|
|
return
|
|
|
end
|
|
|
local now = os.time()
|
|
|
+
|
|
|
human.db.zhuanpan = human.db.zhuanpan or {}
|
|
|
human.db.zhuanpan[mainType] = {}
|
|
|
+
|
|
|
local dayStartTime = Util.getDayStartTime(now)
|
|
|
human.db.zhuanpan[mainType].ts1 = dayStartTime
|
|
|
human.db.zhuanpan[mainType].ts2 = now - DEFAULT_FREE_REFRESH_TIME
|
|
|
human.db.zhuanpan[mainType].cnt = cnt
|
|
|
human.db.zhuanpan[mainType].luck = oldluck
|
|
|
human.db.zhuanpan[mainType].free = 1
|
|
|
- human.db.zhuanpan[mainType].luckStatus = {}
|
|
|
+ if tOldStatus then
|
|
|
+ human.db.zhuanpan[mainType].luckStatus = tOldStatus
|
|
|
+ else
|
|
|
+ human.db.zhuanpan[mainType].luckStatus = {}
|
|
|
+ end
|
|
|
+
|
|
|
addRandomReward(human, mainType)
|
|
|
end
|
|
|
|
|
|
@@ -647,10 +669,14 @@ end
|
|
|
|
|
|
function getFree(human)
|
|
|
local oldLuck
|
|
|
- if human.db.zhuanpan and human.db.zhuanpan[DEFAULT_ZHUANPAN_TYPE_NORMAL] then
|
|
|
+ local tOldStatus = nil
|
|
|
+ if human.db.zhuanpan and human.db.zhuanpan[DEFAULT_ZHUANPAN_TYPE_NORMAL] then
|
|
|
oldLuck = human.db.zhuanpan[DEFAULT_ZHUANPAN_TYPE_NORMAL].luck
|
|
|
+ if human.db.zhuanpan[DEFAULT_ZHUANPAN_TYPE_NORMAL].luckStatus then
|
|
|
+ tOldStatus = Util.copyTable(human.db.zhuanpan[DEFAULT_ZHUANPAN_TYPE_NORMAL].luckStatus)
|
|
|
+ end
|
|
|
end
|
|
|
- initDB(human,DEFAULT_ZHUANPAN_TYPE_NORMAL,nil,oldLuck)
|
|
|
+ initDB(human,DEFAULT_ZHUANPAN_TYPE_NORMAL,nil, oldLuck,tOldStatus)
|
|
|
if human.db.zhuanpan[DEFAULT_ZHUANPAN_TYPE_NORMAL].free ~= 1 then
|
|
|
return
|
|
|
end
|