RuneShopDataMgr.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. local RuneShopDataMgr = class("RuneShopDataMgr", require("DataBase"))
  2. local RuneShopBaseData = require('RuneShop/RuneShopBaseData')
  3. local RuneShopReardsBaseData = require('RuneShop/RuneShopRewardsBaseData')
  4. local RUNESHOP_REQ_CD = 2000
  5. function RuneShopDataMgr:ctor()
  6. self.runeShopDatas = {}
  7. self.forceCheck = false
  8. end
  9. function RuneShopDataMgr:Clear()
  10. self.runeShopDatas = {}
  11. self.forceCheck = false
  12. self.specialPrivilegeId = nil
  13. self.specialPrivilegeTime = nil
  14. self.roPassStatus = nil
  15. end
  16. function RuneShopDataMgr:Destroy()
  17. self.runeShopDatas = nil
  18. self.lastSendMsgTimeMap = nil
  19. self.forceCheck = nil
  20. self.specialPrivilegeId = nil
  21. self.specialPrivilegeTime = nil
  22. self.roPassStatus = nil
  23. self:UnRegisterNetEvents()
  24. end
  25. function RuneShopDataMgr:RegisterNetEvents()
  26. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_RUNE_SHOP_INFO_ACK, self.OnRuneShopInfoAck, self)
  27. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_RUNE_SHOP_BUY_ITEM_NTF, self.OnRuneShopInfoNtf, self)
  28. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_RUNE_FREE_RED_CHANGE_INFO_NTF, self.OnRuneShopFreeItemChangeNtf, self)
  29. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_EXPLORE_INFO_ACK, self.OnRuneShopRewardInfoAck, self)
  30. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_EXPLORE_EXTRA_REWARD_ACK, self.OnRuneShopRewardExtraAck, self)
  31. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_EXPLORE_REWARD_ACK, self.OnRuneShopRewardACK, self)
  32. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_EXPLORE_EXP_CHANGE_NTF, self.OnRuneShopExchangeNtf, self)
  33. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_RUNE_BASE_DATA_NTF, self.OnRuneShopBaseNtf, self)
  34. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_RUNE_SPECIAL_PRIVILEGE_REWARD_ACK, self.OnRuneSpecialPrvilegeRewardAck, self)
  35. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_BT_SHOP_INFO_ACK, self.OnRuneShopInfoAck, self)
  36. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_BT_RO_COIN_SHOP_ITEM_BUY_ACK, self.OnRuneShopRoCoinBuyItem, self)
  37. end
  38. function RuneShopDataMgr:UnRegisterNetEvents()
  39. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_RUNE_SHOP_INFO_ACK)
  40. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_RUNE_SHOP_BUY_ITEM_NTF)
  41. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_RUNE_FREE_RED_CHANGE_INFO_NTF)
  42. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_EXPLORE_INFO_ACK)
  43. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_EXPLORE_EXTRA_REWARD_ACK)
  44. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_EXPLORE_REWARD_ACK)
  45. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_EXPLORE_EXP_CHANGE_NTF, self.OnRuneShopExchangeNtf, self)
  46. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_RUNE_BASE_DATA_NTF, self.OnRuneShopBaseNtf, self)
  47. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_RUNE_SPECIAL_PRIVILEGE_REWARD_ACK, self.OnRuneSpecialPrvilegeRewardAck, self)
  48. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_BT_SHOP_INFO_ACK, self.OnRuneShopInfoAck, self)
  49. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_BT_RO_COIN_SHOP_ITEM_BUY_ACK, self.OnRuneShopRoCoinBuyItem, self)
  50. end
  51. function RuneShopDataMgr:OnRuneShopInfoAck(data)
  52. LogError('[wboy] SC_RUNE_SHOP_INFO_ACK ' .. Inspect(data))
  53. if ManagerContainer.NetManager:IsErrorData(data) then
  54. return
  55. end
  56. local runeShopType = data.shop_type
  57. local runeShopSubType = data.sub_shop
  58. local shopData = self:GetShopData(runeShopType, runeShopSubType, true)
  59. if not shopData then return end
  60. shopData:SetData(data)
  61. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_DATA_CHANGED, runeShopType, runeShopSubType)
  62. if runeShopType == Enum.RuneShopType.LimitTime then
  63. ManagerContainer.RedPointMgr.RSLimitGiftRPCtr:RefreshLimitGiftRedPointByShopData(shopData)
  64. end
  65. end
  66. function RuneShopDataMgr:OnRuneShopInfoNtf(data)
  67. -- LogError('[wboy] SC_RUNE_SHOP_BUY_ITEM_NTF ' .. Inspect(data))
  68. if ManagerContainer.NetManager:IsErrorData(data) then
  69. return
  70. end
  71. local shopItem = data.shop_item
  72. if not shopItem then return end
  73. local runeShopType = data.shop_type
  74. local runeShopSubType = data.sub_shop
  75. local shopData = self:GetShopData(runeShopType, runeShopSubType)
  76. if not shopData then return end
  77. shopData:RefreshOneGoodsData(shopItem)
  78. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_DATA_CHANGED, runeShopType, runeShopSubType)
  79. end
  80. function RuneShopDataMgr:OnRuneShopFreeItemChangeNtf(data)
  81. -- LogError('[wboy] SC_RUNE_FREE_RED_CHANGE_INFO_NTF ' .. Inspect(data))
  82. if ManagerContainer.NetManager:IsErrorData(data) then
  83. return
  84. end
  85. local runeReds = data.rune_red
  86. local red1 = false
  87. local red2 = false
  88. local red3 = false
  89. for i = 1, #runeReds do
  90. local runeRed = runeReds[i]
  91. if runeRed.key == Enum.RuneShopType.Gifts then
  92. if runeRed.value == Enum.RuneShopSubType.Daily then
  93. red1 = true
  94. elseif runeRed.value == Enum.RuneShopSubType.Week then
  95. red2 = true
  96. elseif runeRed.value == Enum.RuneShopSubType.Month then
  97. red3 = true
  98. end
  99. end
  100. end
  101. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopDaily, red1)
  102. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopWeek, red2)
  103. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopMonth, red3)
  104. ManagerContainer.RedPointMgr.RSLimitGiftRPCtr:RefreshLimitGiftRedPointByIds(data.limit_red)
  105. end
  106. function RuneShopDataMgr:RefreshRewardsData(data)
  107. local shopData = self:GetRewardsData()
  108. if not shopData then LogError('战令数据类不存在') return end
  109. shopData:SetRewardData(data)
  110. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_REWARDS_DATA_CHANGED)
  111. end
  112. function RuneShopDataMgr:RefreshRecieveRewardsData(data)
  113. local shopData = self:GetRewardsData()
  114. if not shopData then return end
  115. shopData:SetRecRewardData(data)
  116. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_REWARDS_DATA_CHANGED)
  117. end
  118. function RuneShopDataMgr:RefreshExtraRewardsData(data)
  119. local shopData = self:GetRewardsData()
  120. if not shopData then return end
  121. shopData:SetRecExtraRewardData(data)
  122. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_REWARDS_DATA_CHANGED)
  123. end
  124. function RuneShopDataMgr:RefreshExploreExpChange(data)
  125. local shopData = self:GetRewardsData()
  126. if not shopData then return end
  127. shopData:SetExpChangeData(data)
  128. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_REWARDS_DATA_CHANGED)
  129. end
  130. function RuneShopDataMgr:OnRuneShopRewardInfoAck(data)
  131. --LogError('[xyh] SC_EXPLORE_REWARD_ACK ' .. Inspect(data))
  132. if ManagerContainer.NetManager:IsErrorData(data) then
  133. return
  134. end
  135. self.isRewardsDataDirty = false
  136. self.hasRewardData = true
  137. self:OnOnlineAirShipInfoAck(data)
  138. if self:GetAirShipIsOpen() then
  139. self:RefreshRewardsData(data)
  140. end
  141. end
  142. function RuneShopDataMgr:OnRuneShopRewardExtraAck(data)
  143. if ManagerContainer.NetManager:IsErrorData(data) then
  144. return
  145. end
  146. if not data then return end
  147. self:RefreshExtraRewardsData(data)
  148. if #data.award_item == 0 then return end
  149. --LogError('[xyh] SC_EXPLORE_EXTRA_REWARD_ACK ' .. Inspect(data))
  150. local rewardList = { {cfgId= data.award_item[1].key,num = data.award_item[1].value}}
  151. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPOPGot,{rewards = rewardList})
  152. end
  153. function RuneShopDataMgr:OnOnlineAirShipInfoAck(data)
  154. if data.bUnlock then
  155. self.isCash = 0
  156. else
  157. self.isCash = 0
  158. end
  159. self.airShipRewardEndTime = data.endTime
  160. self.airShipRewardStartTime = data.startTime
  161. self.airShipRewardsNextTime = data.nextStartTime
  162. if self.isCash == 0 then
  163. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.AIRSHIP_ACTIVITY_DISPLAY_NTF,self:GetAirShipIsOpen())
  164. else
  165. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.AIRSHIP_ACTIVITY_DISPLAY_NTF,false)
  166. end
  167. --self:CheckAirShipActivityOpenTime()
  168. end
  169. function RuneShopDataMgr:OnRuneShopRewardACK(data)
  170. --LogError('[xyh] SC_EXPLORE_REWARD_ACK ' .. Inspect(data))
  171. if #data.award_item == 0 then return end
  172. if ManagerContainer.NetManager:IsErrorData(data) then
  173. return
  174. end
  175. local rewardList = { {cfgId= data.award_item[1].key,num = data.award_item[1].value}}
  176. --LogError('[xyh] SC_EXPLORE_REWARD_ACK ' .. Inspect(rewardList))
  177. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPOPGot,{rewards = rewardList})
  178. self:RefreshRecieveRewardsData(data)
  179. end
  180. function RuneShopDataMgr:OnRuneShopExchangeNtf(data)
  181. --LogError('[xyh] SC_EXPLORE_EXP_CHANGE_NTF' .. Inspect(data))
  182. if ManagerContainer.NetManager:IsErrorData(data) then
  183. return
  184. end
  185. self:RefreshExploreExpChange(data)
  186. end
  187. function RuneShopDataMgr:SendShopInfoReq(runeShopType, runeShopSubType)
  188. local id = runeShopType * 100 + (runeShopSubType or 0)
  189. if not self:IsCanSend(id) then return false end
  190. if runeShopType == Enum.RuneShopType.Gifts and runeShopSubType == Enum.RuneShopSubType.ROCoin then
  191. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_BT_SHOP_INFO_REQ, {shop_type = runeShopType, sub_shop = runeShopSubType})
  192. else
  193. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_RUNE_SHOP_INFO_REQ, {shop_type = runeShopType, sub_shop = runeShopSubType})
  194. end
  195. return true
  196. end
  197. function RuneShopDataMgr:SendRewardsInfoReq()
  198. local id = 7 * 100
  199. if not self:IsCanSend(id) then return false end
  200. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_EXPLORE_INFO_REQ)
  201. self.isRewardsDataDirty = true
  202. end
  203. function RuneShopDataMgr:IsCanSend(key, cdTime)
  204. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  205. if not self.lastSendMsgTimeMap then
  206. self.lastSendMsgTimeMap = {}
  207. self.lastSendMsgTimeMap[key] = curTime
  208. return true
  209. end
  210. local lastTime = self.lastSendMsgTimeMap[key]
  211. if lastTime then
  212. local cd = cdTime or RUNESHOP_REQ_CD
  213. if (curTime - lastTime) < cd then
  214. return false
  215. end
  216. end
  217. self.lastSendMsgTimeMap[key] = curTime
  218. return true
  219. end
  220. function RuneShopDataMgr:RefreshShopData(runeShopType, runeShopSubType, forceRefresh)
  221. if not forceRefresh then
  222. local shopData = self:GetShopData(runeShopType, runeShopSubType)
  223. if shopData then
  224. if shopData:IsValidData() then
  225. return
  226. end
  227. end
  228. end
  229. self:SendShopInfoReq(runeShopType, runeShopSubType)
  230. end
  231. function RuneShopDataMgr:RefreshRewardData()
  232. self:SendRewardsInfoReq()
  233. end
  234. function RuneShopDataMgr:GetShopData(runeShopType, runeShopSubType, isNewNil)
  235. local runeShopDatas = self.runeShopDatas[runeShopType]
  236. if not runeShopDatas then
  237. if not isNewNil then
  238. return nil
  239. end
  240. if runeShopType == Enum.RuneShopType.MonthCard then
  241. runeShopDatas = RuneShopBaseData:new()
  242. self.runeShopDatas[runeShopType] = runeShopDatas
  243. elseif runeShopType == Enum.RuneShopType.Gifts then
  244. runeShopDatas = {}
  245. self.runeShopDatas[runeShopType] = runeShopDatas
  246. elseif runeShopType == Enum.RuneShopType.LimitTime then
  247. runeShopDatas = RuneShopBaseData:new()
  248. self.runeShopDatas[runeShopType] = runeShopDatas
  249. elseif runeShopType == Enum.RuneShopType.RushTower then
  250. runeShopDatas = RuneShopBaseData:new()
  251. self.runeShopDatas[runeShopType] = runeShopDatas
  252. elseif runeShopType == Enum.RuneShopType.RushArena then
  253. runeShopDatas = RuneShopBaseData:new()
  254. self.runeShopDatas[runeShopType] = runeShopDatas
  255. elseif runeShopType == Enum.RuneShopType.RushMap then
  256. runeShopDatas = RuneShopBaseData:new()
  257. self.runeShopDatas[runeShopType] = runeShopDatas
  258. elseif runeShopType == Enum.RuneShopType.GuildWar then
  259. runeShopDatas = RuneShopBaseData:new()
  260. self.runeShopDatas[runeShopType] = runeShopDatas
  261. elseif runeShopType == Enum.RuneShopType.RushPet then
  262. runeShopDatas = RuneShopBaseData:new()
  263. self.runeShopDatas[runeShopType] = runeShopDatas
  264. elseif runeShopType == Enum.RuneShopType.RushSkill then
  265. runeShopDatas = RuneShopBaseData:new()
  266. self.runeShopDatas[runeShopType] = runeShopDatas
  267. elseif runeShopType == Enum.RuneShopType.IdolShop then
  268. runeShopDatas = RuneShopBaseData:new()
  269. self.runeShopDatas[runeShopType] = runeShopDatas
  270. end
  271. end
  272. if runeShopType ~= Enum.RuneShopType.Gifts then
  273. return runeShopDatas
  274. end
  275. if runeShopDatas[runeShopSubType] then
  276. return runeShopDatas[runeShopSubType]
  277. end
  278. if not isNewNil then
  279. return nil
  280. end
  281. runeShopDatas[runeShopSubType] = RuneShopBaseData:new()
  282. return runeShopDatas[runeShopSubType]
  283. end
  284. function RuneShopDataMgr:GetRewardsData()
  285. if not self.runeShopRewardsData then
  286. self.runeShopRewardsData = RuneShopReardsBaseData:new()
  287. end
  288. return self.runeShopRewardsData
  289. end
  290. function RuneShopDataMgr:GetCurAirShipActivityEndTime()
  291. return self.airShipRewardEndTime
  292. end
  293. function RuneShopDataMgr:GetAirShipIsOpen()
  294. if not self.airShipRewardEndTime or not self.airShipRewardStartTime then
  295. return false
  296. end
  297. local endt =ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(self.airShipRewardEndTime, false)
  298. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  299. local startt = curTime - self.airShipRewardStartTime
  300. if endt and startt then
  301. if endt > 0 and startt > 0 then
  302. return true
  303. end
  304. end
  305. return false
  306. end
  307. function RuneShopDataMgr:CheckAirShipActivityOpenTime()
  308. local needSend = false
  309. if self:GetAirShipIsOpen() then
  310. if not self.isCash then
  311. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.AIRSHIP_ACTIVITY_DISPLAY_NTF, false)
  312. else
  313. if self.isCash == 0 then
  314. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.AIRSHIP_ACTIVITY_DISPLAY_NTF, true)
  315. else
  316. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.AIRSHIP_ACTIVITY_DISPLAY_NTF, false)
  317. end
  318. end
  319. else
  320. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopRewards, false)
  321. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  322. if self.airShipRewardsNextTime then
  323. if curTime > self.airShipRewardsNextTime and self.airShipRewardsNextTime ~= 0 then
  324. needSend = true
  325. end
  326. end
  327. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.AIRSHIP_ACTIVITY_DISPLAY_NTF, false)
  328. end
  329. if not self.hasRewardData then
  330. needSend = true
  331. end
  332. if needSend then
  333. self:QueryAirShipActivityData()
  334. end
  335. end
  336. function RuneShopDataMgr:QueryAirShipActivityData()
  337. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_EXPLORE_INFO_REQ)
  338. end
  339. function RuneShopDataMgr:CheckMonthData()
  340. local monthShopData = self:GetShopData(Enum.RuneShopType.MonthCard, nil)
  341. if not monthShopData then
  342. self:SendShopInfoReq(Enum.RuneShopType.MonthCard,nil)
  343. else
  344. local mgoodsData = monthShopData:GetGoodsDataByIdx(1)
  345. if mgoodsData then
  346. local outTime = mgoodsData:HasResidueTime()
  347. if not outTime then
  348. return true
  349. end
  350. end
  351. end
  352. return false
  353. end
  354. function RuneShopDataMgr:CheckSuperMonth()
  355. local monthShopData = self:GetShopData(Enum.RuneShopType.MonthCard, nil)
  356. if not monthShopData then
  357. self:SendShopInfoReq(Enum.RuneShopType.MonthCard,nil)
  358. else
  359. local mgoodsData = monthShopData:GetGoodsDataByIdx(2)
  360. if mgoodsData then
  361. local outTime = mgoodsData:HasResidueTime()
  362. if not outTime then
  363. return true
  364. end
  365. end
  366. end
  367. return false
  368. end
  369. function RuneShopDataMgr:OnRuneShopBaseNtf(data)
  370. if not data or not data.rune_base_data then
  371. return
  372. end
  373. self:RefreshSpecialPrivilegeData(data.rune_base_data.privilege_data)
  374. self:RefreshRoPassStatus(data.rune_base_data)
  375. end
  376. function RuneShopDataMgr:OnRuneShopRoCoinBuyItem(data)
  377. -- LogError('[wboy] SC_BT_RO_COIN_SHOP_ITEM_BUY_ACK ' .. Inspect(data))
  378. if ManagerContainer.NetManager:IsErrorData(data) then
  379. return
  380. end
  381. if data.reward_item_list then
  382. local rewardList = {}
  383. for i = 1, #data.reward_item_list do
  384. local _itemData = data.reward_item_list[i]
  385. rewardList[#rewardList+1] = {cfgId = _itemData.key, num = _itemData.value}
  386. end
  387. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPOPGot,{rewards = rewardList})
  388. end
  389. local shopItem = data.shop_item
  390. if not shopItem then return end
  391. local runeShopType = data.goods_type
  392. local runeShopSubType = data.sub_type
  393. local shopData = self:GetShopData(runeShopType, runeShopSubType)
  394. if not shopData then return end
  395. shopData:RefreshOneGoodsData(shopItem)
  396. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_DATA_CHANGED, runeShopType, runeShopSubType)
  397. end
  398. function RuneShopDataMgr:OnRuneSpecialPrvilegeRewardAck(data)
  399. if ManagerContainer.NetManager:IsErrorData(data) then
  400. return
  401. end
  402. if data.reward_item_list then
  403. local rewardList = {}
  404. for i = 1, #data.reward_item_list do
  405. local _itemData = data.reward_item_list[i]
  406. rewardList[#rewardList+1] = {cfgId = _itemData.key, num = _itemData.value}
  407. end
  408. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPOPGot,{rewards = rewardList})
  409. end
  410. end
  411. function RuneShopDataMgr:SendRuneSpecialPrvilegeRewardReq()
  412. if not self:IsCanSend(1) then return false end
  413. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_RUNE_SPECIAL_PRIVILEGE_REWARD_REQ)
  414. return true
  415. end
  416. function RuneShopDataMgr:SendRuneRoCoinBuyItemReq(goods_id)
  417. if not self:IsCanSend(1) then return false end
  418. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_BT_RO_COIN_SHOP_ITEM_BUY_REQ, {goods_id = goods_id, goods_num = 1})
  419. return true
  420. end
  421. function RuneShopDataMgr:RefreshSpecialPrivilegeData(data)
  422. local specialPrivilegeId = self.specialPrivilegeId
  423. local specialPrivilegeTime = self.specialPrivilegeTime
  424. self.specialPrivilegeId = data and data.special_id or nil
  425. self.specialPrivilegeTime = data and data.reward_time or nil
  426. if self.specialPrivilegeId ~= specialPrivilegeId or self.specialPrivilegeTime ~= specialPrivilegeTime then
  427. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_DATA_CHANGED, Enum.RuneShopType.SpecialPrivilege)
  428. if self.specialPrivilegeId then
  429. local hasRP = self:CanGetSpecialPrivilegeReward()
  430. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.RuneShopSpecialPrivilege, hasRP)
  431. end
  432. end
  433. end
  434. function RuneShopDataMgr:GetSpecialPrivilegeId()
  435. return self.specialPrivilegeId
  436. end
  437. function RuneShopDataMgr:CanGetSpecialPrivilegeReward()
  438. if not self.specialPrivilegeId or self.specialPrivilegeId <= 0 then
  439. return false
  440. end
  441. if not self.specialPrivilegeTime then
  442. return true
  443. end
  444. if self.specialPrivilegeTime > 0 then
  445. return false
  446. end
  447. return true
  448. end
  449. function RuneShopDataMgr:CheckSpecialPrivilegeSpeed()
  450. if not self.specialPrivilegeId then
  451. return false
  452. end
  453. local cfgData = ManagerContainer.CfgMgr:GetPrivilegeCardCfgByLv(self.specialPrivilegeId)
  454. if not cfgData or not cfgData.QuickBattle then
  455. return false
  456. end
  457. return cfgData.QuickBattle == 1
  458. end
  459. function RuneShopDataMgr:RefreshRoPassStatus(data)
  460. local roPassStatus = self.roPassStatus
  461. self.roPassStatus = data.is_pass_check or false
  462. if self.roPassStatus ~= roPassStatus then
  463. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RUNE_SHOP_DATA_CHANGED, Enum.RuneShopType.PassCheck)
  464. end
  465. end
  466. function RuneShopDataMgr:GetRoPassStatus()
  467. return self.roPassStatus
  468. end
  469. function RuneShopDataMgr:GetRoPassAutoBattle()
  470. if not self.roPassStatus then
  471. return false
  472. end
  473. local cfgData = ManagerContainer.CfgMgr:GetPassCheckCfgById(1)
  474. if not cfgData or not cfgData.Automatic then
  475. return false
  476. end
  477. return cfgData.Automatic == 1
  478. end
  479. return RuneShopDataMgr