挂机
This commit is contained in:
parent
0289de2d9a
commit
3cb5152538
@ -66,7 +66,8 @@ BIReport.ITEM_GET_TYPE = {
|
||||
TASK_DAILY_REWARD = "TaskDailyReward",
|
||||
BOUNTY_UNLOCK_LEVEL = "BountyUnlockLevel",
|
||||
BOUNTY_REWARD = "BountyReward",
|
||||
BOUNTY = "Bounty"
|
||||
BOUNTY = "Bounty",
|
||||
IDLE_DROP = "IdleDrop"
|
||||
}
|
||||
|
||||
BIReport.ADS_CLICK_TYPE = {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
local IdleManager = class("IdleManager", BaseModule)
|
||||
|
||||
function IdleManager:showIdleDropUI(params)
|
||||
self:getIdleShowRewrad()
|
||||
UIManager:showUI("app/ui/idle/idle_drop_ui", params)
|
||||
end
|
||||
|
||||
@ -8,8 +9,27 @@ function IdleManager:showIdleQuickDropUI(params)
|
||||
UIManager:showUI("app/ui/idle/idle_quick_drop_ui", params)
|
||||
end
|
||||
|
||||
function IdleManager:getIdleRewrad()
|
||||
function IdleManager:getIdleShowRewrad()
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.IdleInfoReq, {}, {}, self.onGetIdleShowRewrad, BIReport.ITEM_GET_TYPE.NONE)
|
||||
end
|
||||
|
||||
function IdleManager:onGetIdleShowRewrad(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.IdleData:onGetIdleShowRewrad(result)
|
||||
end
|
||||
end
|
||||
|
||||
function IdleManager:getIdleRewrad()
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.IdleRewardReq, {}, {}, self.onGetIdleRewrad, BIReport.ITEM_GET_TYPE.IDLE_DROP)
|
||||
end
|
||||
|
||||
function IdleManager:onGetIdleRewrad(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
if result.rewards and next(result.rewards) then
|
||||
GFunc.showRewardBox(result.rewards)
|
||||
end
|
||||
DataManager.IdleData:onGetIdleRewrad(result.claim_at)
|
||||
end
|
||||
end
|
||||
|
||||
function IdleManager:getHangUpQuickRewrad()
|
||||
|
||||
@ -36,6 +36,8 @@ local ProtoMsgType = {
|
||||
[1666429753] = "MailDeleteRsp",
|
||||
[1690297937] = "SummonReq",
|
||||
[1690299770] = "SummonRsp",
|
||||
[1746317288] = "IdleInfoReq",
|
||||
[1746319121] = "IdleInfoRsp",
|
||||
[1901321540] = "PipedReq",
|
||||
[2095612947] = "ChangeNameReq",
|
||||
[2095614780] = "ChangeNameRsp",
|
||||
@ -134,6 +136,8 @@ local ProtoMsgType = {
|
||||
MailDeleteRsp = 1666429753,
|
||||
SummonReq = 1690297937,
|
||||
SummonRsp = 1690299770,
|
||||
IdleInfoReq = 1746317288,
|
||||
IdleInfoRsp = 1746319121,
|
||||
PipedReq = 1901321540,
|
||||
ChangeNameReq = 2095612947,
|
||||
ChangeNameRsp = 2095614780,
|
||||
@ -232,6 +236,8 @@ local ProtoMsgType = {
|
||||
MailDeleteRsp = "MailDeleteRsp",
|
||||
SummonReq = "SummonReq",
|
||||
SummonRsp = "SummonRsp",
|
||||
IdleInfoReq = "IdleInfoReq",
|
||||
IdleInfoRsp = "IdleInfoRsp",
|
||||
PipedReq = "PipedReq",
|
||||
ChangeNameReq = "ChangeNameReq",
|
||||
ChangeNameRsp = "ChangeNameRsp",
|
||||
|
||||
@ -9,11 +9,9 @@ function IdleDropUI:getPrefabPath()
|
||||
end
|
||||
|
||||
function IdleDropUI:ctor()
|
||||
self.rewardList = {}
|
||||
end
|
||||
|
||||
function IdleDropUI:onReshow()
|
||||
-- self:refreshBtn()
|
||||
self.itemList = {}
|
||||
self.refreshIntervalTime = GFunc.getConstValue("idle_exp_drop_time")
|
||||
self.canRefreshReward = false
|
||||
end
|
||||
|
||||
function IdleDropUI:onLoadRootComplete()
|
||||
@ -36,6 +34,8 @@ function IdleDropUI:onLoadRootComplete()
|
||||
uiMap["idle_drop_ui.bg.quick_btn.text"]:setText("临时文本:快速挂机")
|
||||
self.getBtn = uiMap["idle_drop_ui.bg.get_btn"]
|
||||
self.getBtn:addClickListener(function()
|
||||
self.lastRefreshTime = Time:getServerTime()
|
||||
ModuleManager.IdleManager:getIdleRewrad()
|
||||
end)
|
||||
uiMap["idle_drop_ui.bg.get_btn.text"]:setText("临时文本:领取")
|
||||
uiMap["idle_drop_ui.bg.close_btn"]:addClickListener(function()
|
||||
@ -43,6 +43,7 @@ function IdleDropUI:onLoadRootComplete()
|
||||
end)
|
||||
|
||||
self:initRewards()
|
||||
self:bindData()
|
||||
self:refreshCD()
|
||||
self:scheduleGlobal(function()
|
||||
self:refreshCD()
|
||||
@ -55,73 +56,100 @@ function IdleDropUI:initRewards()
|
||||
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
-- cell:refreshByConfig(self.list[index])
|
||||
cell:refreshByConfig(self.itemList[index])
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.rewardList)
|
||||
self.scrollRect:setTotalCount(0)
|
||||
end
|
||||
|
||||
-- function IdleDropUI:_display()
|
||||
-- local uiMap = self.root:genAllChildren()
|
||||
-- uiMap["idle_drop_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC))
|
||||
-- uiMap["idle_drop_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_1))
|
||||
-- uiMap["idle_drop_ui.bg.desc_2"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_3, Time:formatNumTime(GFunc.getConstIntValue("idle_maxtime"))))
|
||||
-- uiMap["idle_drop_ui.bg.btn_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_5))
|
||||
-- uiMap["idle_drop_ui.bg.btn_2.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.GET_DESC))
|
||||
-- uiMap["idle_drop_ui.bg.bg_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_4, self.coinPerHour))
|
||||
-- uiMap["idle_drop_ui.bg.bg_2.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_4, self.expPerHour))
|
||||
function IdleDropUI:bindData()
|
||||
self:bind(DataManager.IdleData, "dirty", function()
|
||||
self:onRefresh()
|
||||
self.canRefreshReward = true
|
||||
end)
|
||||
end
|
||||
|
||||
-- self:_refreshScrollRect()
|
||||
-- self:refreshBtn()
|
||||
-- self.canRefreshReward = true
|
||||
-- end
|
||||
function IdleDropUI:onRefresh()
|
||||
self:refreshRewards()
|
||||
self:refreshBtns()
|
||||
end
|
||||
|
||||
-- function IdleDropUI:_addListeners()
|
||||
-- local uiMap = self.root:genAllChildren()
|
||||
-- self.root:addClickListener(function()
|
||||
-- self:closeUI()
|
||||
-- ModuleManager.IdleManager:getIdleRewrad()
|
||||
-- end)
|
||||
-- uiMap["idle_drop_ui.bg.close_img"]:addClickListener(function()
|
||||
-- self:closeUI()
|
||||
-- ModuleManager.IdleManager:getIdleRewrad()
|
||||
-- end)
|
||||
function IdleDropUI:refreshRewards()
|
||||
for i = 1, #self.itemList do
|
||||
table.remove(self.itemList)
|
||||
end
|
||||
local rewards = DataManager.IdleData:getIdleRewards()
|
||||
for _, item in pairs(rewards) do
|
||||
if item.num > 0 then
|
||||
table.insert(self.itemList, item)
|
||||
end
|
||||
end
|
||||
if #self.itemList > 1 then
|
||||
-- 道具类型从低到高>道具ID从低到高>品质从高到低
|
||||
local cfg = ConfigManager:getConfig("item")
|
||||
local infoA
|
||||
local infoB
|
||||
table.sort(self.itemList, function(a, b)
|
||||
infoA = cfg[a.id]
|
||||
infoB = cfg[b.id]
|
||||
if infoA.type == infoB.type then
|
||||
if infoA.qlt == infoB.qlt then
|
||||
return infoA.qlt > infoB.qlt
|
||||
else
|
||||
return a.id < b.id
|
||||
end
|
||||
else
|
||||
return infoA.type < infoB.type
|
||||
end
|
||||
end)
|
||||
end
|
||||
if self.scrollRect:getTotalCount() ~= #self.itemList then -- 打开界面的时候定位到当前可领取的最低等级奖励,如果没有则定位到当前等级
|
||||
self.scrollRect:refillCells(#self.itemList)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
end
|
||||
|
||||
-- uiMap["idle_drop_ui.bg.btn_1"]:addClickListener(function()
|
||||
-- ModuleManager.IdleManager:showIdleQuickDropUI()
|
||||
-- end)
|
||||
|
||||
-- uiMap["idle_drop_ui.bg.btn_2"]:addClickListener(function()
|
||||
-- ModuleManager.IdleManager:getIdleRewrad()
|
||||
-- end)
|
||||
|
||||
-- -- self:bind(DataManager.HangUpData, "isDirty", function()
|
||||
-- -- self.list = DataManager.HangUpData:getCacheRewards()
|
||||
-- -- self:_refreshScrollRect()
|
||||
-- -- self.canRefreshReward = true
|
||||
-- -- end)
|
||||
-- end
|
||||
function IdleDropUI:refreshBtns()
|
||||
if #self.itemList > 0 then
|
||||
self.getBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_green_2")
|
||||
self.getBtn:setTouchEnable(true)
|
||||
else
|
||||
self.getBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_2")
|
||||
self.getBtn:setTouchEnable(false)
|
||||
end
|
||||
local quickTimes = DataManager.IdleData:getQuickIdleTimes()
|
||||
if quickTimes > 0 then
|
||||
self.quickBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_2")
|
||||
self.quickBtn:setTouchEnable(true)
|
||||
self:addQuickBtnRedPoint()
|
||||
else
|
||||
self.quickBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_2")
|
||||
self.quickBtn:setTouchEnable(false)
|
||||
self:removeQuickBtnRedPoint()
|
||||
end
|
||||
end
|
||||
|
||||
function IdleDropUI:refreshCD()
|
||||
local time = Time:getServerTime() - DataManager.IdleData:getLastDropTime()
|
||||
local idleMaxTime = DataManager.IdleData:getIdleMaxTime()
|
||||
if time >= idleMaxTime then
|
||||
if time >= idleMaxTime and #self.itemList > 0 then
|
||||
self:addGetBtnRedPoint()
|
||||
self.timeTx:setText(Time:formatNumTime(idleMaxTime))
|
||||
else
|
||||
self:removeGetBtnRedPoint()
|
||||
self.timeTx:setText(Time:formatNumTime(time))
|
||||
end
|
||||
-- if self.lastRefreshTime == nil then
|
||||
-- self.lastRefreshTime = Time:getServerTime()
|
||||
-- elseif Time:getServerTime() - self.lastRefreshTime > GFunc.getConstIntValue("exp_drop_time") then
|
||||
-- if not self.canRefreshReward then
|
||||
-- return
|
||||
-- end
|
||||
-- self.canRefreshReward = false
|
||||
-- self.lastRefreshTime = Time:getServerTime()
|
||||
-- ModuleManager.HangUpManager:getHangUpShowRewrad()
|
||||
-- end
|
||||
if self.lastRefreshTime == nil then
|
||||
self.lastRefreshTime = Time:getServerTime()
|
||||
elseif Time:getServerTime() - self.lastRefreshTime > self.refreshIntervalTime then
|
||||
if not self.canRefreshReward then
|
||||
return
|
||||
end
|
||||
self.canRefreshReward = false
|
||||
self.lastRefreshTime = Time:getServerTime()
|
||||
ModuleManager.IdleManager:getIdleShowRewrad()
|
||||
end
|
||||
end
|
||||
|
||||
function IdleDropUI:addGetBtnRedPoint()
|
||||
@ -156,23 +184,4 @@ function IdleDropUI:removeQuickBtnRedPoint()
|
||||
self.quickBtn:removeRedPoint()
|
||||
end
|
||||
|
||||
-- function IdleDropUI:refreshBtn()
|
||||
-- local uiMap = self.root:genAllChildren()
|
||||
-- local btn = uiMap["idle_drop_ui.bg.btn_1"]
|
||||
-- if self:canAd() or self:canDiamond() then
|
||||
-- btn:addRedPoint(85, 36, 0.5)
|
||||
-- else
|
||||
-- btn:removeRedPoint()
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- function IdleDropUI:canAd()
|
||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_1") > DataManager.HangUpData:getAdCount()
|
||||
-- end
|
||||
|
||||
-- function IdleDropUI:canDiamond()
|
||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_2") > DataManager.HangUpData:getDiamondCount()
|
||||
-- end
|
||||
|
||||
|
||||
return IdleDropUI
|
||||
@ -1,11 +1,5 @@
|
||||
local IdleQuickDropUI = class("IdleQuickDropUI", BaseUI)
|
||||
|
||||
local BTN_ICON = {
|
||||
BLUE = "common_btn_3",
|
||||
YELLOW = "common_btn_2",
|
||||
GRAY = "common_btn_4"
|
||||
}
|
||||
|
||||
function IdleQuickDropUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
@ -15,114 +9,44 @@ function IdleQuickDropUI:getPrefabPath()
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:ctor()
|
||||
-- self.list = ModuleManager.IdleManager:getRewardList()
|
||||
self.list = {}
|
||||
self.rewardList = {}
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:onLoadRootComplete()
|
||||
self:_display()
|
||||
self:_addListeners()
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:_display()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
uiMap["idle_quick_drop_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_5))
|
||||
uiMap["idle_quick_drop_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_6))
|
||||
uiMap["idle_quick_drop_ui.bg.btn_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.FREE_DESC))
|
||||
-- uiMap["idle_quick_drop_ui.bg.btn_2.desc"]:setText("X" .. GFunc.getConstIntValue("idle_drop_fast_cost"))
|
||||
-- uiMap["idle_quick_drop_ui.bg.desc2"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_VIT_DESC_2, GFunc.getConstIntValue("idle_drop_fast_times_2") - DataManager.HangUpData:getDiamondCount()))
|
||||
|
||||
-- if DataManager.MonthlyData:skipAd() then
|
||||
-- uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad_1", function ()
|
||||
-- uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
||||
-- end)
|
||||
-- else
|
||||
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad", function ()
|
||||
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
||||
end)
|
||||
-- end
|
||||
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setImageGray(not self:canAd())
|
||||
uiMap["idle_quick_drop_ui.bg.btn_2.img"]:setImageGray(not self:canDiamond())
|
||||
|
||||
local btn1 = uiMap["idle_quick_drop_ui.bg.btn_1"]
|
||||
|
||||
local icon = BTN_ICON.BLUE
|
||||
if not self:canAd() then
|
||||
icon = BTN_ICON.GRAY
|
||||
btn1:removeRedPoint()
|
||||
else
|
||||
btn1:addRedPoint(85, 36, 0.5)
|
||||
end
|
||||
btn1:setSprite(GConst.ATLAS_PATH.COMMON, icon)
|
||||
|
||||
icon = BTN_ICON.YELLOW
|
||||
if not self:canDiamond() then
|
||||
icon = BTN_ICON.GRAY
|
||||
end
|
||||
uiMap["idle_quick_drop_ui.bg.btn_2"]:setSprite(GConst.ATLAS_PATH.COMMON, icon)
|
||||
|
||||
self:_refreshScrollRect()
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:_addListeners()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.root:addClickListener(function()
|
||||
self.uiMap = uiMap
|
||||
uiMap["idle_quick_drop_ui.mask"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
uiMap["idle_quick_drop_ui.bg.title_text"]:setText("临时文本:快速挂机")
|
||||
uiMap["idle_quick_drop_ui.bg.desc_tx"]:setText("临时文本:立刻获得6小时挂机奖励")
|
||||
|
||||
uiMap["idle_quick_drop_ui.bg.btn_1"]:addClickListener(function()
|
||||
if not self:canAd() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_7, "0"))
|
||||
return
|
||||
end
|
||||
BIReport:postAdClick(BIReport.ADS_CLICK_TYPE.AD_HANG_UP)
|
||||
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.AD_HANG_UP, function()
|
||||
ModuleManager.IdleManager:getHangUpQuickRewrad(ModuleManager.IdleManager.HANG_UP_REWARD_TYPE.QUICK_AD)
|
||||
end)
|
||||
end)
|
||||
|
||||
uiMap["idle_quick_drop_ui.bg.btn_2"]:addClickListener(function()
|
||||
if not self:canDiamond() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_7, "0"))
|
||||
return
|
||||
end
|
||||
ModuleManager.IdleManager:getHangUpQuickRewrad(ModuleManager.IdleManager.HANG_UP_REWARD_TYPE.QUICK_DIAMOND)
|
||||
end)
|
||||
|
||||
uiMap["idle_quick_drop_ui.bg.close_img"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
|
||||
-- self:bind(DataManager.IdleData, "isDirty", function()
|
||||
-- self:_display()
|
||||
-- end)
|
||||
self:initRewards()
|
||||
self:initBtns()
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:_refreshScrollRect()
|
||||
if self.scrollRect then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.list)
|
||||
return
|
||||
end
|
||||
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.scrollRect = uiMap["idle_quick_drop_ui.bg.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
function IdleQuickDropUI:initRewards()
|
||||
self.scrollRect = self.uiMap["idle_quick_drop_ui.bg.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refreshByConfig(self.list[index])
|
||||
-- cell:refreshByConfig(self.list[index])
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.list)
|
||||
self.scrollRect:refillCells(#self.rewardList)
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:canAd()
|
||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_1") > DataManager.HangUpData:getAdCount()
|
||||
end
|
||||
|
||||
function IdleQuickDropUI:canDiamond()
|
||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_2") > DataManager.HangUpData:getDiamondCount()
|
||||
function IdleQuickDropUI:initBtns()
|
||||
self.uiMap["idle_quick_drop_ui.bg.ad_btn"]:addClickListener(function()
|
||||
end)
|
||||
self.uiMap["idle_quick_drop_ui.bg.ad_btn.text"]:setText("临时文本:免费")
|
||||
self.uiMap["idle_quick_drop_ui.bg.gem_btn"]:addClickListener(function()
|
||||
end)
|
||||
local gemBtnIcon = self.uiMap["idle_quick_drop_ui.bg.gem_btn.icon"]
|
||||
local gemBtnTx = self.uiMap["idle_quick_drop_ui.bg.gem_btn.text"]
|
||||
gemBtnTx:setText("50")
|
||||
GFunc.centerImgAndTx(gemBtnIcon, gemBtnTx)
|
||||
end
|
||||
|
||||
return IdleQuickDropUI
|
||||
|
||||
@ -104,7 +104,6 @@ function MainComp:refreshChapter(force)
|
||||
end
|
||||
|
||||
local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId()
|
||||
Logger.logHighlight("rewardChapterId " .. rewardChapterId)
|
||||
if rewardChapterId > chapterId then
|
||||
rewardChapterId = chapterId
|
||||
end
|
||||
|
||||
@ -1,19 +1,67 @@
|
||||
local IdleData = class("IdleData", BaseData)
|
||||
|
||||
function IdleData:ctor()
|
||||
self.data.dirty = false
|
||||
self.idleRewardMap = {}
|
||||
end
|
||||
|
||||
function IdleData:init(data)
|
||||
data = data or GConst.EMPTY_TABLE
|
||||
self.data.dropTime = (data.gold_drop_time or 0) // 1000
|
||||
self.data.dropTime = (data.claim_at or 0) // 1000
|
||||
self.data.adCount = data.ad_count or 0
|
||||
self.data.energyCount = data.energy_count or 0
|
||||
end
|
||||
|
||||
function IdleData:onGetIdleShowRewrad(data)
|
||||
data = data or GConst.EMPTY_TABLE
|
||||
self.data.dropTime = (data.claim_at or 0) // 1000
|
||||
self.data.adCount = data.ad_count or 0
|
||||
self.data.energyCount = data.energy_count or 0
|
||||
self:updateIdleRewards(data.items)
|
||||
self:markDirty()
|
||||
end
|
||||
|
||||
function IdleData:updateIdleRewards(items)
|
||||
if items == nil then
|
||||
return
|
||||
end
|
||||
for k, v in pairs(self.idleRewardMap) do
|
||||
self.idleRewardMap[k].num = 0
|
||||
end
|
||||
for id, num in pairs(items) do
|
||||
if self.idleRewardMap[id] then
|
||||
self.idleRewardMap[id].num = num
|
||||
else
|
||||
self.idleRewardMap[id] = {
|
||||
id = id,
|
||||
num = num,
|
||||
type = GConst.REWARD_TYPE.ITEM
|
||||
}
|
||||
end
|
||||
end
|
||||
self:markDirty()
|
||||
end
|
||||
|
||||
function IdleData:getIdleRewards()
|
||||
return self.idleRewardMap
|
||||
end
|
||||
|
||||
function IdleData:markDirty()
|
||||
self.data.dirty = not self.data.dirty
|
||||
end
|
||||
|
||||
function IdleData:getLastDropTime()
|
||||
return self.data.dropTime
|
||||
end
|
||||
|
||||
function IdleData:onGetIdleRewrad(time)
|
||||
self.data.dropTime = time // 1000
|
||||
for k, v in pairs(self.idleRewardMap) do
|
||||
self.idleRewardMap[k].num = 0
|
||||
end
|
||||
self:markDirty()
|
||||
end
|
||||
|
||||
function IdleData:getIsOpen()
|
||||
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.IDLE_DROP, true)
|
||||
end
|
||||
@ -51,4 +99,22 @@ function IdleData:getExpPerHour()
|
||||
return math.floor(expDrop * 3600 / time)
|
||||
end
|
||||
|
||||
function IdleData:getQuickIdleMaxAdTimes()
|
||||
if self.quickIdleMaxAdTimes == nil then
|
||||
self.quickIdleMaxAdTimes = ConfigManager:getConfig("const")["idle_drop_fast_times_1"].value
|
||||
end
|
||||
return self.quickIdleMaxAdTimes
|
||||
end
|
||||
|
||||
function IdleData:getQuickIdleMaxVitTimes()
|
||||
if self.quickIdleMaxVitTimes == nil then
|
||||
self.quickIdleMaxVitTimes = ConfigManager:getConfig("const")["idle_drop_fast_times_2"].value
|
||||
end
|
||||
return self.quickIdleMaxVitTimes
|
||||
end
|
||||
|
||||
function IdleData:getQuickIdleTimes()
|
||||
return self:getQuickIdleMaxAdTimes() + self:getQuickIdleMaxVitTimes() - self.data.adCount - self.data.energyCount
|
||||
end
|
||||
|
||||
return IdleData
|
||||
Loading…
x
Reference in New Issue
Block a user