RecruitManager = {} local this = RecruitManager local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting) local lotteryRewardConfig = ConfigManager.GetConfig(ConfigName.LotteryRewardConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local dailyRewardConfig = ConfigManager.GetConfig(ConfigName.DialRewardConfig) --活动抽卡类型(动态的数据) local drawtType={ FindFairySingle=0, FindFairyTen=0 } this.freeUseTimeList={} --免费抽卡容器 function this.Initialize() this.randCount = 0 --英雄抽卡已招募次数 this.isCanOpenBox = false this.boxReward = {} this.recruitFreeUseTime = 0 --现在只剩下秘盒招募在用了 this.isTenRecruit = 0 --首次十连 this.isFirstEnterElementScroll=true this.isFirstEnterHeroScroll=true this.InitPreData() end --请求抽卡 1抽卡类型 2回调 3特权id function this.RecruitRequest(recruitType, func, privilegeId,_itemId,_itemNum) local itemId = 0 local itemNum = 0 local freeTimesId = ConfigManager.GetConfigData(ConfigName.LotterySetting,RecruitType.LingShowSingle).FreeTimes if privilegeId == freeTimesId then itemId = _itemId itemNum = _itemNum else local data=this.GetExpendData(recruitType) itemId,itemNum=data[1],data[2] --默认 end --Log("BagManager.GetItemCountById(itemId) ".. BagManager.GetItemCountById(itemId).." itemNum "..itemNum) --Log(tostring(this.freeUseTimeList[privilegeId])) if BagManager.GetItemCountById(itemId) >= itemNum or (this.freeUseTimeList[privilegeId] and this.freeUseTimeList[privilegeId] >= 1) then NetManager.RecruitRequest(recruitType, function(msg) local data = ConfigManager.GetConfigData(ConfigName.LotterySetting,recruitType) if (RecruitType.Single == recruitType or RecruitType.NormalSingle==recruitType or (data.LotteryType == 3 and data.PerCount == 1) or(data.LotteryType == 9 and data.PerCount == 1) or RecruitType.LingShowSingle== recruitType ) or (data.LotteryType == 10 and data.PerCount == 1) or (data.LotteryType == 11 and data.PerCount == 1)then --若某抽卡类型有免费次数 if this.freeUseTimeList[privilegeId] and this.freeUseTimeList[privilegeId] >= 1 then PrivilegeManager.RefreshPrivilegeUsedTimes(privilegeId, 1) this.freeUseTimeList[privilegeId] = PrivilegeManager.GetPrivilegeRemainValue(privilegeId) CheckRedPointStatus(RedPointType.Recruit_Red) CheckRedPointStatus(RedPointType.Recruit_Normal) CheckRedPointStatus(RedPointType.TimeLimited) CheckRedPointStatus(RedPointType.QianKunBox) CheckRedPointStatus(RedPointType.Pokemon_Recruit) end end if func then func(msg) end end) end end --5点刷新数据 function this.RefreshFreeTime() this.freeUseTimeList[38] = PrivilegeManager.GetPrivilegeRemainValue(38) this.freeUseTimeList[14] = PrivilegeManager.GetPrivilegeRemainValue(14) this.freeUseTimeList[32] = PrivilegeManager.GetPrivilegeRemainValue(32) this.freeUseTimeList[99] = PrivilegeManager.GetPrivilegeRemainValue(99) this.freeUseTimeList[2005] = PrivilegeManager.GetPrivilegeRemainValue(2005) if (ActTimeCtrlManager.SingleFuncState(1)) then CheckRedPointStatus(RedPointType.Recruit_Red) CheckRedPointStatus(RedPointType.Recruit_Normal) CheckRedPointStatus(RedPointType.TimeLimited) CheckRedPointStatus(RedPointType.QianKunBox) end Game.GlobalEvent:DispatchEvent(GameEvent.Recruit.OnRecruitRefreshData) end --刷新招募红点 function this.CheckRecuritRedPoint() if (PrivilegeManager.GetPrivilegeRemainValue(14) >= 1) then--this.freeUseTimeList[14]) return true else return false end end --刷新普通招募红点 function this.CheckRecuritNormalPoint() if (PrivilegeManager.GetPrivilegeRemainValue(38) >= 1) then--this.freeUseTimeList[38] return true else return false end end function this.InitPreData() this.previewHeroData = {} this.previewFriendData={} this.previewNormalData={} this.previewElementData={} this.previewLuckData = {} --- 幸运探宝 this.previewLingShou={} --灵兽奖励数据 this.previewGhostFindData = {} -- this.previewTimeLimitedData = {}--限时招募 -- this.previewTimeLimitedUPData={} -- this.previewLotterySoulData = {}--乾坤宝囊其他奖励 -- this.previewLotterySoulUPData={}--乾坤宝囊魂印up保底 if(#this.previewHeroData>=1) then return end for i, v in ConfigPairs(lotteryRewardConfig) do if(v.Pool==1) then--钻石招募 table.insert(this.previewHeroData, v) elseif v.Pool==2 then--友情 table.insert(this.previewFriendData,v) elseif v.Pool==3 then --普抽 table.insert(this.previewNormalData,v) elseif(v.Pool==11 or v.Pool==12 or v.Pool==13 or v.Pool==14) then-- or v.Pool==15 光暗被移除 table.insert(this.previewElementData, v) elseif v.Pool==5001 then table.insert(this.previewLingShou,v) end end for key, value in ConfigPairs(dailyRewardConfig) do if value.ActivityId == 30 then table.insert( this.previewLuckData, value) else table.insert( this.previewGhostFindData, value) end end if #this.previewLuckData > 1 then table.sort(this.previewLuckData, function(a, b) return a.Rank < b.Rank end) end if #this.previewGhostFindData > 1 then table.sort(this.previewGhostFindData, function(a, b) return a.Rank < b.Rank end) end --灵兽奖品排序 if #this.previewLingShou > 1 then table.sort(this.previewLingShou, function(a, b) --判断品质 if itemConfig[a.Reward[1]].Quantity == itemConfig[b.Reward[1]].Quantity then --判断类型 if itemConfig[a.Reward[1]].ItemType==itemConfig[b.Reward[1]].ItemType then --判断id if a.Reward[1] == b.Reward[1] then return a.Reward[2] < b.Reward[2] else return a.Reward[1] < b.Reward[1] end else return itemConfig[a.Reward[1]].ItemType itemConfig[b.Reward[1]].Quantity end end) end table.sort(this.previewHeroData, function(a, b) if itemConfig[a.Reward[1]].HeroStar[2] == itemConfig[b.Reward[1]].HeroStar[2] then if a.Quality == b.Quality then return a.Id < b.Id else return a.Quality > b.Quality end else return itemConfig[a.Reward[1]].HeroStar[2]>itemConfig[b.Reward[1]].HeroStar[2] end end) --友情 table.sort(this.previewFriendData, function(a, b) if itemConfig[a.Reward[1]].HeroStar[2] == itemConfig[b.Reward[1]].HeroStar[2] then if a.Quality == b.Quality then return a.Id < b.Id else return a.Quality > b.Quality end else return itemConfig[a.Reward[1]].HeroStar[2]>itemConfig[b.Reward[1]].HeroStar[2] end end) --普抽 table.sort(this.previewNormalData, function(a, b) if itemConfig[a.Reward[1]].HeroStar[2] == itemConfig[b.Reward[1]].HeroStar[2] then if a.Quality == b.Quality then return a.Id < b.Id else return a.Quality > b.Quality end else return itemConfig[a.Reward[1]].HeroStar[2]>itemConfig[b.Reward[1]].HeroStar[2] end end) --元素 LogPink("#this.previewElementData:"..#this.previewElementData) table.sort(this.previewElementData, function(a, b) if (itemConfig[a.Reward[1]].Quantity == itemConfig[b.Reward[1]].Quantity) then if (a.Quality == b.Quality) then return a.Id > b.Id else return a.Quality > b.Quality end else return itemConfig[a.Reward[1]].Quantity > itemConfig[b.Reward[1]].Quantity end end) end --获取抽卡奖励预览数据 function this.GetRewardPreviewData(type) if type == PRE_REWARD_POOL_TYPE.RECRUIT then--常驻 return this.previewHeroData elseif type == PRE_REWARD_POOL_TYPE.ELEMENT_RECRUIT then--常驻 return this.previewElementData elseif type == PRE_REWARD_POOL_TYPE.LUCK_FIND then--常驻 return this.previewLuckData elseif type == PRE_REWARD_POOL_TYPE.UPPER_LUCK_FIND then--常驻 return this.previewGhostFindData elseif type ==PRE_REWARD_POOL_TYPE.FRIEND then--常驻 return this.previewFriendData elseif type==PRE_REWARD_POOL_TYPE.NORMAL then--常驻 return this.previewNormalData elseif type==PRE_REWARD_POOL_TYPE.LING_SHOU then--常驻 return this.previewLingShou elseif type==PRE_REWARD_POOL_TYPE.TIME_LIMITED--限时招募--开启时间有限制的 or type==PRE_REWARD_POOL_TYPE.TIME_LIMITED_UP--限时招募UP or type==PRE_REWARD_POOL_TYPE.LOTTERY_SOUL--乾坤宝盒 or type==PRE_REWARD_POOL_TYPE.LOTTERY_SOUL_UP--乾坤宝盒UP or type==PRE_REWARD_POOL_TYPE.LING_SHOU_UP--灵兽宝阁UP or type==PRE_REWARD_POOL_TYPE.XIANG_YAO_UP then--降妖夺宝UP return this.GetActivityPreviewData(type)--非常驻抽卡需要检测时间 else return {} end end function this.GetActivityPreviewData(type)--非常驻抽卡奖池预览 local previewData = {} -- 根据当前期获取卡池信息 local curActivityId = nil if type==PRE_REWARD_POOL_TYPE.TIME_LIMITED or type==PRE_REWARD_POOL_TYPE.TIME_LIMITED_UP then curActivityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy) elseif type==PRE_REWARD_POOL_TYPE.LOTTERY_SOUL or type==PRE_REWARD_POOL_TYPE.LOTTERY_SOUL_UP then curActivityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.QianKunBox) elseif type==PRE_REWARD_POOL_TYPE.LING_SHOU_UP then curActivityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.LingShouBaoGe) elseif type==PRE_REWARD_POOL_TYPE.XIANG_YAO_UP then curActivityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.XiangYaoDuoBao) end local data = nil if curActivityId ~= nil then --活动招募 --LogGreen("curActivityId:"..curActivityId) data = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"ActivityId",curActivityId,"PerCount",1) else LogRed("活动没开,你不应该看到这儿"..curActivityId) end local poolId = nil if data ~= nil then if type == PRE_REWARD_POOL_TYPE.TIME_LIMITED or type == PRE_REWARD_POOL_TYPE.LOTTERY_SOUL then--限时招募,乾坤宝盒 poolId = data.DiamondBoxContain[1][1] elseif type == PRE_REWARD_POOL_TYPE.TIME_LIMITED_UP or type == PRE_REWARD_POOL_TYPE.LOTTERY_SOUL_UP then--限时招募UP,乾坤宝盒UP data = ConfigManager.GetConfigDataByKey(ConfigName.LotterySpecialConfig,"Type",data.MergePool) poolId = data.pool_id elseif type == PRE_REWARD_POOL_TYPE.LING_SHOU_UP or type == PRE_REWARD_POOL_TYPE.XIANG_YAO_UP then--灵兽宝阁,降妖夺宝 poolId = data.DiamondBoxContain[1][1] end else LogRed("lotterySetting表里没有这个活动:"..curActivityId) end for i, v in ConfigPairs(lotteryRewardConfig) do if(v.Pool == poolId) then table.insert(previewData, v) end end table.sort(previewData, function(a, b) if itemConfig[a.Reward[1]].Quantity == itemConfig[b.Reward[1]].Quantity then return a.Weight > b.Weight else return itemConfig[a.Reward[1]].Quantity > itemConfig[b.Reward[1]].Quantity end end) return previewData end --获取英雄星级数据的最大长度(动态) type 数据类型 star 星级 function this.GetHeroMaxLengthByStar_Dynamic(type,star) local d={} for i, v in ipairs(this.GetRewardPreviewData(type)) do if itemConfig[v.Reward[1]].HeroStar[2]==star then table.insert(d,v) end end return #d end --获取抽卡消耗数据 --根据数据长度遍历;若前者不足 返回后者数据;若都不足 返回最后那组数据;若前者足 显示前者 function this.GetExpendData(type) local d local k=0 for i, v in ipairs(lotterySetting[type].CostItem) do if BagManager.GetItemCountById(v[1])>=v[2] then d=v break else k=k+1 end end local l=#lotterySetting[type].CostItem if k==l then return lotterySetting[type].CostItem[l] end return d end return this