|
@@ -1,16 +1,14 @@
|
|
|
-- 每日好礼(小7渠道专属)
|
|
-- 每日好礼(小7渠道专属)
|
|
|
--- db.roleDailyGiftData = { getTime = 领取时间戳 }
|
|
|
|
|
|
|
+-- db.roleDailyGiftGot = true 表示今日已领取,跨天由 updateDaily 重置
|
|
|
|
|
|
|
|
-local Util = require("common.Util")
|
|
|
|
|
local Lang = require("common.Lang")
|
|
local Lang = require("common.Lang")
|
|
|
local Msg = require("core.Msg")
|
|
local Msg = require("core.Msg")
|
|
|
local Broadcast = require("broadcast.Broadcast")
|
|
local Broadcast = require("broadcast.Broadcast")
|
|
|
local Grid = require("bag.Grid")
|
|
local Grid = require("bag.Grid")
|
|
|
local BagLogic = require("bag.BagLogic")
|
|
local BagLogic = require("bag.BagLogic")
|
|
|
-local ObjHuman = require("core.ObjHuman")
|
|
|
|
|
local CommonDefine = require("common.CommonDefine")
|
|
local CommonDefine = require("common.CommonDefine")
|
|
|
--- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
|
|
|
|
|
--- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
|
|
|
|
|
|
|
+local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
|
|
|
|
|
+local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
|
|
|
|
|
|
|
|
local LOGTYPE = "roleDailyGift"
|
|
local LOGTYPE = "roleDailyGift"
|
|
|
local REWARD_ITEM_ID = 31
|
|
local REWARD_ITEM_ID = 31
|
|
@@ -31,11 +29,7 @@ function ModuleisOpen(human)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
local function isClaimedToday(human)
|
|
local function isClaimedToday(human)
|
|
|
- local data = human.db.roleDailyGiftData
|
|
|
|
|
- if not data or not data.getTime then
|
|
|
|
|
- return false
|
|
|
|
|
- end
|
|
|
|
|
- return Util.isSameDay(data.getTime)
|
|
|
|
|
|
|
+ return human.db.roleDailyGiftGot == true
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
local function getPrizeState(human)
|
|
local function getPrizeState(human)
|
|
@@ -45,18 +39,19 @@ local function getPrizeState(human)
|
|
|
return CommonDefine.COMMON_PRIZE_STATE_CANGET
|
|
return CommonDefine.COMMON_PRIZE_STATE_CANGET
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
--- function isDot(human)
|
|
|
|
|
--- if not ModuleisOpen(human) then
|
|
|
|
|
--- return false
|
|
|
|
|
--- end
|
|
|
|
|
--- return getPrizeState(human) == CommonDefine.COMMON_PRIZE_STATE_CANGET
|
|
|
|
|
--- end
|
|
|
|
|
|
|
+function isDot(human)
|
|
|
|
|
+ if not ModuleisOpen(human) then
|
|
|
|
|
+ return false
|
|
|
|
|
+ end
|
|
|
|
|
+ return getPrizeState(human) == CommonDefine.COMMON_PRIZE_STATE_CANGET
|
|
|
|
|
+end
|
|
|
|
|
|
|
|
function updateDaily(human)
|
|
function updateDaily(human)
|
|
|
if not ModuleisOpen(human) then
|
|
if not ModuleisOpen(human) then
|
|
|
return
|
|
return
|
|
|
end
|
|
end
|
|
|
- -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
|
|
|
|
|
|
|
+ human.db.roleDailyGiftGot = nil
|
|
|
|
|
+ RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
|
|
|
if human.fd then
|
|
if human.fd then
|
|
|
Query(human)
|
|
Query(human)
|
|
|
end
|
|
end
|
|
@@ -67,8 +62,6 @@ function Query(human)
|
|
|
return
|
|
return
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- ObjHuman.updateDaily(human)
|
|
|
|
|
-
|
|
|
|
|
local msgRet = Msg.gc.GC_ROLE_DAILY_GIFT_QUERY
|
|
local msgRet = Msg.gc.GC_ROLE_DAILY_GIFT_QUERY
|
|
|
msgRet.status = getPrizeState(human)
|
|
msgRet.status = getPrizeState(human)
|
|
|
Grid.makeItem(msgRet.item, REWARD_ITEM_ID, REWARD_ITEM_CNT)
|
|
Grid.makeItem(msgRet.item, REWARD_ITEM_ID, REWARD_ITEM_CNT)
|
|
@@ -80,8 +73,6 @@ function Get(human)
|
|
|
return Broadcast.sendErr(human, Lang.COMMON_SYSTEM_READY)
|
|
return Broadcast.sendErr(human, Lang.COMMON_SYSTEM_READY)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- ObjHuman.updateDaily(human)
|
|
|
|
|
-
|
|
|
|
|
if isClaimedToday(human) then
|
|
if isClaimedToday(human) then
|
|
|
return Broadcast.sendErr(human, "今日已领取")
|
|
return Broadcast.sendErr(human, "今日已领取")
|
|
|
end
|
|
end
|
|
@@ -89,9 +80,8 @@ function Get(human)
|
|
|
local itemArr = {{REWARD_ITEM_ID, REWARD_ITEM_CNT}}
|
|
local itemArr = {{REWARD_ITEM_ID, REWARD_ITEM_CNT}}
|
|
|
BagLogic.addItemList(human, itemArr, LOGTYPE)
|
|
BagLogic.addItemList(human, itemArr, LOGTYPE)
|
|
|
|
|
|
|
|
- human.db.roleDailyGiftData = human.db.roleDailyGiftData or {}
|
|
|
|
|
- human.db.roleDailyGiftData.getTime = os.time()
|
|
|
|
|
|
|
+ human.db.roleDailyGiftGot = true
|
|
|
|
|
|
|
|
- -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
|
|
|
|
|
|
|
+ RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
|
|
|
Query(human)
|
|
Query(human)
|
|
|
end
|
|
end
|