123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- ---
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by admin.
- --- DateTime: 2024/11/12 13:41
- ---@class UIEveryDayGiftRechargeInfo
- UIEveryDayGiftRechargeInfo = class()
- local this = UIEveryDayGiftRechargeInfo
- function this:ctor()
- end
- function this:Reset()
- end
- function this:Init()
- self:InitData()
- self:RegistMessages()
- self.EveryDayGiftAllData = SL:GetConfigTable("cfg_everydayGift_recharge")
- self.EveryDayGiftData = {}
- self.EverDayGiftFreeDataId = {}
- end
- function this:InitData()
- end
- function this:RegistMessages()
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self)
- end
- --服务器发送礼包组消息后刷新礼包组的数据
- function this:RES_RECHARGE_ACTION(_, message)
- if tonumber(message.type)~= 13 then --类型9
- return
- end
- if message.data then
- self.EveryDayGiftData ={}
- self.EveryDayGiftData.buyDay = message.data.buyDay
- self.EveryDayGiftData.dayFreeGift = message.data.dayFreeGift
- self.EveryDayGiftData.group = message.data.group
- self.EveryDayGiftData.todayBuy = message.data.todayBuy
- self.EveryDayGiftData.needCost = 6
- local rewardShowItem = {}
- local taskInfo = {}
- local taskAllDayInfo={}
- local taskInfoReward = {}
- local havereward = false
- local carreerId = SL:GetMetaValue(EMetaVarGetKey.JOB)
- for k , v in ipairs(self.EveryDayGiftAllData) do
- if v.round == tonumber(message.data.group) then
- if v.sort == 0 then
- for key,value in ipairs(v.showItem) do
- if value[1] == carreerId or value[1] == 0 then
- taskInfoReward = {
- itemId = value[2],
- count = value[3]
- }
- table.insert(rewardShowItem,taskInfoReward)
- end
- end
- self.EverDayGiftFreeDataId = v.id
- self.EveryDayGiftData.rewardShowItem = rewardShowItem
- else
- taskInfo = {}
- taskInfo.id = v.id
- taskInfo.day = v.sort
- taskInfo.task = v.task
- taskInfo.canGain = false
- taskInfo.haveGain = false
- taskInfo.showItem={}
- taskInfo.gift={}
- if v.sort == 1 then
- self.EveryDayGiftData.needCost = v.needCost
- end
- if message.data.buyDay >=v.sort then
- taskInfo.canGain = true
- end
- if not table.isNullOrEmpty(message.data.rewards) then
- for key,value in pairs(message.data.rewards) do
- if value == v.id then
- taskInfo.haveGain = true
- break
- end
- end
- end
- for key,value in ipairs(v.showItem) do
- if value[1] == carreerId or value[1] == 0 then
- taskInfoReward = {
- itemId = value[2],
- count = value[3]
- }
- table.insert(taskInfo.showItem,taskInfoReward)
- end
- end
- for key,value in ipairs(v.gift) do
- if value[1] == carreerId or value[1] == 0 then
- taskInfoReward = {
- itemId = value[2],
- count = value[3]
- }
- table.insert(taskInfo.gift,taskInfoReward)
- end
- end
- if taskInfo.canGain and (not taskInfo.haveGain) then --可领取
- taskInfo.sort = 1
- havereward = true
- elseif taskInfo.canGain then --已领取
- taskInfo.sort = 3
- elseif (not taskInfo.haveGain) then --未完成
- taskInfo.sort = 2
- else
- taskInfo.sort = 0
- end
- if taskInfo.sort~=0 then
- table.insert(taskAllDayInfo,taskInfo)
- end
- end
- end
- end
- table.sort(taskAllDayInfo,function (a,b)
- if a.sort == b.sort then
- return a.day<b.day
- else
- return a.sort<b.sort
- end
- end)
- self.EveryDayGiftData.task = taskAllDayInfo
- InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_EveryDayGift",(not self.EveryDayGiftData.dayFreeGift)or havereward)
- SL:onLUAEvent(LUA_EVENT_EVERYDAYGIFT_RECHARGE_CHANGE)
- end
- end
|