礼包
This commit is contained in:
parent
1bc3f1e9f2
commit
bc3e832daa
@ -44,6 +44,7 @@ function DataManager:init()
|
||||
|
||||
-- 冲刺活动
|
||||
self:initManager("ActTimeData", "app/userdata/activity/act_time_data")
|
||||
self:initManager("ActGiftData", "app/userdata/activity/act_gift_data")
|
||||
self:initManager("ActSprintData", "app/userdata/activity/act_sprint/act_sprint_data")
|
||||
self:initManager("ActSprintSummonDataAll", "app/userdata/activity/act_sprint/act_sprint_summon_data_all")
|
||||
|
||||
|
||||
@ -88,8 +88,8 @@ function ActSprintManager:rspStandardReward(result)
|
||||
-- bi
|
||||
local biType = sprintData:getBIType()
|
||||
local taskFinishNum, taskTotalNum = sprintData:getBISprintTaskNumInfo()
|
||||
local sprintTaskRound = sprintData:getStandardTurn()
|
||||
local sprintRewardRound = sprintData:getStandardClaimedTurn()
|
||||
local sprintTaskRound = DataManager.ActTaskData:getTurnScore(result.reqData.activity_id)
|
||||
local sprintRewardRound = DataManager.ActTaskData:getClaimedTurnScore(result.reqData.activity_id)
|
||||
BIReport:postActSprintClaimSprintReward(result.reqData.activity_id, biType, taskFinishNum, taskTotalNum, sprintTaskRound, sprintRewardRound)
|
||||
end
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ local BG_NAME_2 = "act_common_bg_28" -- 正常
|
||||
local BTN_NAME_1 = "common_btn_grey_5"
|
||||
local BTN_NAME_2 = "common_btn_yellow_5"
|
||||
|
||||
function GiftCell:refresh(actGiftId)
|
||||
function GiftCell:refresh(actId, actGiftId)
|
||||
local uiMap = self:getUIMap()
|
||||
local bg = uiMap["gift_cell.bg"]
|
||||
local descTx = uiMap["gift_cell.bg.desc_tx"]
|
||||
@ -26,14 +26,15 @@ function GiftCell:refresh(actGiftId)
|
||||
local funcAdTx = uiMap["gift_cell.bg.func_btn.ad_tx"]
|
||||
local func2AdTx = uiMap["gift_cell.bg.func_btn.ad_2_tx"]
|
||||
|
||||
local isFree = DataManager.ActSprintSummonDataAll:getActGiftIsFree(actGiftId)
|
||||
local isAd = DataManager.ActSprintSummonDataAll:getActGiftIsAd(actGiftId)
|
||||
local costItem = DataManager.ActSprintSummonDataAll:getActGiftCostItem(actGiftId)
|
||||
local rechargeId = DataManager.ActSprintSummonDataAll:getActGiftRechargeId(actGiftId)
|
||||
local buyCount = DataManager.ActSprintSummonDataAll:getActGiftBuyCount(actGiftId)
|
||||
local limitCount = DataManager.ActSprintSummonDataAll:getActGiftLimit(actGiftId)
|
||||
local value = DataManager.ActSprintSummonDataAll:getActGiftValue(actGiftId) -- 超值标识
|
||||
local rewards = DataManager.ActSprintSummonDataAll:getActGiftReward(actGiftId)
|
||||
self.cfg = DataManager.ActGiftData:getGiftConfig(actId, actGiftId)
|
||||
local isFree = DataManager.ActGiftData:isFreeGift(actId, actGiftId)
|
||||
local isAd = DataManager.ActGiftData:isAdGift(actId, actGiftId)
|
||||
local buyCount = DataManager.ActGiftData:getGiftBuyCount(actGiftId)
|
||||
local costItem = self.cfg.item_cost and self.cfg.item_cost[1]
|
||||
local rechargeId = self.cfg.recharge_id
|
||||
local limitCount = self.cfg.limit
|
||||
local value = self.cfg.value
|
||||
local rewards = self.cfg.reward
|
||||
local soldOut = buyCount >= limitCount
|
||||
|
||||
bg:setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, (isFree or isAd) and BG_NAME_1 or BG_NAME_2)
|
||||
@ -78,7 +79,7 @@ function GiftCell:refresh(actGiftId)
|
||||
end
|
||||
end
|
||||
end
|
||||
descTx:setText(DataManager.ActSprintSummonDataAll:getActGiftI18NName(actGiftId))
|
||||
descTx:setText(DataManager.ActGiftData:getActGiftI18NName(actGiftId))
|
||||
for i = 1, REWARD_CELL_COUNT do
|
||||
local reward = rewards and rewards[i]
|
||||
if reward then
|
||||
|
||||
@ -50,7 +50,7 @@ function SummonActCell:refresh(day, maxDay, info)
|
||||
GFunc.setGrey(self.dayIcon:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE), false)
|
||||
else
|
||||
self.freeRewardCell:hideFrameAnimation()
|
||||
-- self.freeRewardCell:setClickShowTips()
|
||||
self.freeRewardCell:clearClickListener()
|
||||
self.dayTx:setVisible(freeGot)
|
||||
self.dayTxGrey:setVisible(not freeGot)
|
||||
GFunc.setGrey(self.bg:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE), not freeGot)
|
||||
@ -78,14 +78,14 @@ function SummonActCell:refresh(day, maxDay, info)
|
||||
else
|
||||
self.proRewardCells[1]:hideFrameAnimation()
|
||||
self.proRewardCells[2]:hideFrameAnimation()
|
||||
-- self.proRewardCells[1]:setClickShowTips()
|
||||
-- self.proRewardCells[2]:setClickShowTips()
|
||||
self.proRewardCells[1]:clearClickListener()
|
||||
self.proRewardCells[2]:clearClickListener()
|
||||
end
|
||||
end
|
||||
|
||||
function SummonActCell:onClickClaimRewards()
|
||||
local actId = DataManager.ActSprintSummonDataAll:getActId()
|
||||
local actType = DataManager.ActSprintSummonDataAll:getActType(actId)
|
||||
local actType = DataManager.ActivityData:getActType(actId)
|
||||
local grade = DataManager.ActSprintSummonDataAll:isUnlockBountyPro() and 1 or 0
|
||||
ModuleManager.ActSprintManager:reqSprintBountySign(actType, actId, grade)
|
||||
end
|
||||
|
||||
@ -12,28 +12,7 @@ end
|
||||
function GiftComp:refresh(actId)
|
||||
self.txTitle:setText(I18N:getGlobalText(GConst.ActSprintConst.ACT_LIST_NAME[actId]))
|
||||
self.banner:setTexture(GConst.ActSprintConst.ACT_MAIN_BANNER[actId])
|
||||
local cfgList = DataManager.ActSprintSummonDataAll:getActGiftList(actId)
|
||||
self.giftList = table.clearOrCreate(self.giftList)
|
||||
for _, id in ipairs(cfgList) do
|
||||
table.insert(self.giftList, id)
|
||||
end
|
||||
-- 排序
|
||||
table.sort(self.giftList, function(a, b)
|
||||
-- 免费 > 可购买 > 已售罄 > id
|
||||
local isFreeA = DataManager.ActSprintSummonDataAll:getActGiftIsFree(a) or DataManager.ActSprintSummonDataAll:getActGiftIsAd(a)
|
||||
local isFreeB = DataManager.ActSprintSummonDataAll:getActGiftIsFree(b) or DataManager.ActSprintSummonDataAll:getActGiftIsAd(b)
|
||||
if isFreeA == isFreeB then
|
||||
local canBuyA = DataManager.ActSprintSummonDataAll:getActGiftRemainCount(a) > 0
|
||||
local canBuyB = DataManager.ActSprintSummonDataAll:getActGiftRemainCount(b) > 0
|
||||
if canBuyA == canBuyB then
|
||||
return a < b
|
||||
else
|
||||
return canBuyA
|
||||
end
|
||||
else
|
||||
return isFreeA
|
||||
end
|
||||
end)
|
||||
self.giftList = DataManager.ActGiftData:getGiftIdsSort(actId)
|
||||
|
||||
if self.scrollRect == nil then
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
@ -41,7 +20,7 @@ function GiftComp:refresh(actId)
|
||||
return CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.giftList[index])
|
||||
cell:refresh(actId, self.giftList[index])
|
||||
end)
|
||||
end
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
|
||||
@ -202,6 +202,10 @@ function RewardCell:addClickListener(callback)
|
||||
self.clickCallback = callback
|
||||
end
|
||||
|
||||
function RewardCell:clearClickListener()
|
||||
self.clickCallback = nil
|
||||
end
|
||||
|
||||
function RewardCell:setLocalScale(x, y, z)
|
||||
self.baseObject:setLocalScale(x, y, z)
|
||||
end
|
||||
|
||||
140
lua/app/userdata/activity/act_gift_data.lua
Normal file
140
lua/app/userdata/activity/act_gift_data.lua
Normal file
@ -0,0 +1,140 @@
|
||||
local ActGiftData = class("ActGiftData", BaseData)
|
||||
|
||||
local ActGift = ConfigManager:getConfig("act_gift")
|
||||
|
||||
function ActGiftData:ctor()
|
||||
end
|
||||
|
||||
function ActGiftData:clear()
|
||||
self.giftConfig = nil
|
||||
end
|
||||
|
||||
--@region 礼包
|
||||
function ActGiftData:getActGiftsByActId(actId)
|
||||
local cfg = ConfigManager:getConfig("activity")[actId]
|
||||
if not cfg then
|
||||
return {}
|
||||
end
|
||||
return cfg.act_gift
|
||||
end
|
||||
|
||||
function ActGiftData:getGiftConfig(actId, id)
|
||||
self.giftConfig = self.giftConfig or {}
|
||||
if self.giftConfig[actId] == nil then
|
||||
self.giftConfig[actId] = {}
|
||||
local ids = self:getActGiftsByActId(actId)
|
||||
for i, id in ipairs(ids) do
|
||||
local info = ConfigManager:getConfig("act_gift")[id]
|
||||
info.id = id
|
||||
self.giftConfig[actId][id] = info
|
||||
end
|
||||
end
|
||||
|
||||
if id then
|
||||
return self.giftConfig[actId][id]
|
||||
else
|
||||
return self.giftConfig[actId]
|
||||
end
|
||||
end
|
||||
|
||||
function ActGiftData:getGiftIdsSort(actId)
|
||||
local tempList = {}
|
||||
for id, info in pairs(self:getGiftConfig(actId)) do
|
||||
local temp = {id = info.id, _sort = info.id}
|
||||
|
||||
-- if self:isFreeGift(actId, info.id) then
|
||||
-- temp._sort = temp._sort - 100000
|
||||
-- end
|
||||
if self:getGiftCanBuyCount(actId, info.id) <= 0 then
|
||||
temp._sort = temp._sort + 100000000000
|
||||
end
|
||||
|
||||
table.insert(tempList, temp)
|
||||
end
|
||||
table.sort(tempList, function(a, b) return a._sort < b._sort end)
|
||||
|
||||
local ids = {}
|
||||
for i, data in ipairs(tempList) do
|
||||
table.insert(ids, data.id)
|
||||
end
|
||||
|
||||
return ids
|
||||
end
|
||||
|
||||
-- 是否是广告礼包
|
||||
function ActGiftData:isAdGift(actId, id)
|
||||
local cfg = self:getGiftConfig(actId, id)
|
||||
if cfg.item_cost == nil and cfg.recharge_id == nil and cfg.parameter_pro == nil then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- 是否是免费礼包
|
||||
function ActGiftData:isFreeGift(actId, id)
|
||||
local cfg = self:getGiftConfig(actId, id)
|
||||
if cfg.parameter_pro and cfg.parameter_pro[1] and cfg.parameter_pro[1] == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- 是否是每日刷新礼包
|
||||
function ActGiftData:isDailyGift(actId, id)
|
||||
local cfg = self:getGiftConfig(actId, id)
|
||||
if cfg.limit_type ~= nil and cfg.limit_type == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- 是否是每周刷新礼包
|
||||
function ActGiftData:isWeekGift(actId, id)
|
||||
local cfg = self:getGiftConfig(actId, id)
|
||||
if cfg.limit_type ~= nil and cfg.limit_type == 2 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- 获取礼包购买次数
|
||||
function ActGiftData:getGiftBuyCount(id)
|
||||
return DataManager.PaymentData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, id)
|
||||
end
|
||||
|
||||
-- 获取礼包剩余可购买次数
|
||||
function ActGiftData:getGiftCanBuyCount(actId, id)
|
||||
local cfg = self:getGiftConfig(actId, id)
|
||||
if cfg then
|
||||
return cfg.limit - self:getGiftBuyCount(id)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function ActGiftData:tryResetGift(actId, force)
|
||||
local ids = self:getActGiftsByActId(actId)
|
||||
if ids == nil then
|
||||
return
|
||||
end
|
||||
for index, id in ipairs(ids) do
|
||||
local config = ActGift[id]
|
||||
if config then
|
||||
if force or self:isDailyGift(actId, id) then
|
||||
DataManager.PaymentData:resetGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, id)
|
||||
elseif self:isWeekGift(actId, id) then
|
||||
local isCrossWeek = Time:getDayofWeek() == 1
|
||||
if isCrossWeek then
|
||||
DataManager.PaymentData:resetGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 礼包名
|
||||
function ActGiftData:getActGiftI18NName(actGiftId)
|
||||
return I18N:getConfig("act_gift")[actGiftId] and I18N:getConfig("act_gift")[actGiftId].value
|
||||
end
|
||||
--@endregion
|
||||
|
||||
return ActGiftData
|
||||
10
lua/app/userdata/activity/act_gift_data.lua.meta
Normal file
10
lua/app/userdata/activity/act_gift_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e116a7c164e043f4b4d9bb1b5d58c83
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -63,6 +63,7 @@ function ActSprintSummonData:setActivityInfo(data)
|
||||
if self.bountyCurrDay then
|
||||
self.bountyCurrDay = self.bountyCurrDay + 1
|
||||
end
|
||||
self:tryResetGift()
|
||||
|
||||
self:setDirty()
|
||||
end)
|
||||
@ -246,7 +247,7 @@ function ActSprintSummonData:getIsOpen()
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getIsShow()
|
||||
local funcOpen = self:getActFuncOpen(self:getActId())
|
||||
local funcOpen = DataManager.ActivityData:getActFuncOpen(self:getActId())
|
||||
if funcOpen then
|
||||
local isFuncOpen = ModuleManager:getIsOpen(funcOpen, true)
|
||||
return isFuncOpen
|
||||
@ -331,7 +332,9 @@ function ActSprintSummonData:getNormalRemainTime()
|
||||
|
||||
return self:getEndTime() - nowTime
|
||||
end
|
||||
--endregion
|
||||
|
||||
--region 红点
|
||||
function ActSprintSummonData:hasRedPoint()
|
||||
if not self:syncedData() then
|
||||
return false
|
||||
@ -370,118 +373,27 @@ function ActSprintSummonData:hasStandardRp(actId)
|
||||
end
|
||||
|
||||
function ActSprintSummonData:hasGiftRp()
|
||||
return self:getHasFreeGiftCanBuy()
|
||||
if self.giftIds == nil then
|
||||
self.giftIds = DataManager.ActGiftData:getGiftIdsSort(self:getActId())
|
||||
end
|
||||
for i, id in ipairs(self.giftIds) do
|
||||
if DataManager.ActGiftData:isFreeGift(self:getActId(), id) and DataManager.ActGiftData:getGiftCanBuyCount(self:getActId(), id) > 0 then
|
||||
if DataManager.PaymentData:getIsSkipAd() then
|
||||
return true
|
||||
end
|
||||
return not self.fitstGift
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActSprintSummonData:hasTaskRp()
|
||||
return self:getCanAnyNormalTaskCanGetReward()
|
||||
end
|
||||
--endregion
|
||||
|
||||
--region 配置
|
||||
function ActSprintSummonData:getActConfig(id)
|
||||
if id then
|
||||
return ConfigManager:getConfig("activity")[id]
|
||||
else
|
||||
return ConfigManager:getConfig("activity")
|
||||
end
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActType(id)
|
||||
return self:getActConfig(id).act_type
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftList(id)
|
||||
return self:getActConfig(id).act_gift
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActShowReward(id)
|
||||
return self:getActConfig(id).show_reward
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActFuncOpen(id)
|
||||
return self:getActConfig(id).func_open
|
||||
end
|
||||
--endregion
|
||||
|
||||
--region 礼包
|
||||
function ActSprintSummonData:getActGiftBuyCount(actGiftId)
|
||||
return DataManager.PaymentData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, actGiftId)
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftIsFree(actGiftId)
|
||||
local rechargeId = self:getActGiftRechargeId(actGiftId)
|
||||
local value = self:getActGiftParameterPro(actGiftId)
|
||||
local cost = self:getActGiftCostItem(actGiftId)
|
||||
return not rechargeId and (value and value[1] == 1) and not cost
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftIsAd(actGiftId)
|
||||
local rechargeId = self:getActGiftRechargeId(actGiftId)
|
||||
local value = self:getActGiftParameterPro(actGiftId)
|
||||
local cost = self:getActGiftCostItem(actGiftId)
|
||||
return not rechargeId and not value and not cost
|
||||
end
|
||||
|
||||
function ActSprintSummonData:onGiftBuySuccess(actGiftId)
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftConfig(id)
|
||||
if id then
|
||||
return ConfigManager:getConfig("act_gift")[id]
|
||||
else
|
||||
return ConfigManager:getConfig("act_gift")
|
||||
end
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftRechargeId(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).recharge_id
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftParameterPro(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).parameter_pro
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftCostItem(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).item_cost and self:getActGiftConfig(actGiftId).item_cost[1]
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftReward(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).reward
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftLimitType(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).limit_type
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftLimit(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).limit
|
||||
end
|
||||
|
||||
-- 超值标识
|
||||
function ActSprintSummonData:getActGiftValue(actGiftId)
|
||||
return self:getActGiftConfig(actGiftId).value
|
||||
end
|
||||
|
||||
-- 礼包名
|
||||
function ActSprintSummonData:getActGiftI18NName(actGiftId)
|
||||
return I18N:getConfig("act_gift")[actGiftId] and I18N:getConfig("act_gift")[actGiftId].value
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getActGiftRemainCount(actGiftId)
|
||||
return self:getActGiftLimit(actGiftId) - self:getActGiftBuyCount(actGiftId)
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getHasFreeGiftCanBuy()
|
||||
local cfgList = self:getActGiftList(self:getActId())
|
||||
if cfgList then
|
||||
for _, giftId in ipairs(cfgList) do
|
||||
if self:getActGiftIsFree(giftId) and self:getActGiftRemainCount(giftId) > 0 then
|
||||
local taskList = DataManager.ActTaskData:getTaskIdList(self.actId)
|
||||
for _, actTaskId in ipairs(taskList) do
|
||||
if DataManager.ActTaskData:canClaimTask(self.actId, actTaskId) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
--endregion
|
||||
|
||||
@ -503,16 +415,6 @@ function ActSprintSummonData:getBINormalTaskNumInfo()
|
||||
return num, totalNum
|
||||
end
|
||||
|
||||
function ActSprintSummonData:getCanAnyNormalTaskCanGetReward()
|
||||
local taskList = DataManager.ActTaskData:getTaskIdList(self.actId)
|
||||
for _, actTaskId in ipairs(taskList) do
|
||||
if DataManager.ActTaskData:canClaimTask(self.actId, actTaskId) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- 达标任务
|
||||
function ActSprintSummonData:getBISprintTaskNumInfo()
|
||||
local num, totalNum = 0, 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user