源战役客户端
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.

627 rivejä
20 KiB

4 viikkoa sitten
  1. SakuraGiftModel = SakuraGiftModel or BaseClass(BaseVo, true)
  2. local SakuraGiftModel = SakuraGiftModel
  3. SakuraGiftModel.REQUEST_CCMD_EVENT = "SakuraGiftModel.REQUEST_CCMD_EVENT"
  4. SakuraGiftModel.REFRESH_ACT_INFO = "SakuraGiftModel.REFRESH_ACT_INFO"--基础信息更新
  5. SakuraGiftModel.REFRESH_RECORD_INFO = "SakuraGiftModel.REFRESH_RECORD_INFO"--记录信息
  6. SakuraGiftModel.REFRESH_SHOP_INFO = "SakuraGiftModel.REFRESH_SHOP_INFO" -- 刷新商店信息
  7. SakuraGiftModel.OPEN_BASE_VIEW = "SakuraGiftModel.OPEN_BASE_VIEW"--主界面
  8. -- SakuraGiftModel.OPEN_EXCHANGE_VIEW = "SakuraGiftModel.OPEN_EXCHANGE_VIEW"--兑换商城界面
  9. SakuraGiftModel.OPEN_SHOP_VIEW = "SakuraGiftModel.OPEN_SHOP_VIEW"--兑换商城界面
  10. SakuraGiftModel.OPEN_EXCHANGE_REQ_VIEW = "SakuraGiftModel.OPEN_EXCHANGE_REQ_VIEW"--兑换数目界面
  11. SakuraGiftModel.OPEN_MESSAGE_VIEW = "SakuraGiftModel.OPEN_MESSAGE_VIEW" -- 打开滚屏界面
  12. SakuraGiftModel.OPEN_REWARD_VIEW = "SakuraGiftModel.OPEN_REWARD_VIEW" -- 打开奖励预览
  13. SakuraGiftModel.UPDATE_CHUANWEN = "SakuraGiftModel.UPDATE_CHUANWEN" -- 更新记录
  14. SakuraGiftModelRedType = {
  15. Login = 1, -- 每天首次登陆
  16. Exchange = 2, -- 最后5小时可兑换红点
  17. CanGo = 3, -- 抽奖红点
  18. LoginExchange = 4, -- 首次登陆兑换红点
  19. }
  20. local NeedCheckExchangeRedTime = 18000
  21. function SakuraGiftModel:__init()
  22. SakuraGiftModel.Instance = self
  23. self:Reset()
  24. end
  25. function SakuraGiftModel:Reset()
  26. self.act_info = {}
  27. self.shop_info = {}
  28. self.base_type = CustomActivityModel.CustomActBaseType.SAKURA_GIFT
  29. self.exchange_red = {}
  30. self.login_exchange_red = {}
  31. self.login_red = {}
  32. self.can_go_red = {}
  33. self.sub_type_list = {}
  34. self.time_id_list = {}
  35. end
  36. function SakuraGiftModel:getInstance()
  37. if SakuraGiftModel.Instance == nil then
  38. SakuraGiftModel.Instance = SakuraGiftModel.New()
  39. end
  40. return SakuraGiftModel.Instance
  41. end
  42. function SakuraGiftModel:GetKeyValueConf( suit,key )
  43. if not self.Sakuragiftkey_Cfg then
  44. self:InitSakuragiftkeyCfg( )
  45. end
  46. return (self.Sakuragiftkey_Cfg[suit] and self.Sakuragiftkey_Cfg[suit][key])
  47. and self.Sakuragiftkey_Cfg[suit][key].value or nil
  48. end
  49. function SakuraGiftModel:InitSakuragiftkeyCfg( )
  50. self.Sakuragiftkey_Cfg = {}
  51. for k,v in pairs(Config.Sakuragiftkey) do
  52. self.Sakuragiftkey_Cfg[v.suit] = self.Sakuragiftkey_Cfg[v.suit] or {}
  53. self.Sakuragiftkey_Cfg[v.suit][Trim(v.key)] = v
  54. end
  55. end
  56. --获取套装id
  57. function SakuraGiftModel:GetSuitIdBySubType( sub_type )
  58. local suit_id = 0
  59. local act_list = CustomActivityModel:getInstance():getActList(self.base_type, sub_type)
  60. if act_list and act_list.condition_list then
  61. for k,v in ipairs(act_list.condition_list) do
  62. if v[1] == "suit" then
  63. suit_id = v[2]
  64. break
  65. end
  66. end
  67. end
  68. if suit_id == 0 then
  69. --找不到条件的话就取最小值
  70. suit_id = 99999
  71. for k,v in pairs(Config.Sakuragiftkey) do
  72. suit_id = suit_id > v.suit and v.suit or suit_id
  73. end
  74. end
  75. return tonumber(suit_id)
  76. end
  77. function SakuraGiftModel:GetShowModelData( sub_type )
  78. local act_list = CustomActivityModel:getInstance():getActList(self.base_type, sub_type)
  79. if act_list and act_list.condition_list then
  80. for k,v in ipairs(act_list.condition_list) do
  81. if v[1] == "show" then
  82. return v
  83. end
  84. end
  85. end
  86. end
  87. function SakuraGiftModel:GetActInfo( sub_type )
  88. return self.act_info[sub_type]
  89. end
  90. function SakuraGiftModel:SetActInfo( value )
  91. self.act_info[value.sub_type] = value
  92. if value.score then -- 更新积分
  93. self.shop_info[value.sub_type].score = value.score
  94. end
  95. end
  96. function SakuraGiftModel:GetShopInfo( sub_type )
  97. return self.shop_info[sub_type]
  98. end
  99. function SakuraGiftModel:SetShopInfo( value )
  100. self.shop_info[value.sub_type] = value
  101. if value.goods_list then
  102. local sort_func = function ( a, b )
  103. local conf_a = Config.Sakuragiftpointreward[a.reward_id]
  104. local conf_b = Config.Sakuragiftpointreward[b.reward_id]
  105. if conf_a and conf_b and conf_a.limit and conf_a.limit then
  106. local release_num_a = conf_a.limit - a.times
  107. local release_num_b = conf_b.limit - b.times
  108. if release_num_a == 0 and release_num_b ~= 0 then
  109. return false
  110. elseif release_num_b == 0 and release_num_a ~= 0 then
  111. return true
  112. else
  113. return a.reward_id < b.reward_id
  114. end
  115. end
  116. end
  117. table.sort(value.goods_list, sort_func)
  118. end
  119. end
  120. function SakuraGiftModel:RefreshShopOneInfo( data )
  121. local is_find = false
  122. if self.shop_info[data.sub_type] then
  123. self.shop_info[data.sub_type].score = data.score
  124. for k,v in pairs(self.shop_info[data.sub_type].goods_list) do
  125. if v.reward_id == data.reward_id then
  126. local conf = Config.Sakuragiftpointreward[v.reward_id]
  127. if conf.limit - data.times > 0 then -- 还有兑换次数就才直接刷数目
  128. v.times = data.times
  129. is_find = true
  130. end
  131. break
  132. end
  133. end
  134. end
  135. return is_find
  136. end
  137. --检测活动图标是否需要开启
  138. function SakuraGiftModel:CheckIconBoolOpen(sub_type)
  139. local base_type = self.base_type
  140. local sub_type = sub_type
  141. local level = RoleManager.Instance.mainRoleInfo.level
  142. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  143. local icon_sub_type = base_type*1000 + sub_type
  144. if sub_type >= 10001 then
  145. icon_sub_type = base_type*100000 + sub_type
  146. end
  147. if act_list and act_list.etime then
  148. local end_time = 0
  149. end_time = act_list.etime - TimeUtil:getServerTime()
  150. local open_lv = 0
  151. for k,v in pairs(act_list.condition_list) do
  152. if v[1] == "role_lv" then
  153. open_lv = tonumber(v[2])
  154. end
  155. end
  156. is_open = end_time > 0 and level >= open_lv
  157. if GetModuleIsOpen(331,base_type) then
  158. if end_time > 0 and is_open then
  159. self:SetDelayTimeList(sub_type) -- 活动结束前5小时红点
  160. ActivityIconManager:getInstance():addIcon(icon_sub_type, end_time)
  161. -- 检查一下活动期间首次登陆红点
  162. -- local list = self:GetFirstLoginCookie( )
  163. -- if not list[sub_type] or list[sub_type] ~= act_list.etime then -- 没缓存或缓存的不是这次活动
  164. -- self:SetFirstLoginRed( true ) -- 首次登陆
  165. -- end
  166. table.insert(self.sub_type_list, sub_type)
  167. else
  168. ActivityIconManager:getInstance():deleteIcon(icon_sub_type)
  169. end
  170. end
  171. else
  172. ActivityIconManager:getInstance():deleteIcon(icon_sub_type)
  173. end
  174. end
  175. --获取当前免费次数
  176. function SakuraGiftModel:GetFreeTime( sub_type )
  177. local free_num = 0
  178. local act_info = self:GetActInfo( sub_type )
  179. if act_info then
  180. local use_time = act_info.use_free_times
  181. local max_free = self:GetKeyValueConf( self:GetSuitIdBySubType(sub_type), "free_time" )
  182. free_num = max_free - use_time
  183. free_num = free_num > 0 and free_num or 0
  184. end
  185. return free_num
  186. end
  187. -- 获取展示在主界面的奖励数据
  188. -- 奖励物品展示去奖池奖励,极品奖励取2个,珍稀奖励取4个,普通奖励取4个
  189. -- 同奖池内根据奖励ID取数字小的,如数量不足,则极品奖励取珍稀奖励补充,珍稀奖励取普通奖励补充
  190. -- tag--标签 2-极品 1-珍稀 0-普通
  191. function SakuraGiftModel:GetMainShowRewardList( sub_type )
  192. local show_list = {}
  193. local temp_list = {}
  194. if not sub_type then return show_list end
  195. if self.main_show_list and self.main_show_list[sub_type] then -- 拿过了就拿缓存
  196. return self.main_show_list[sub_type]
  197. end
  198. -- 先数据处理
  199. for k,v in pairs(Config.Sakuragiftreward) do
  200. if v.act_id == sub_type then
  201. temp_list[v.tag] = temp_list[v.tag] or {}
  202. table.insert( temp_list[v.tag], v)
  203. end
  204. end
  205. -- 同奖池内根据奖励ID取数字小的
  206. local function sort_call( a,b )
  207. return a.id < b.id
  208. end
  209. for k,v in pairs(temp_list) do
  210. table.sort( v, sort_call )
  211. end
  212. -- 开始拿展示的数据
  213. for i=1, 10 do
  214. if i >= 1 and i <= 2 then -- 两个极品
  215. start_tag = 2
  216. elseif i >= 3 and i <= 6 then -- 四个珍稀
  217. start_tag = 1
  218. else
  219. start_tag = 0
  220. end
  221. for tag=start_tag, 0, -1 do
  222. if temp_list[tag] then
  223. for ii, v in ipairs(temp_list[tag]) do
  224. show_list[i] = table.remove(temp_list[tag], ii)
  225. break
  226. end
  227. end
  228. if show_list[i] then
  229. break
  230. end
  231. end
  232. -- 遍历完都没有奖励 奖励数量都不够10个 撤退
  233. if not show_list[i] then
  234. break
  235. end
  236. end
  237. self.main_show_list = self.main_show_list or {}
  238. self.main_show_list[sub_type] = show_list
  239. return show_list
  240. end
  241. -- 获取奖励展示里面
  242. -- TIPS: main_show_list2 是奖励详情里展示的 main_show_list 是主界面展示的
  243. function SakuraGiftModel:GetAwardListBySubtype( sub_type )
  244. local show_list = {}
  245. local temp_list = {}
  246. if not sub_type then return show_list end
  247. if self.main_show_list2 and self.main_show_list2[sub_type] then -- 拿过了就拿缓存
  248. -- for k,v in ipairs(self.main_show_list2[sub_type]) do
  249. -- table.insert(show_list, stringtotable(v.awards)[1])
  250. -- end
  251. -- return show_list
  252. for k,v in pairs(self.main_show_list2[sub_type]) do
  253. for ii,vv in ipairs(v) do
  254. show_list[k] = show_list[k] or {}
  255. table.insert(show_list[k], stringtotable(vv.awards)[1])
  256. end
  257. end
  258. return show_list
  259. end
  260. for k,v in pairs(Config.Sakuragiftreward) do
  261. if v.act_id == sub_type then
  262. -- table.insert(temp_list, v)
  263. temp_list[v.tag] = temp_list[v.tag] or {}
  264. table.insert(temp_list[v.tag], v)
  265. end
  266. end
  267. -- 同奖池内根据奖励ID取数字小的
  268. local function sort_call( a,b )
  269. return a.id < b.id
  270. end
  271. for k,v in pairs(temp_list) do
  272. table.sort( v, sort_call )
  273. end
  274. -- local sort_func = function ( a, b )
  275. -- if a.tag == b.tag then
  276. -- return a.tag > b.tag
  277. -- else
  278. -- return a.id < b.id
  279. -- end
  280. -- end
  281. -- table.sort(temp_list, sort_func)
  282. self.main_show_list2 = self.main_show_list2 or {}
  283. self.main_show_list2[sub_type] = temp_list
  284. for k,v in pairs(self.main_show_list2[sub_type]) do
  285. for ii,vv in ipairs(v) do
  286. show_list[k] = show_list[k] or {}
  287. table.insert(show_list[k], stringtotable(vv.awards)[1])
  288. end
  289. end
  290. return show_list
  291. end
  292. -- tag 1珍稀 2极品
  293. function SakuraGiftModel:GetTagByItemId(item_id )
  294. if not self.tag_item_id_cache then
  295. self.tag_item_id_cache = {}
  296. for k,v in pairs(Config.Sakuragiftreward) do
  297. if v.tag ~= 0 then
  298. self.tag_item_id_cache[v.tag] = self.tag_item_id_cache[v.tag] or {}
  299. local awards = stringtotable(v.awards)
  300. self.tag_item_id_cache[v.tag][tonumber(awards[1][2])] = true
  301. end
  302. end
  303. end
  304. local item_id = tonumber(item_id)
  305. if self.tag_item_id_cache[1][item_id] then
  306. return 27
  307. elseif self.tag_item_id_cache[2][item_id] then
  308. return 28
  309. end
  310. end
  311. -- 展示获得界面 33401
  312. function SakuraGiftModel:ShowGetRewardView( scmd_reward_list )
  313. local temp_list = {}
  314. for i,v in ipairs(scmd_reward_list) do
  315. local state = self:GetTagByItemId(v.reward_id)
  316. temp_list[#temp_list + 1] = {100, v.reward_id, v.num, state}
  317. end
  318. if #temp_list > 0 then
  319. GiftModel:getInstance():Fire(GiftModel.OPEN_SHOW_ACT_GOODS_VIEW, temp_list)
  320. end
  321. end
  322. ----------红点-start---------
  323. function SakuraGiftModel:GoodsChangeCheck( )
  324. if #self.sub_type_list > 0 then
  325. for k,v in pairs(self.sub_type_list) do
  326. self:CheckRedByType(SakuraGiftModelRedType.CanGo, v)
  327. end
  328. end
  329. end
  330. function SakuraGiftModel:CheckSakuraGiftMainRedDot( sub_type )
  331. local base_type = CustomActivityModel.CustomActBaseType.SAKURA_GIFT
  332. if not sub_type then return end
  333. local icon_sub_type = base_type*1000 + sub_type
  334. if sub_type >= 10001 then
  335. icon_sub_type = base_type*100000 + sub_type
  336. end
  337. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  338. if not act_list then
  339. return
  340. else
  341. local bool = self:GetAllRed( sub_type )
  342. GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, icon_sub_type, bool)
  343. end
  344. end
  345. -- 这个拿红点会顺便刷一遍红点缓存
  346. function SakuraGiftModel:CheckAllRed( sub_type )
  347. local bool1 = self:CheckLoginRed(sub_type) -- 首次登陆红点
  348. local bool2 = self:CheckExchangeRed(sub_type) -- 最后5小时可兑换红点
  349. local bool3 = self:CheckCanGoRed(sub_type) -- 抽奖红点
  350. local bool4 = self:CheckLoginExchangeRed(sub_type) -- 首次登陆兑换红点
  351. self:CheckSakuraGiftMainRedDot( sub_type ) -- 刷新一下总按钮红点
  352. return bool1 or bool2 or bool3 or bool4
  353. end
  354. -- 这个是拿总红点缓存 不会刷新的
  355. function SakuraGiftModel:GetAllRed( sub_type )
  356. local bool1 = self:GetLoginRed(sub_type) -- 首次登陆红点
  357. local bool2 = self:GetExchangeRed(sub_type) -- 最后5小时可兑换红点
  358. local bool3 = self:GetCanGoRed(sub_type) -- 抽奖红点
  359. local bool4 = self:GetLoginExchangeRed(sub_type) -- 首次登陆兑换红点
  360. return bool1 or bool2 or bool3 or bool4
  361. end
  362. -- 根据红点类型单个更新红点缓存
  363. function SakuraGiftModel:CheckRedByType(red_type, sub_type)
  364. local bool
  365. if red_type == SakuraGiftModelRedType.Login then
  366. bool = self:CheckLoginRed(sub_type)
  367. elseif red_type == SakuraGiftModelRedType.Exchange then
  368. bool = self:CheckExchangeRed(sub_type)
  369. elseif red_type == SakuraGiftModelRedType.CanGo then
  370. bool = self:CheckCanGoRed(sub_type)
  371. elseif red_type == SakuraGiftModelRedType.LoginExchange then
  372. bool = self:CheckLoginExchangeRed(sub_type)
  373. end
  374. self:CheckSakuraGiftMainRedDot( sub_type ) -- 刷新一下总按钮红点
  375. self:Fire(SakuraGiftModel.REFRESH_ACT_INFO)
  376. return bool
  377. end
  378. ----------------------------------------------
  379. -- 抽奖红点 (有免费次数 或 有道具)
  380. function SakuraGiftModel:CheckCanGoRed( sub_type )
  381. local suit_id = self:GetSuitIdBySubType(sub_type)
  382. local conf = stringtotable(self:GetKeyValueConf( suit_id, "pray_one" ))[1]
  383. local good_num = GoodsModel:getInstance():GetTypeGoodsNum(conf[2])
  384. self.can_go_red[sub_type] = good_num > 0 or self:GetFreeTime( sub_type ) > 0
  385. return self.can_go_red[sub_type] == true
  386. end
  387. function SakuraGiftModel:GetCanGoRed( sub_type )
  388. return self.can_go_red[sub_type]
  389. end
  390. -------------------------------------------------
  391. -- 检查是否有可以兑换的物品
  392. function SakuraGiftModel:CheckCanExchange( sub_type )
  393. local shop_info = self:GetShopInfo( sub_type )
  394. if not shop_info then return end
  395. local score = shop_info.score
  396. if not score or score == 0 then
  397. return false
  398. end
  399. for k,v in pairs(shop_info.goods_list) do
  400. local conf = Config.Sakuragiftpointreward[v.reward_id]
  401. if conf.limit - v.times > 0 and score >= conf.points then
  402. return true
  403. end
  404. end
  405. return false
  406. end
  407. -- 检查兑换红点
  408. function SakuraGiftModel:CheckExchangeRed( sub_type )
  409. local bool = false
  410. local base_type = self.base_type
  411. local sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(base_type)
  412. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  413. local is_last_day = false
  414. if act_list and act_list.etime then
  415. local end_time = 0
  416. end_time = act_list.etime - TimeUtil:getServerTime()
  417. if end_time > 0 and end_time <= NeedCheckExchangeRedTime then -- 剩余5小时
  418. is_last_day = true
  419. else
  420. return false
  421. end
  422. end
  423. self.exchange_red[sub_type] = is_last_day and self:CheckCanExchange(sub_type)
  424. return self.exchange_red[sub_type]
  425. end
  426. function SakuraGiftModel:GetExchangeRed( sub_type )
  427. return self.exchange_red[sub_type] == true
  428. end
  429. --------------------------------------------------
  430. -- 当前有可以兑换道具首次登陆时给红点
  431. function SakuraGiftModel:CheckLoginExchangeRed( sub_type )
  432. local list = self:GetLoginExchangeCookie() or {}
  433. if list[sub_type] == true then
  434. self.login_exchange_red[sub_type] = false
  435. else
  436. self.login_exchange_red[sub_type] = self:CheckCanExchange(sub_type)
  437. end
  438. return self.login_exchange_red[sub_type]
  439. end
  440. function SakuraGiftModel:GetLoginExchangeRed( sub_type )
  441. return self.login_exchange_red[sub_type]
  442. end
  443. function SakuraGiftModel:SetLoginExchangeRed( sub_type, bool )
  444. if self.login_exchange_red[sub_type] and bool == false then
  445. self.login_exchange_red[sub_type] = false
  446. self:SetLoginExchangeCookie( sub_type, true ) -- 今天点开过了
  447. self:CheckRedByType(SakuraGiftModelRedType.LoginExchange, sub_type)
  448. end
  449. end
  450. -- 每天首次登陆兑换红点cookie
  451. function SakuraGiftModel:SetLoginExchangeCookie( sub_type, bool )
  452. local list = self:GetLoginExchangeCookie() or {}
  453. list[sub_type] = bool
  454. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,
  455. CookieTimeType.TYPE_DAY2, CookieKey.SAKURA_GIFT_FIRST_EXCHANGE_RED, list)
  456. CookieWrapper.Instance:WriteAll()
  457. end
  458. --每天首次登陆兑换红点cookie
  459. function SakuraGiftModel:GetLoginExchangeCookie( )
  460. local list = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,
  461. CookieKey.SAKURA_GIFT_FIRST_EXCHANGE_RED) or {}
  462. return list
  463. end
  464. ---------------------------------------
  465. -- 每天首次登陆红点cookie
  466. function SakuraGiftModel:SetLoginCookie( sub_type, bool )
  467. local list = self:GetLoginCookie() or {}
  468. list[sub_type] = bool
  469. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,
  470. CookieTimeType.TYPE_DAY2, CookieKey.SAKURA_GIFT_FIRST_LOGIN_RED, list)
  471. CookieWrapper.Instance:WriteAll()
  472. end
  473. --每天首次登陆红点cookie
  474. function SakuraGiftModel:GetLoginCookie( )
  475. local list = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,
  476. CookieKey.SAKURA_GIFT_FIRST_LOGIN_RED) or {}
  477. return list
  478. end
  479. -- 当前有可以兑换道具首次登陆时给红点
  480. function SakuraGiftModel:CheckLoginRed( sub_type )
  481. local list = self:GetLoginCookie() or {}
  482. if list[sub_type] == true then
  483. self.login_red[sub_type] = false
  484. else
  485. self.login_red[sub_type] = true
  486. end
  487. return self.login_red[sub_type]
  488. end
  489. function SakuraGiftModel:GetLoginRed( sub_type )
  490. return self.login_red[sub_type]
  491. end
  492. function SakuraGiftModel:SetLoginRed( sub_type, bool )
  493. if self.login_red[sub_type] and bool == false then
  494. self.login_red[sub_type] = false
  495. self:SetLoginCookie( sub_type, true ) -- 今天点开过了
  496. self:CheckRedByType(SakuraGiftModelRedType.Login, sub_type)
  497. end
  498. end
  499. ------------------------------------------------------
  500. --[[-- 活动期间首次登陆指引红点cookie
  501. function SakuraGiftModel:SetFirstLoginCookie( sub_type, time )
  502. local list = self:GetFirstLoginCookie() or {}
  503. list[sub_type] = time
  504. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,
  505. CookieTimeType.TYPE_ALWAYS, CookieKey.SAKURA_GIFT_FIRST_LOGIN_RED,list)
  506. CookieWrapper.Instance:WriteAll()
  507. end
  508. --活动期间首次登陆指引红点
  509. function SakuraGiftModel:GetFirstLoginCookie( )
  510. local list = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,
  511. CookieKey.SAKURA_GIFT_FIRST_LOGIN_RED) or {}
  512. return list
  513. end
  514. -- 活动期间首次登陆指引红点
  515. function SakuraGiftModel:SetFirstLoginRed( sub_type, bool )
  516. self.first_login_red = self.first_login_red or {}
  517. self.first_login_red[sub_type] = bool
  518. if bool == false then
  519. local base_type = self.base_type
  520. local sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(base_type)
  521. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  522. local is_last_day = false
  523. if act_list and act_list.etime then
  524. self:SetFirstLoginCookie( sub_type, act_list.etime )
  525. end
  526. end
  527. end
  528. function SakuraGiftModel:GetFirstLoginRed( sub_type )
  529. return self.first_login_red[sub_type]
  530. end--]]
  531. ----------红点-end-----------
  532. ----------界面内跑马传闻-start---------
  533. function SakuraGiftModel:InitMessage( )
  534. self.chuan_wen_info = {}
  535. end
  536. function SakuraGiftModel:AppendNoticeMsg( str )
  537. self.chuan_wen_info[#self.chuan_wen_info + 1] = str
  538. end
  539. function SakuraGiftModel:GetChuanwenInfo( )
  540. return self.chuan_wen_info or {}
  541. end
  542. ----------界面内跑马传闻-end-----------
  543. function SakuraGiftModel:SetDelayTimeList( sub_type )
  544. if self.time_id_list[sub_type] then
  545. GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
  546. self.time_id_list[sub_type] = nil
  547. end
  548. local base_type = CustomActivityModel.CustomActBaseType.SAKURA_GIFT
  549. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type) or {}
  550. if not act_list then return end
  551. local end_time = act_list.etime
  552. local haly_hour = NeedCheckExchangeRedTime
  553. local sec = end_time - TimeUtil:getServerTime()
  554. if sec > 0 then
  555. local function onTimer()
  556. sec = end_time - TimeUtil:getServerTime()
  557. if sec <= haly_hour then--五小时有可以兑换的要给予红点且所有奖励有未购买完的
  558. if self.time_id_list[sub_type] then
  559. GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
  560. self.time_id_list[sub_type] = nil
  561. end
  562. self:CheckRedByType(SakuraGiftModelRedType.Exchange, sub_type)
  563. if self.time_id_list[sub_type] then
  564. GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
  565. self.time_id_list[sub_type] = nil
  566. end
  567. end
  568. end
  569. if not self.time_id_list[sub_type] then
  570. self.time_id_list[sub_type] = GlobalTimerQuest:AddPeriodQuest(onTimer, 10, -1)
  571. end
  572. onTimer()
  573. end
  574. end