源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.5 KiB

  1. PowerTurnTableModel = PowerTurnTableModel or BaseClass(BaseVo, true)
  2. local PowerTurnTableModel = PowerTurnTableModel
  3. PowerTurnTableModel.REQUEST_INFO = "PowerTurnTableModel.REQUEST_INFO"
  4. PowerTurnTableModel.UPDATE_VIEW_INFO = "PowerTurnTableModel.UPDATE_VIEW_INFO" -- 更新源能转盘红点
  5. PowerTurnTableModel.OPEN_MAIN_VIEW = "PowerTurnTableModel.OPEN_MAIN_VIEW" -- 打开源能转盘界面
  6. PowerTurnTableModel.OPEN_EXCHANGE_VIEW = "PowerTurnTableModel.OPEN_EXCHANGE_VIEW"--打开积分兑换界面
  7. PowerTurnTableModel.START_TURN_ACTION = "PowerTurnTableModel.START_TURN_ACTION"--开始转盘动画
  8. PowerTurnTableModel.UPDATE_RECORD_INFO = "PowerTurnTableModel.UPDATE_RECORD_INFO"--更新日志
  9. PowerTurnTableModel.UPDATE_EXCHANGE_VIEW = "PowerTurnTableModel.UPDATE_EXCHANGE_VIEW"--刷新兑换界面
  10. PowerTurnTableModel.OPEN_EXCHANGE_REQ_VIEW = "PowerTurnTableModel.OPEN_EXCHANGE_REQ_VIEW"--打开兑换请求界面
  11. function PowerTurnTableModel:__init()
  12. PowerTurnTableModel.Instance = self
  13. self:Reset()
  14. end
  15. function PowerTurnTableModel:Reset()
  16. self.is_skip_turn_table_action = false
  17. self.server_award_info = {}--界面信息
  18. self.record_info_list = {}--日志信息
  19. self.exchange_info = {}--兑换界面信息
  20. self.buy_toggle = {}--购买确认
  21. self.login_red_list = {}
  22. self.time_id_list = {}
  23. self.time_red_list = {}--倒计时五小时有积分可以兑换就有红点
  24. self.can_exchange_red_list = {}--可以兑换的红点列表
  25. end
  26. function PowerTurnTableModel:getInstance()
  27. if self.Instance == nil then
  28. self.Instance = PowerTurnTableModel.New()
  29. end
  30. return self.Instance
  31. end
  32. --检查源能转盘开启
  33. function PowerTurnTableModel:CheckPowerTurnTableIconBoolOpen( sub_type )
  34. local base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
  35. local sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(base_type)
  36. local level = RoleManager.Instance.mainRoleInfo.level
  37. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  38. local is_open = false
  39. local end_time = 0
  40. local open_level = 1
  41. local icon_sub_type = base_type*1000 + sub_type
  42. if sub_type >= 10001 then
  43. icon_sub_type = base_type*100000 + sub_type
  44. end
  45. if act_list and act_list.etime then
  46. for l,w in pairs(act_list.condition_list) do
  47. if type(w) == "table" and w[1] == "role_lv" then
  48. open_level = tonumber(w[2])
  49. break
  50. end
  51. end
  52. local have_time = TimeUtil:getServerTime( ) - act_list.stime
  53. end_time = act_list.etime - TimeUtil:getServerTime()
  54. is_open = have_time > 0 and end_time > 0 and open_level <= RoleManager.Instance.mainRoleInfo.level
  55. if GetModuleIsOpen(331,base_type) then
  56. if is_open then
  57. self:SetDelayTimeList(sub_type)
  58. ActivityIconManager:getInstance():addIcon(icon_sub_type, end_time)
  59. else
  60. ActivityIconManager:getInstance():deleteIcon(icon_sub_type)
  61. end
  62. else
  63. -- print("huangcong:KfActivityModel [62]: ",key)
  64. end
  65. else
  66. ActivityIconManager:getInstance():deleteIcon(icon_sub_type)
  67. end
  68. end
  69. function PowerTurnTableModel:SetDelayTimeList( sub_type )
  70. if self.time_id_list[sub_type] then
  71. GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
  72. self.time_id_list[sub_type] = nil
  73. end
  74. if self.time_red_list[sub_type] then
  75. return
  76. end
  77. local base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
  78. local act_list = CustomActivityModel:getInstance():getActList(base_type,sub_type) or {}
  79. if not act_list then return end
  80. local end_time = act_list.etime
  81. local haly_hour = 3600*5
  82. local sec = end_time - TimeUtil:getServerTime()
  83. if sec > 0 then
  84. local function onTimer()
  85. sec = end_time - TimeUtil:getServerTime()
  86. if sec < haly_hour then--五小时有可以兑换的要给予红点且所有奖励有未购买完的
  87. if self.time_id_list[sub_type] then
  88. GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
  89. self.time_id_list[sub_type] = nil
  90. end
  91. self.time_red_list[sub_type] = true
  92. self:CheckPowerTurnTableMainRedDot(sub_type)
  93. self:Fire(PowerTurnTableModel.UPDATE_VIEW_INFO,sub_type)
  94. end
  95. end
  96. onTimer()
  97. if not self.time_id_list[sub_type] then
  98. self.time_id_list[sub_type] = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
  99. end
  100. end
  101. end
  102. --源能转盘信息
  103. function PowerTurnTableModel:SetPowerTurnTableInfo( vo )
  104. local sort_func = function ( a, b )
  105. return a.id < b.id
  106. end
  107. table.sort(vo.pool_list, sort_func)
  108. for i,v in ipairs(vo.pool_list) do
  109. v.reward = stringtotable(v.reward)[1]
  110. end
  111. self.server_award_info[vo.sub_type] = vo
  112. self:Fire(PowerTurnTableModel.UPDATE_VIEW_INFO,vo.sub_type)
  113. self:CheckPowerTurnTableMainRedDot(vo.sub_type)
  114. end
  115. function PowerTurnTableModel:GetPowerTurnTableInfo( sub_type )
  116. return self.server_award_info[sub_type]
  117. end
  118. function PowerTurnTableModel:CheckPowerTurnTableMainRedDot( sub_type )
  119. local bool = false
  120. local base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
  121. if not sub_type then return end
  122. local icon_sub_type = base_type*1000 + sub_type
  123. if sub_type >= 10001 then
  124. icon_sub_type = base_type*100000 + sub_type
  125. end
  126. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  127. if not act_list then
  128. return
  129. else
  130. local server_award_info = self:GetPowerTurnTableInfo(sub_type)
  131. if server_award_info and server_award_info.free_time and server_award_info.free_time > 0 then--免费红点
  132. bool = true
  133. end
  134. if not bool and not self.login_red_list[sub_type] then--每次登陆给一次红点
  135. bool = true
  136. end
  137. if not bool and self.time_red_list[sub_type] and self.can_exchange_red_list[sub_type] then--倒计时5小时兑换红点
  138. bool = true
  139. end
  140. if not bool then
  141. local last_time_list = self:GetPowerTTScoreCookie()--积分按钮每日首次红点
  142. local score = self.server_award_info[sub_type] and self.server_award_info[sub_type].score or 0
  143. if not last_time_list[sub_type] then
  144. bool = score > 0
  145. end
  146. end
  147. GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, icon_sub_type, bool)
  148. end
  149. end
  150. --设置抽奖记录数据
  151. function PowerTurnTableModel:SetRecordInfo( scmd )
  152. self.record_info_list[scmd.sub_type] = scmd.list
  153. end
  154. function PowerTurnTableModel:GetRecordInfo( sub_type )
  155. return self.record_info_list[sub_type]
  156. end
  157. --设置兑换界面数据
  158. function PowerTurnTableModel:SetExchangeInfoList( scmd )
  159. self.can_exchange_red_list[scmd.sub_type] = false
  160. for i,v in ipairs(scmd.swap_list) do
  161. v.reward = stringtotable(v.reward)[1]
  162. v.sort_id = v.id + (v.left_times == 0 and 1000 or 0)--兑换完置底
  163. if v.left_times > 0 and scmd.cur_score >= v.score and not self.can_exchange_red_list[scmd.sub_type] then
  164. self.can_exchange_red_list[scmd.sub_type] = true
  165. end
  166. end
  167. local sort_func = function ( a, b )
  168. return a.sort_id < b.sort_id
  169. end
  170. table.sort(scmd.swap_list, sort_func)
  171. self.exchange_info[scmd.sub_type] = scmd.swap_list
  172. self:CheckPowerTurnTableMainRedDot(scmd.sub_type)
  173. end
  174. --获得源能转盘兑换界面信息
  175. function PowerTurnTableModel:GetExchangeInfoList( sub_type )
  176. return self.exchange_info[sub_type]
  177. end
  178. --设置源能转盘红点cookie
  179. function PowerTurnTableModel:SetPowerTTScoreCookie( sub_type,time )
  180. local list = self:GetPowerTTScoreCookie() or {}
  181. list[sub_type] = time
  182. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_DAY2,CookieKey.POWER_TURN_TABLE_SCORE_RED,list)
  183. CookieWrapper.Instance:WriteAll()
  184. end
  185. --获得源能转盘红点cookie
  186. function PowerTurnTableModel:GetPowerTTScoreCookie( )
  187. local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.POWER_TURN_TABLE_SCORE_RED) or {}
  188. return bool
  189. end