PrivilegeTurnManager = {} local this = PrivilegeTurnManager this.luckyData = {}---服务器幸运探宝跑马灯 物品数据 indication、刷新同一数据 this.advancedData = {}---服务器高级探宝跑马灯 物品数据 this.luckyTempData = {}---幸运探宝 临时数据(包含Drop) this.advancedTempData = {}---高级探宝 临时数据 this.dialRewardConfig = {}---表数据 this.dialRewardSettingConfig = {} this.gameSettingConfig = ConfigManager.GetConfigData(ConfigName.GameSetting, 1) local PrivilegeTypeConfig = ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig) ---下次免费刷新时间倒计时 this.luckyFreeTime = 0 this.advancedFreeTime = 0 ---幸运积分宝箱数据 this.boxReward_One = {} this.boxReward_Two = {} this.boxReward_Three = {} this.curTreasureType = nil---当前探宝类型 local DialRewardSetting = {} local privilegeWheelListInfos = {} --转盘数据 local PrivilegeOneCount = 0 local PrivilegeTwoCount = 0 local PrivilegeThreeCount = 0 local PrivilegeOneScore = 0 local PrivilegeTwoScore = 0 local PrivilegeThreeScore = 0 ---探宝类型 local TreasureType = { Lucky = 30, Advanced = 31, PrivilegeOne = 3, PrivilegeTwo = 4, PrivilegeThree = 5, } function this.Initialize() DialRewardSetting = ConfigManager.GetConfig(ConfigName.DialRewardSetting) for i, v in ConfigPairs(DialRewardSetting) do if v.Type == 2 then if TreasureType.PrivilegeOne == v.Id then for index, value in ipairs(v.BaseReward) do table.insert(this.boxReward_One, {score = value[1], itemId = value[2], itemNum = value[3]}) end elseif TreasureType.PrivilegeTwo == v.Id then for index, value in ipairs(v.BaseReward) do table.insert(this.boxReward_Two, {score = value[1], itemId = value[2], itemNum = value[3]}) end elseif TreasureType.PrivilegeThree == v.Id then for index, value in ipairs(v.BaseReward) do table.insert(this.boxReward_Three, {score = value[1], itemId = value[2], itemNum = value[3]}) end end end end end function this.GetAllData() return privilegeWheelListInfos end --初始化幸运转盘数据读取表数 function this.SetPrivilrgeTurnData(func) NetManager.PrivilegeWheelListInfoResponse(function (msg) privilegeWheelListInfos = msg.privilegeWheelListInfos for index, value in ipairs(privilegeWheelListInfos) do if value.wheelId == TreasureType.PrivilegeOne then PrivilegeOneCount = value.leftTimes PrivilegeOneScore = value.luckScore elseif value.wheelId == TreasureType.PrivilegeTwo then PrivilegeTwoCount = value.leftTimes PrivilegeTwoScore = value.luckScore elseif value.wheelId == TreasureType.PrivilegeThree then PrivilegeThreeCount = value.leftTimes PrivilegeThreeScore = value.luckScore end end -- CheckRedPointStatus(RedPointType.PrivilegeTurn) --特权转盘 if func then func() end end) end function this.GetPrivilrgeTurnIsShow(id) if privilegeWheelListInfos ~= nil then for index, value in ipairs(privilegeWheelListInfos) do if value.wheelId == id then return true end end end return false end --获取抽奖次数 function this.GetPrivilrgeTurnCount(TypeData) if TypeData == TreasureType.PrivilegeOne then return PrivilegeOneCount elseif TypeData == TreasureType.PrivilegeTwo then return PrivilegeTwoCount elseif TypeData == TreasureType.PrivilegeThree then return PrivilegeThreeCount end end --设置抽奖次数 function this.SetPrivilrgeTurnCount(TypeData,count) if TypeData == TreasureType.PrivilegeOne then PrivilegeOneCount = PrivilegeOneCount - count if PrivilegeOneCount <= 0 then PrivilegeOneCount = 0 end elseif TypeData == TreasureType.PrivilegeTwo then PrivilegeTwoCount = PrivilegeTwoCount - count if PrivilegeTwoCount <= 0 then PrivilegeTwoCount = 0 end elseif TypeData == TreasureType.PrivilegeThree then PrivilegeThreeCount = PrivilegeThreeCount - count if PrivilegeThreeCount <= 0 then PrivilegeThreeCount = 0 end end end --获取抽奖积分 function this.GetPrivilrgeTurnScore(TypeData) if TypeData == TreasureType.PrivilegeOne then return PrivilegeOneScore elseif TypeData == TreasureType.PrivilegeTwo then return PrivilegeTwoScore elseif TypeData == TreasureType.PrivilegeThree then return PrivilegeThreeScore end end --获取转盘item领奖状态 function this.GetPrivilrgeItemRewardState(TypeData,itemIndex) for index, value in ipairs(privilegeWheelListInfos) do if value.wheelId == TypeData then for ind, val in ipairs(value.awardIds) do if val == itemIndex then return false end end end end return true end --设置抽奖积分 function this.SetPrivilrgeTurnScore(TypeData,count) if TypeData == TreasureType.PrivilegeOne then PrivilegeOneScore = PrivilegeOneScore + count elseif TypeData == TreasureType.PrivilegeTwo then PrivilegeTwoScore = PrivilegeTwoScore + count elseif TypeData == TreasureType.PrivilegeThree then PrivilegeThreeScore = PrivilegeThreeScore + count end end --获取次数 function this.GetPrivilrgeTurnMaxCount(TreasureType) for index, value in ipairs(privilegeWheelListInfos) do if value.wheelId == TreasureType.PrivilegeOne and TreasureType == TreasureType.PrivilegeOne then return value.upLimitTimes elseif value.wheelId == TreasureType.PrivilegeTwo and TreasureType == TreasureType.PrivilegeTwo then return value.upLimitTimes elseif value.wheelId == TreasureType.PrivilegeThree and TreasureType == TreasureType.PrivilegeThree then return value.upLimitTimes end end return 0 end --初始化幸运转盘数据读取表数 function this.GetPrivilrgeTurnItems(TreasureType) local Data ={} for index, config in ConfigPairs(this.dialRewardConfig) do if config.ActivityId == TreasureType then table.insert(Data,{luckId = config.Id}) end end table.sort(Data, function(a, b) return a.luckId < b.luckId end) return Data end ---------------------------------------------------- ---初始化幸运转盘数据读取表数据 function this.InitTableData() this.dialRewardSettingConfig = ConfigManager.GetConfig(ConfigName.DialRewardSetting) this.dialRewardConfig = ConfigManager.GetConfig(ConfigName.DialRewardConfig) this.gameSettingConfig = ConfigManager.GetConfigData(ConfigName.GameSetting,1) end ---接收服务器数据(每日5点刷新刷新) function this.ReceiveServerDataForFive(data1,data2) this.luckyData = data1 this.advancedData = data2 end ---获取探宝券数量 1探宝类型 function this.GetTreasureTicketNum(treasureType) local Data = this.dialRewardSettingConfig[treasureType].CostItem return BagManager.GetItemCountById(Data[1][1])--返回高级探宝所需物品 end ---获取刷新按钮消耗材料数 function this.GetRefreshItemNum() return BagManager.GetItemCountById(16) end ---获取探宝1/多次按钮信息 1探宝类型 function this.GetTreasureBtnInfo(treasureType) local Data = this.dialRewardSettingConfig[treasureType].CostItem local oneData = {1,Data[2][4]} local moreData = {this.dialRewardSettingConfig[treasureType].ExtractingTime,this.dialRewardSettingConfig[treasureType].MultipleCostItem[2][4]} local icon = SetIcon(Data[1][1]) return oneData,moreData,icon end ---获取奖励盒状态 function this.GetRewardState(activityId,missionId) for i, v in pairs(ActivityGiftManager.mission) do if v.activityId == activityId then for n, m in ipairs(v.mission) do if m.missionId == missionId then return m.state end end end end end -------红点相关-------------- function this.ReturnRedPointState() if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.LuckyTurnTable_One) then return this.ReturnRewardBoxRedPoint() else return false end end ---限时活动关联幸运探宝红点显示 function this.ReturnRewardBoxRedPoint() for i, v in pairs(ActivityGiftManager.mission) do if v.activityId == ActivityTypeDef.LuckyTurnTable_One then this.value_1 = v.value elseif v.activityId == ActivityTypeDef.LuckyTurnTable_Two then this.value_2 = v.value end end if this.CheckLuckyRedPoint() or this.CheckAdvancedRedPoint() then return true else return false end end ---本地检查红点 function this.CheckLuckyRedPoint() local tab = {} for i = 1, 5 do--遍历所有达到领取奖励要求 且未领取奖励的宝箱状态 存入tab if this.value_1 >= this.boxReward_One[i].Values[1][1] then if this.GetRewardState(30,this.boxReward_One[i].Id) == 0 then table.insert(tab,0) end end end if #tab > 0 then --如果有未领取的奖励 显示红点 return true else return false end end function this.CheckAdvancedRedPoint() local tab = {} for i = 1, 5 do if this.value_2 >= this.boxReward_Two[i].Values[1][1] then if this.GetRewardState(31, this.boxReward_Two[i].Id) == 0 then table.insert(tab, 0) end end end if #tab > 0 then return true else return false end end function this.GetTurnMainRedpotState() if #privilegeWheelListInfos > 0 then for index, value in ipairs(privilegeWheelListInfos) do if value.leftTimes > 0 then return true end end end return false end --获取特权卡描述 function this.GetPrivilegeCardDes(id) local Data = {} local DesData = {} for index, config in ConfigPairs(PrivilegeTypeConfig) do if config.UnlockType == 6 then --特权卡描述 table.insert(Data,config) end end for index, value in ipairs(Data) do for ind, val in ipairs(value.Condition) do if val[1] == id then local str = "" if val[2] ~= 0 then str = GetLanguageStrById(value.Name) if value.IfFloat == 2 then if val[2] == 10000 then break end if val[2] > 10000 then str = string.format(str,(val[2]-10000)/10000*100)..string.format("%s", "%") else str = string.format(str,(val[2])/10000*100)..string.format("%s", "%") end else if val[2] >= 1 then str = string.format(str,val[2]) end end --Log("str "..str) table.insert(DesData,{Id=value.Id, des=str}) end end end end table.sort(DesData, function(a, b) return a.Id < b.Id end) return DesData end --特权转盘基础次数 function this.GetTurnNums(turnType) local num = 0 local DailyTimesPrivilege = this.dialRewardSettingConfig[turnType].DailyTimesPrivilege -- local data = ConfigManager.GetConfigData(ConfigName.PrivilegeTypeConfig, DailyTimesPrivilege) num = data.Condition[1][2] return num end --特权转盘添加次数 function this.GetPrivilegeAddTurnNums(turnType) local num = 0 local ExtraPrivilege = this.dialRewardSettingConfig[turnType].ExtraPrivilege -- local data = ConfigManager.GetConfigData(ConfigName.PrivilegeTypeConfig, ExtraPrivilege) for i = 1, #data.Condition do local numData = data.Condition[i] if numData[1]~=0 then local actRewardConfig = ConfigManager.GetConfigData(ConfigName.TequanCardConfig, numData[1]) if PrivilegeManager.GetPrivilegeOpenStatusById(actRewardConfig.PrivilegeID) then num = num + numData[2] end end end return num end --万元礼包红点刷新 function this.RefreShWanYuanRedPoint(actType) local allData = {} if ActivityTypeDef.LoginLiJin == actType then allData = OperatingManager.GetWanYuanLiBao(ActivityTypeDef.LoginLiJin) elseif ActivityTypeDef.LevelLiJin == actType then allData = OperatingManager.GetWanYuanLiBao(ActivityTypeDef.LevelLiJin) end if allData == nil then return false end for index, value in ipairs(allData) do if value.state == 2 then return true end end return false end --万元礼包Main function this.RefreShWanYuanMainRedPoint() if this.RefreShWanYuanRedPoint(ActivityTypeDef.LoginLiJin) or this.RefreShWanYuanRedPoint(ActivityTypeDef.LevelLiJin) then return true end return false end function this.GetWanYuanShowState() local loginData = OperatingManager.GetWanYuanLiBao(ActivityTypeDef.LoginLiJin) local levelData = OperatingManager.GetWanYuanLiBao(ActivityTypeDef.LevelLiJin) if loginData ~= nil then for index, value in ipairs(loginData) do if value.state ~= 1 then return true end end end if levelData ~= nil then for ind, val in ipairs(levelData) do if val.state ~= 1 then return true end end end return false end return this