UILuckyTurnTableInfo.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. ---@class UILuckyTurnTableInfo
  2. UILuckyTurnTableInfo = class()
  3. local this = UILuckyTurnTableInfo
  4. function this:Init()
  5. self:RegistMessages()
  6. self:Reset()
  7. end
  8. function this:Reset()
  9. self.IsSkip = false
  10. self.IsFree = false
  11. self.IsCanReceived = false
  12. self.BtnRedDotList = {}
  13. self.turntableRaffleActiveList = {}
  14. end
  15. function this:RegistMessages()
  16. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TURNTABLE_RAFFLE_FREE_TIME, self.RES_TURNTABLE_RAFFLE_FREE_TIME, self)-- 响应抽奖免费时间
  17. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_MAIN_ACTIVE_INFO, self.RES_MAIN_ACTIVE_INFO, self)-- 响应抽奖
  18. SL:RegisterLUAEvent(LUA_EVENT_MAINOPERATEACTIVITY_CHANGE, self.RefreshRedDotShow, self)
  19. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_COMMON_RED_POINT_MESSAGE, self.CommonRedPointMessage, self)
  20. end
  21. function this:CommonRedPointMessage(_, message)
  22. for k, v in pairs(message) do
  23. local redPointId = tonumber(k)
  24. if redPointId==105 then
  25. self.IsFree = v
  26. InfoManager.mainOperateActivityInfo:RefreshMainOperateActivityRedPoint( EOperateActivityActivityType.luckyTurnTable,"tog_lottery", self:IsRedDot())
  27. --SL:RefreshPanelALLRedStateKmlByCondition("checkLuckyTurnTable")
  28. end
  29. if redPointId==106 then
  30. InfoManager.mainOperateActivityInfo:RefreshMainOperateActivityRedPoint( EOperateActivityActivityType.luckyTurnTable,"tog_lottery", self:IsRedDot())
  31. --SL:RefreshPanelALLRedStateKmlByCondition("checkLuckyTurnTable")
  32. end
  33. end
  34. end
  35. function this:RefreshRedDotShow()
  36. if next(self.turntableRaffleActiveList) then
  37. for id, v in pairs(self.turntableRaffleActiveList) do
  38. InfoManager.mainOperateActivityInfo:RefreshMainOperateActivityRedPoint( EOperateActivityActivityType.luckyTurnTable,"tog_lottery", self:IsBtnRedDot(id))
  39. end
  40. end
  41. end
  42. function this:RES_MAIN_ACTIVE_INFO(_, message)
  43. -----面板信息
  44. if message and message.turntableRaffleActive then
  45. self.IsCanReceived = false
  46. self.turntableRaffleActiveList = message.turntableRaffleActive
  47. for id, v in pairs(self.turntableRaffleActiveList) do
  48. local totalCount = v.total--抽奖总次数
  49. self.IsFree = v.canFree--可否免费抽奖
  50. local received = v.received--已经领取过的奖励id cfg_turntable_extra表id
  51. local curTurnTbl = InfoManager.luckyTurnTableInfo:GetTurnTableDataByActivityId(message.mainActive.mainGroup)
  52. local CountRewardTbl = self:GetTurnTableAwardListByActivityId(curTurnTbl.id)
  53. if self.IsFree == true then
  54. self.BtnRedDotList[id] = self.IsFree
  55. else
  56. self.BtnRedDotList[id] = false
  57. end
  58. for _, reward in pairs(CountRewardTbl) do
  59. if totalCount > reward.num then
  60. if not self:IsGetReceived(reward.id, received) then
  61. self.BtnRedDotList[id] = true
  62. self.IsCanReceived = true
  63. end
  64. end
  65. end
  66. end
  67. self:RefreshRedDotShow()
  68. SL:RefreshPanelALLRedStateKmlByCondition("checkLuckyTurnTable")
  69. end
  70. end
  71. ---@field id number @cfg_turntable表id
  72. function this:IsGetReceived(id, received)
  73. for _, v in pairs(received) do
  74. if id == v then
  75. return true
  76. end
  77. end
  78. return false
  79. end
  80. function this:RES_TURNTABLE_RAFFLE_FREE_TIME(_, message)
  81. if message then
  82. self.IsFree = message.isFree
  83. self:RefreshRedDotShow()
  84. SL:RefreshPanelALLRedStateKmlByCondition("checkLuckyTurnTable")
  85. end
  86. end
  87. ---@field btnId number @cfg_turntable表id
  88. function this:IsBtnRedDot(btnId)
  89. return self.BtnRedDotList[btnId]
  90. end
  91. function this:IsRedDot()
  92. return self.IsFree or self.IsCanReceived
  93. end
  94. ---获取某id活动转盘表id 暂时唯一
  95. ---@field group number @cfg_turntable表mainGroup
  96. function this:GetTurnTableDataByActivityId(group)
  97. local turnTbl = SL:GetConfigTable("cfg_turntable")
  98. for _, v in pairs(turnTbl) do
  99. if v.mainGroup == tonumber(group) then
  100. return v
  101. end
  102. end
  103. return nil
  104. end
  105. ---获取某id活动转盘表id 暂时唯一
  106. ---@field group number @cfg_turntable表mainGroup
  107. function this:GetTurnTableDataByActivityIdAndType(group,type)
  108. local turnTbl = SL:GetConfigTable("cfg_turntable_reward")
  109. for _, v in pairs(turnTbl) do
  110. if v.group == tonumber(group) and v.type == type then
  111. return v
  112. end
  113. end
  114. return nil
  115. end
  116. ---获取轮盘大奖主表id
  117. function this:GetTurnTableBigListByActivityId(relevance)
  118. local bigList = {}
  119. local turnTbl = SL:GetConfigTable("cfg_turntable_extra")
  120. for _, v in pairs(turnTbl) do
  121. if v.bigReward == 1 and tonumber(relevance) == v.relevance then
  122. table.insert(bigList, v)
  123. end
  124. end
  125. return bigList
  126. end
  127. ---获取轮盘奖主表id
  128. function this:GetTurnTableAwardListByActivityId(relevance)
  129. local List = {}
  130. local turnTbl = SL:GetConfigTable("cfg_turntable_extra")
  131. for _, v in pairs(turnTbl) do
  132. if tonumber(relevance) == v.relevance then
  133. table.insert(List, v)
  134. end
  135. end
  136. return List
  137. end