源战役客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1775 řádky
67 KiB

před 1 měsícem
  1. DailyModel = DailyModel or BaseClass(BaseModel)
  2. local table_insert = table.insert
  3. local stringtotable = stringtotable
  4. local tonumber = tonumber
  5. DailyModel.OPEN_DAILY_BASE_VIEW = "DailyModel.OPEN_DAILY_BASE_VIEW"--打开日常界面
  6. DailyModel.CLOSE_DAILY_BASE_VIEW = "DailyModel.CLOSE_DAILY_BASE_VIEW"--打开日常界面
  7. DailyModel.OPEN_ALL_ACTIVITY_VIEW = "DailyModel.OPEN_ALL_ACTIVITY_VIEW"--打开活动日历界面
  8. DailyModel.OPEN_DAILY_COMMON_TIP_VIEW = "DailyModel.OPEN_DAILY_COMMON_TIP_VIEW"
  9. DailyModel.OPEN_RECOVERY_ALL_TIP = "DailyModel.OPEN_RECOVERY_ALL_TIP"-- 一键找回Tip
  10. DailyModel.OPEN_RECOVERY_ONE_TIP = "DailyModel.OPEN_RECOVERY_ONE_TIP"-- 找回Tip
  11. DailyModel.OPEN_HOSTING_RECORD_VIEW = "DailyModel.OPEN_HOSTING_RECORD_VIEW"-- 托管记录
  12. DailyModel.OPEN_HOSTING_REWARD_VIEW = "DailyModel.OPEN_HOSTING_REWARD_VIEW"-- 托管奖励
  13. DailyModel.HOSTING_SETTING_INFO = "DailyModel.HOSTING_SETTING_INFO"-- 托管信息
  14. DailyModel.HOSTING_SETTING_UPDATE = "DailyModel.HOSTING_SETTING_UPDATE"-- 托管设置更新
  15. DailyModel.HOSTING_RECORE_UPDATE = "DailyModel.HOSTING_RECORE_UPDATE"-- 托管记录
  16. DailyModel.OPEN_UP_SUCCESS_VIEW = "DailyModel.OPEN_UP_SUCCESS_VIEW"--学位升级成功界面
  17. DailyModel.CHANGE_RECOVERY_TYPE = "DailyModel.CHANGE_RECOVERY_TYPE"--广播更改资源找回类型
  18. DailyModel.CHECK_DAILY_RED_DOT = "DailyModel.CHECK_DAILY_RED_DOT"--广播红点
  19. DailyModel.REQUEST_CCMD_EVENT = "DailyModel.REQUEST_CCMD_EVENT"
  20. DailyModel.ANS_DAILY_BASE = "DailyModel.ANS_DAILY_BASE"--基础信息返回
  21. DailyModel.ANS_ACTIVITY_OPEN_STATUS = "DailyModel.ANS_ACTIVITY_OPEN_STATUS"--单独查询活动状态
  22. DailyModel.ANS_LIVENESS_INFO = "DailyModel.ANS_LIVENESS_INFO"--查询活跃度信息
  23. DailyModel.ANS_LIVENESS_FIGURE_INFO = "DailyModel.ANS_LIVENESS_FIGURE_INFO"--查询活跃度形象信息
  24. DailyModel.ANS_RECOVERY_LIST = "DailyModel.ANS_RECOVERY_LIST"--资源找回界面信息
  25. DailyModel.ANS_RECOVERY = "DailyModel.ANS_RECOVERY"--资源找回
  26. DailyModel.OPEN_DAILY_ORDER_REWARD_VIEW = "DailyModel.OPEN_DAILY_ORDER_REWARD_VIEW"--日常预约界面
  27. DailyModel.UPDATE_DAILY_ORDER_ALL_DATA = "DailyModel.UPDATE_DAILY_ORDER_ALL_DATA"--刷新日常预约所有数据
  28. DailyModel.UPDATE_DAILY_ORDER_TARGET_DATA = "DailyModel.UPDATE_DAILY_ORDER_TARGET_DATA"--刷新日常预约个别数据
  29. DailyViewType = {
  30. Recovery = 419,--找回
  31. Common = 2,--日常
  32. Activity = 3,--今日活动
  33. ActivityAll = 4,--活动日历
  34. HostingSetting = 1,--托管设置
  35. Achieve = 5, -- 成就
  36. }
  37. DailyActivityType = {
  38. UnLimit = 1, --非限时
  39. Limit = 2, --限时
  40. }
  41. ActivityState = {
  42. Opening = 1, --开启中
  43. Today = 2, --今日开启
  44. Unopened = 3, --未开启
  45. LvLimit = 4, --等级不足
  46. Closed = 5, --已关闭
  47. }
  48. TodayType = {
  49. Yes = 1,
  50. No = 2,
  51. }
  52. ActiveTimeType = {
  53. StartTime = 1,
  54. EndTime = 2,
  55. }
  56. TimeType = {
  57. None = 0,
  58. Week = 1,
  59. Month = 2,
  60. Date = 3,
  61. }
  62. --开合服类型
  63. ServerTimeType = {
  64. MergeDay = 1, --合服
  65. OpenDay = 2, --开服
  66. Normal = 3, --正常
  67. }
  68. --日常预约状态
  69. DailyOrderStatus =
  70. {
  71. UN_ORDER = 0,
  72. UN_JOIN = 1,
  73. UN_GET = 2,
  74. DONE = 3,
  75. }
  76. function DailyModel:__init()
  77. DailyModel.Instance = self
  78. self:ResetData( )
  79. end
  80. function DailyModel:getInstance()
  81. if DailyModel.Instance == nil then
  82. DailyModel.New()
  83. end
  84. return DailyModel.Instance
  85. end
  86. function DailyModel:GetInstance()
  87. return DailyModel:getInstance()
  88. end
  89. function DailyModel:ResetData( )
  90. self.parse_cache_list = nil
  91. self.resact_list = nil
  92. self.daily_base_info = nil--基础信息,日常界面item列表信息
  93. self.ac_open_status = nil--活动的开启状态
  94. self.liveness_info = nil--活跃度信息
  95. self.liveness_figure_info = nil--玩家活跃度形象
  96. self.resource_recovery_list = {}--找回信息
  97. -------------------------
  98. self.red_today_reward = {}--今日活跃奖励
  99. self.red_liveness_up = false--今日活跃度升级
  100. self.mask_recover_red = false--一次性的找回红点
  101. self.hosting_time_cfg = false --托管设置配置
  102. self.hosting_time_string_list = false --托管设置时间字符串缓存
  103. self.hosting_time_day_list = false --托管设置开放日期缓存
  104. self.hosting_info = {} --托管信息
  105. self.hosting_is_request_record = false --托管奖励请求
  106. self.hosting_red_dot = false --托管红点
  107. self.daily_order_info = {} --日常预约数据
  108. self.daily_order_red_dot = false --日常预约红点
  109. end
  110. --解析配置
  111. function DailyModel:GetParseList(key)
  112. if self.parse_cache_list == nil then
  113. self.parse_cache_list = {}
  114. end
  115. local cache_vo = self.parse_cache_list[key]
  116. if cache_vo then
  117. return cache_vo
  118. else
  119. cache_vo = ErlangParser:GetInstance():Parse(key)
  120. self.parse_cache_list[key] = cache_vo
  121. return cache_vo
  122. end
  123. end
  124. --获得活动日历配置
  125. function DailyModel:GetAcConfig(_module, module_sub, ac_sub)
  126. local str = _module .. "@" .. module_sub .. "@" .. ac_sub
  127. return Config.Ac[str]
  128. end
  129. --获得配置表里开合服对应的天数
  130. function DailyModel:GetOpenOrMergeDayByCfg(dayList, day)
  131. local dayData
  132. for i, v in ipairs(dayList) do
  133. local startDay = tonumber(v[1])
  134. local endDay = tonumber(v[2])
  135. if day <= startDay or (day > startDay and day <= endDay) then
  136. dayData = v
  137. break
  138. end
  139. end
  140. return dayData
  141. end
  142. --[[
  143. *
  144. * @param module_id ID
  145. * @param module_sub_id ID
  146. ]]
  147. function DailyModel:GetActLivenessConfig(module_id, module_sub_id)
  148. return Config.Activityliveness[module_id.."@"..module_sub_id]
  149. end
  150. --[[
  151. *
  152. * @param id Id
  153. ]]
  154. function DailyModel:GetLivenessActiveConfig(id)
  155. if not self.conf_liveness_active then
  156. self.conf_liveness_active = {}
  157. for k,v in pairs(DailyConst.Livenessactive) do
  158. local have = false
  159. for a,b in pairs(Config.Livenesslv) do
  160. if b.figure == v.figure_id then
  161. have = true
  162. break
  163. end
  164. end
  165. if have then
  166. self.conf_liveness_active[#self.conf_liveness_active+1] = DeepCopy(v)
  167. end
  168. end
  169. -------------------------
  170. for k,v in pairs(self.conf_liveness_active) do
  171. v.lv = 999
  172. for a,b in pairs(Config.Livenesslv) do
  173. if b.figure == v.figure_id then
  174. v.lv = v.lv < b.lv and v.lv or b.lv
  175. end
  176. end
  177. end
  178. local function sort_call( a,b )
  179. return a.lv < b.lv
  180. end
  181. table.sort( self.conf_liveness_active, sort_call )
  182. end
  183. if id then
  184. return self.conf_liveness_active[id]
  185. else
  186. return self.conf_liveness_active
  187. end
  188. end
  189. --[[
  190. *
  191. * @param level
  192. ]]
  193. function DailyModel:GetLivenessLvConfig(level)
  194. if not level then return end
  195. for k,v in pairs(Config.Livenesslv) do
  196. if v.lv == level then
  197. return v
  198. end
  199. end
  200. end
  201. --[[
  202. *
  203. * @param act_id id
  204. * @param act_sub
  205. ]]
  206. function DailyModel:GetResactConfig(act_id, act_sub)
  207. local type = Config.Resacttype[act_id .. "@" .. act_sub] and Config.Resacttype[act_id .. "@" .. act_sub].type or 1
  208. local cur_key = act_id .. "@" .. act_sub
  209. if not self.resact_list then
  210. self.resact_list = {}
  211. for _,v in pairs(Config.Resact) do
  212. local key = v.act_id.."@"..v.act_sub
  213. local list = self.resact_list[key]
  214. if not list then
  215. list = {}
  216. self.resact_list[key] = list
  217. end
  218. table_insert(list,v)
  219. end
  220. end
  221. local cur_list = self.resact_list[cur_key]
  222. local cfg = nil
  223. if cur_list then
  224. local role_lv = RoleManager.Instance:GetMainRoleLevel2()
  225. local world_lv = RoleManager.Instance:GetMainRoleVo().worldLv
  226. for _,v in pairs(cur_list) do
  227. if type == 1 then --玩家等级
  228. if role_lv >= v.level and role_lv <= v.level_max then
  229. cfg = v
  230. break
  231. end
  232. elseif type == 2 then --世界等级
  233. if world_lv >= v.server_min_lv and world_lv <= v.server_max_lv then
  234. cfg = v
  235. break
  236. end
  237. end
  238. end
  239. end
  240. return cfg
  241. end
  242. --获取找回活动经验配置系数
  243. function DailyModel:GetBackAwardPer( act_id, act_sub )
  244. local lv = RoleManager.Instance.mainRoleInfo.level
  245. for k,v in pairs(Config.Awardexp) do
  246. if v.mid == act_id and v.sid == act_sub then
  247. if lv >= v.lv_min and lv <= v.lv_max then
  248. return v.extra/10000
  249. end
  250. end
  251. end
  252. return 0
  253. end
  254. --获取活动开始时间的秒数和开始等级
  255. function DailyModel:GetActivityStartSecAndStartLv(vo, now_time)
  256. local time = os.date("*t", now_time)
  257. local now_sec = time.hour * 3600 + time.min * 60
  258. local start_second, end_second, now_second = 0, 0, 0
  259. local start_lv = 0
  260. local state = ActivityState.Unopened
  261. local ac_cfg = self:GetAcConfig(vo.module, vo.module_sub, vo.ac_sub)
  262. local temp_start_second, temp_end_second, temp_now_second = 0, 0, 0
  263. if ac_cfg then
  264. local active_time_list = self:GetParseList(ac_cfg.time_region)
  265. table.sort(active_time_list, function (a, b)
  266. return tonumber(a[1][1]) < tonumber(b[1][1])
  267. end)
  268. for i, v in ipairs(active_time_list) do
  269. local start_hour = v[ActiveTimeType.StartTime][1]
  270. local start_min = v[ActiveTimeType.StartTime][2]
  271. local end_hour = v[ActiveTimeType.EndTime][1]
  272. local end_min = v[ActiveTimeType.EndTime][2]
  273. local activity_start_sec = start_hour * 3600 + start_min * 60
  274. local activity_end_sec = end_hour * 3600 + end_min * 60
  275. start_second = activity_start_sec
  276. end_second = activity_end_sec
  277. now_second = now_sec
  278. if now_sec < activity_start_sec then
  279. state = ActivityState.Unopened
  280. break
  281. elseif now_sec >= activity_end_sec then
  282. state = ActivityState.Closed
  283. else
  284. state = ActivityState.Opening
  285. break
  286. end
  287. end
  288. start_lv = ac_cfg.start_lv
  289. end
  290. local isToday = self:EstimateActivityIsToday(vo, now_time)
  291. if isToday == TodayType.No then
  292. state = ActivityState.Unopened
  293. elseif isToday and state ~= ActivityState.Closed then
  294. state = ActivityState.Today
  295. end
  296. return start_second, start_lv, state, end_second, now_second
  297. end
  298. --判断活动是否是今天开启
  299. function DailyModel:EstimateActivityIsToday(vo, time)
  300. local result = TodayType.No
  301. local nowDate = os.date("*t", time)
  302. local weekday = tonumber(os.date("%w", time))--0-6 = Sunday-Saturday
  303. if weekday == 0 then
  304. weekday = 7
  305. end
  306. local ac_cfg = self:GetAcConfig(vo.module, vo.module_sub, vo.ac_sub)
  307. if ac_cfg then
  308. local dateList = self:GetParseList(ac_cfg.time)
  309. local monthList = self:GetParseList(ac_cfg.month)
  310. local weekList = self:GetParseList(ac_cfg.week)
  311. local openDayList = self:GetParseList(ac_cfg.open_day)
  312. local mergeDayList = self:GetParseList(ac_cfg.merge_day)
  313. local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
  314. local mergeDay = ServerTimeModel:getInstance():GetMergeServerDay()
  315. local isToday = false
  316. if mergeDay > 0 and #mergeDayList > 0 then
  317. local dayData = self:GetOpenOrMergeDayByCfg(mergeDayList, mergeDay)
  318. if dayData then
  319. local startDay = tonumber(dayData[1])
  320. local endDay = tonumber(dayData[2])
  321. if mergeDay >= startDay and mergeDay <= endDay then
  322. if endDay - startDay <= 7 then
  323. isToday = true
  324. else
  325. if #weekList > 0 then
  326. for i, v in ipairs(weekList) do
  327. if tonumber(v) == tonumber(weekday) then
  328. isToday = true
  329. break
  330. end
  331. end
  332. elseif #weekList == 0 then
  333. isToday = true
  334. end
  335. end
  336. end
  337. end
  338. elseif #openDayList > 0 then
  339. local dayData = self:GetOpenOrMergeDayByCfg(openDayList, openDay)
  340. if dayData then
  341. local startDay = tonumber(dayData[1])
  342. local endDay = tonumber(dayData[2])
  343. if openDay >= startDay and openDay <= endDay then
  344. if #weekList > 0 then
  345. for i, v in ipairs(weekList) do
  346. if tonumber(v) == tonumber(weekday) then
  347. isToday = true
  348. break
  349. end
  350. end
  351. elseif #weekList == 0 then
  352. isToday = true
  353. end
  354. end
  355. end
  356. elseif #weekList ~= 0 then
  357. for i, v in ipairs(weekList) do
  358. if tonumber(v) == tonumber(weekday) then
  359. isToday = true
  360. break
  361. end
  362. end
  363. elseif #monthList ~= 0 then
  364. for i, v in ipairs(monthList) do
  365. if nowDate.day == tonumber(v) then
  366. isToday = true
  367. break
  368. end
  369. end
  370. elseif #dateList ~= 0 then
  371. for i, v in ipairs(dateList) do
  372. if tonumber(v[1]) == nowDate.year and tonumber(v[2]) == nowDate.month and tonumber(v[3]) == nowDate.day then
  373. isToday = true
  374. break
  375. end
  376. end
  377. elseif #weekList == 0 and #monthList == 0 and #dateList == 0 then
  378. isToday = true
  379. end
  380. if isToday then
  381. result = TodayType.Yes
  382. else
  383. result = TodayType.No
  384. end
  385. end
  386. return result
  387. end
  388. --根据等级区间获得挂机配置 -- 1 为随机配置的一个点 2 为选中配置的点
  389. function DailyModel:GetOnhookConfig(type)
  390. type = type or 1
  391. if type == 2 then
  392. local level = RoleManager:getInstance():GetMainRoleVo().level
  393. local data
  394. for _, v in pairs(Config.Onhook) do
  395. --只有野外的才选择
  396. if level >= v.min_lv and level < v.max_lv and v.onhook_type == 0 then
  397. data = v
  398. break
  399. end
  400. end
  401. return data
  402. else
  403. local level = RoleManager:getInstance():GetMainRoleVo().level
  404. local min_lv,max_lv,scene_id
  405. for _, v in pairs(Config.Onhook) do
  406. --只有野外的才选择
  407. if level >= v.min_lv and level < v.max_lv and v.onhook_type == 0 then
  408. min_lv = v.min_lv
  409. max_lv = v.max_lv
  410. scene_id = v.scene_id
  411. break
  412. end
  413. end
  414. if min_lv then
  415. local list = {}
  416. for _, v in pairs(Config.Onhook) do
  417. --取配置表的前后 两条跟当前的一条数据
  418. if ((v.max_lv == min_lv) or (min_lv == v.min_lv and max_lv == v.max_lv) or (v.min_lv == max_lv)) and v.onhook_type == 0 and v.scene_id == scene_id then
  419. table_insert(list,v)
  420. end
  421. end
  422. if #list > 0 then
  423. local index = math.random(1,#list)
  424. return list[index]
  425. end
  426. end
  427. return false
  428. end
  429. end
  430. function DailyModel:GetCommonShowList( )
  431. -------------------------
  432. --有个需求,几个副本要合并到一起去显示,这时候要前端编一个假条目
  433. -------------------------
  434. local special_dungeon_list = {
  435. module = 610,
  436. module_sub = 9999,
  437. ac_sub = 1,
  438. num = 0,
  439. live = 0,
  440. state = 1,
  441. conf_data = DeepCopy(self:GetAcConfig(610, 1001, 1)),
  442. -------------------------
  443. max_times = 0,
  444. }
  445. special_dungeon_list.conf_data.ac_icon = 610999
  446. special_dungeon_list.conf_data.about = DailyConst.CommonDungeonDes or ""
  447. special_dungeon_list.conf_data.reward = {}
  448. special_dungeon_list.base_num = 0--统计一下有几个要计算基础的总数
  449. special_dungeon_list.base_success_num = 0--统计一下完成了几个计算基础
  450. special_dungeon_list.can_buy_num = 0--统计一下还可以买几次
  451. special_dungeon_list.have_buy_num = 0--统计一下已经买了几次
  452. -------------------------
  453. local data = {}
  454. local base_data = self:GetDailyBaseInfo( )
  455. if not base_data then return data end
  456. for i=1,2 do
  457. if base_data.ac_list[i] then
  458. for ii,vv in ipairs(base_data.ac_list[i]) do
  459. local temp_live_cfg = self:GetActLivenessConfig(vv.module, vv.module_sub)
  460. if temp_live_cfg and temp_live_cfg.hidden ~= 0 then
  461. --部分不需要显示啦
  462. else
  463. local str_id = vv.module .. "@" .. vv.module_sub .. "@" .. vv.ac_sub
  464. if DailyConst.CommonDungeonList[str_id] then
  465. if vv.state == 1 and GetModuleIsOpen(vv.module,vv.module_sub) then
  466. -------------------------
  467. --后端发来的次数包含了可购买的次数,那么这边需要减掉这些次数,而且沉底表现也用到了
  468. local left_can_buy_time,left_gold_can_buy_time = BaseDungeonModel:GetInstance():GetDunVipBuyLeftTimes(tonumber(vv.module_sub))
  469. -------------------------
  470. --如果是贵族,当天第二次打本是免费的,那么在通关次数小于二的时候,可购买次数就要减一
  471. local dungeon_type = BaseDungeonModel:GetInstance():GetDunTypeByDunId(tonumber(vv.module_sub))
  472. local dungeon_data = BaseDungeonModel:GetInstance():GetDunProtoInfoByDunId( dungeon_type,tonumber(vv.module_sub) )
  473. local today_pass_count = dungeon_data and (dungeon_data.day_pass_count + dungeon_data.vip_count) or 0
  474. if RoleManager.Instance.mainRoleInfo.sup_vip_type ~= 0 and today_pass_count <= 1 then
  475. left_can_buy_time = left_can_buy_time - 1
  476. end
  477. -------------------------
  478. --要在分母加一个已购买次数
  479. local max_buy_time = BaseDungeonModel:GetInstance():GetDunVipBuyMaxTimes( tonumber(vv.module_sub) )
  480. local have_buy_time = max_buy_time - left_can_buy_time
  481. local left_gold_can_buy_time = (left_gold_can_buy_time > have_buy_time ) and (left_gold_can_buy_time - have_buy_time) or 0--剩余的红钻购买次数
  482. special_dungeon_list.num = special_dungeon_list.num + vv.num--通关次数
  483. special_dungeon_list.live = special_dungeon_list.live + vv.live--活跃度
  484. special_dungeon_list.max_times = special_dungeon_list.max_times + vv.max_times - left_can_buy_time + left_gold_can_buy_time--最大次数(如果还有红钻购买次数,则加起来)
  485. special_dungeon_list.can_buy_num = special_dungeon_list.can_buy_num + left_can_buy_time--可买次数
  486. special_dungeon_list.have_buy_num = special_dungeon_list.have_buy_num + have_buy_time--已买次数
  487. local cur_base_num = DailyConst.CommonBaseTime[str_id]
  488. if cur_base_num then
  489. --额外购买次数的任务,基本次数之后,置底
  490. special_dungeon_list.base_num = special_dungeon_list.base_num + cur_base_num
  491. if vv.num >= cur_base_num then
  492. special_dungeon_list.base_success_num = special_dungeon_list.base_success_num + cur_base_num
  493. else
  494. special_dungeon_list.base_success_num = special_dungeon_list.base_success_num + vv.num
  495. end
  496. end
  497. if type(vv.conf_data.reward) == "string" then
  498. for k,v in pairs(stringtotable(vv.conf_data.reward)[1][2]) do
  499. local have = false
  500. for a,b in pairs(special_dungeon_list.conf_data.reward) do
  501. if b[1] == v[1] and b[2] == v[2] then
  502. have = true
  503. -- b[3] = b[3] + v[3]
  504. b[3] = 0
  505. end
  506. end
  507. if not have then
  508. table.insert( special_dungeon_list.conf_data.reward, v )
  509. end
  510. end
  511. end
  512. end
  513. elseif vv.module == 280 and vv.module_sub == 0 and DailyConst.CommonBaseTime[str_id] then
  514. --竞技场,要做购买次数的额外显示
  515. local conf_max_buy = PkRankModel:getInstance():GetVipCanBuyTime(RoleManager.Instance.mainRoleInfo.vip_flag)--配置的最大可购买次数
  516. local can_buy_num = PkRankModel:getInstance().times_info.can_buy_num
  517. -------------------------
  518. vv.base_num = DailyConst.CommonBaseTime[str_id]--统计一下有几个要计算基础的总数
  519. vv.base_success_num = math.min( vv.num , vv.base_num )--统计一下完成了几个计算基础
  520. vv.can_buy_num = PkRankModel:getInstance().times_info.can_buy_num
  521. vv.show_max_times = math.max(0, vv.max_times - can_buy_num)
  522. vv.have_buy_num = conf_max_buy - can_buy_num
  523. table.insert( data, vv )
  524. else
  525. --装备副本最大次数,读配置
  526. if vv.module == 215 and vv.module_sub == 1 then
  527. vv.max_times = DunManyModel:GetEquipDunMaxCount( )
  528. end
  529. table.insert( data, vv )
  530. end
  531. end
  532. end
  533. end
  534. end
  535. table.insert( data, 1, special_dungeon_list )
  536. -------------------------
  537. return data
  538. end
  539. ---------------------------------------------------------------------------------------------------------------
  540. --[[获得活动周历信息,返回数据结构:
  541. {
  542. {12:10~12:30,,{name = 1, module_id = xxx, module_sub = xxx},,,,,},
  543. {16:00~16:30,,,,,{name = 2, module_id = xxx, module_sub = xxx},,},
  544. ]]--
  545. --need_combine有的活动时间区间可以并入其它大时间区间,判断十分需要并入
  546. function DailyModel:GetWeekCalendarInfo(need_combine)
  547. --开服天数
  548. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  549. --合服天数
  550. local merge_day = ServerTimeModel:getInstance():GetMergeServerDay()
  551. local all_ac_list = {} --活动日历列表
  552. for _, v in pairs(Config.Ac) do
  553. if tonumber(v.ac_type) == DailyActivityType.Limit then
  554. local cfg = DeepCopy(v)
  555. cfg.week_day_list = stringtotable(cfg.week)
  556. cfg.time_region_info = stringtotable(cfg.time_region)
  557. -- cfg.start_time_info = cfg.time_region_info[1]
  558. cfg.start_time_info = cfg.time_region_info
  559. assert(cfg.start_time_info and cfg.start_time_info[1][1], "has no time region setting for limit activity in Config.Ac.lua!")
  560. -- cfg.start_time_info = cfg.start_time_info[1]
  561. cfg.open_day_list = stringtotable(cfg.open_day)
  562. cfg.merge_day_list = stringtotable(cfg.merge_day)
  563. table_insert(all_ac_list, cfg)
  564. end
  565. end
  566. --今天是星期几
  567. local cur_weekday = tonumber(os.date("%w", TimeUtil:getServerTime()))
  568. cur_weekday = cur_weekday ~= 0 and cur_weekday or 7
  569. -- 2020年6月20日新增,格式跟Config.ConfigDaily.WeekCalendarTime相同,代表活动的开始时间
  570. local event_time_list = self:GetAllAcEventTimeList(all_ac_list,need_combine)
  571. local cale_list = self:InitCalendarList(event_time_list, open_day, merge_day, cur_weekday)
  572. --遍历所有的限时活动
  573. for i,ac_cfg in ipairs(all_ac_list) do
  574. --周1至周日
  575. for week_day=1,7 do
  576. local is_week_day_ok = self:IsEmptyListOrDayInList(ac_cfg.week_day_list, week_day)
  577. --假设今天是周3,周1时的开服天数就是当前开服天数减2
  578. local open_day_for_show = open_day-(cur_weekday-week_day)
  579. local is_open_day_ok = self:IsEmptyListOrDayInList(ac_cfg.open_day_list, open_day_for_show)
  580. local merge_day_for_show = merge_day-(cur_weekday-week_day)
  581. -- 2020年7月24日修改:修复有合服开放情况的配置出现开放时间错误的问题
  582. -- local is_merge_day_ok = merge_day == 0 or self:IsEmptyListOrDayInList(ac_cfg.merge_day_list, merge_day_for_show)
  583. if merge_day == 0 then
  584. --都还没合服,就不用推算后面和之前的合服天数啦
  585. merge_day_for_show = 0
  586. end
  587. --合服天数的配置,[0,0]代表未合服,不填代表无合服天数限制
  588. local is_merge_day_ok = self:IsEmptyListOrDayInList(ac_cfg.merge_day_list, merge_day_for_show > 0 and merge_day_for_show or 0)
  589. if is_week_day_ok and is_open_day_ok and is_merge_day_ok then
  590. -- 开服天数和合服天数都满足就看开启时间段
  591. -- 2020年2月24日新增:对同一活动多时段情况的判断
  592. for k = 1, #ac_cfg.start_time_info do
  593. local time_section_index = self:GetTimeSectionIndex(event_time_list, ac_cfg.start_time_info[k][1])
  594. if time_section_index then
  595. cale_list[time_section_index] = cale_list[time_section_index] or {}
  596. if not cale_list[time_section_index][week_day+1] or cale_list[time_section_index][week_day+1]=="" then
  597. --week_day要加1是因为第1元素是存放时间段的如:12:00~12:30
  598. local ac_table = {
  599. name = Trim(ac_cfg.ac_name),
  600. module_id = ac_cfg.module,
  601. module_sub = ac_cfg.module_sub,
  602. ac_sub = ac_cfg.ac_sub,
  603. }
  604. cale_list[time_section_index][week_day+1] = ac_table
  605. end
  606. end
  607. end
  608. end
  609. end
  610. end
  611. return cale_list, event_time_list
  612. end
  613. -- 2020年6月20日新增,计算获取活动的开始时间
  614. -- 格式为 {活动开始时间h, 活动开始时间m,活动结束时间h,活动结束时间m} h,m分别代表小时和分
  615. -- 例:{12, 0, 12, 20},
  616. function DailyModel:GetAllAcEventTimeList(ac_list, need_combine)
  617. local time_region
  618. -- 用来存放临时的开始时间和结束时间
  619. local temp_tb = {}
  620. local temp_key_tb = {}
  621. local event_time_list = {}
  622. local filter_key
  623. local have_key_list = need_combine and {}--如果要合并,用这个表方便处理记录
  624. for k, cfg in ipairs(ac_list) do
  625. filter_key = cfg.module .. cfg.module_sub
  626. if not Config.ConfigDaily.CalendarFilterAc[filter_key] then -- 如果是不打算显示在活动日历上的限时活动,需要添加相应的配置进行过滤
  627. time_region = stringtotable(cfg.time_region)
  628. for k2, v2 in ipairs(time_region) do
  629. -------------------------
  630. local need_mask = false
  631. if have_key_list then
  632. for index_have_key,data in pairs(have_key_list) do
  633. if (v2[1][1]*60+v2[1][2] >= data[1]*60+data[2]) and (v2[2][1]*60+v2[2][2] <= data[3]*60+data[4]) then
  634. --已经存在较大区间,那么本区间不需要增加
  635. need_mask = true
  636. break
  637. elseif (v2[1][1]*60+v2[1][2] <= data[1]*60+data[2]) and (v2[2][1]*60+v2[2][2] >= data[3]*60+data[4]) then
  638. --我比你大,要把你换掉!把现有区间删掉!
  639. local temp_time_key = data[1] .. "@" .. data[2] .. "@" .. data[3] .. "@" .. data[4]
  640. for temp_k,temp_v in pairs(temp_tb) do
  641. if temp_v.time_key == temp_time_key then
  642. table.remove(temp_tb,temp_k)--抹除旧记录,就当没事发生过
  643. table.remove(have_key_list,index_have_key)--抹除旧记录,就当没事发生过
  644. break
  645. end
  646. end
  647. temp_key_tb[temp_time_key] = nil
  648. break
  649. end
  650. end
  651. end
  652. -------------------------
  653. if not need_mask then
  654. local time_key = v2[1][1] .. "@" .. v2[1][2] .. "@" .. v2[2][1] .. "@" .. v2[2][2]
  655. if not temp_key_tb[time_key] then
  656. -- 使用活动时间组成键值之后,使用活动开始的时间计算分钟数作为排序sort_id
  657. temp_tb[#temp_tb + 1] = {time_key = time_key, sort_id = v2[1][1] * 60 + v2[1][2]}
  658. temp_key_tb[time_key] = true
  659. if have_key_list then
  660. table.insert( have_key_list, {v2[1][1], v2[1][2], v2[2][1], v2[2][2]} )
  661. end
  662. end
  663. end
  664. end
  665. end
  666. end
  667. -- 根据特殊键值排序
  668. local sort_func = function ( a, b )
  669. return a.sort_id < b.sort_id
  670. end
  671. table.sort(temp_tb, sort_func)
  672. -- 解析time_key,组成{12, 0, 12, 20}这样的格式
  673. local new_time_list
  674. for k, v in ipairs(temp_tb) do
  675. new_time_list = Split(v.time_key, "@")
  676. -- 处理成数字
  677. new_time_list[1] = tonumber(new_time_list[1])
  678. new_time_list[2] = tonumber(new_time_list[2])
  679. new_time_list[3] = tonumber(new_time_list[3])
  680. new_time_list[4] = tonumber(new_time_list[4])
  681. event_time_list[#event_time_list+1] = new_time_list
  682. end
  683. return event_time_list
  684. end
  685. function DailyModel:InitCalendarList( event_time_list, open_day, merge_day, cur_weekday )
  686. local cale_list = {}
  687. for i, v in ipairs(event_time_list) do --多少行
  688. cale_list[i] = cale_list[i] or {}
  689. local time_str = (v[1] .. ":" .. (v[2] < 10 and "0" .. v[2] or v[2]).."~"..v[3]..":"..(v[4] < 10 and "0" .. v[4] or v[4]))
  690. cale_list[i][1] = time_str
  691. for week_day=1,7 do
  692. local show_str = ""
  693. if merge_day > 0 and merge_day < 7 then
  694. local merge_day_for_show = merge_day-(cur_weekday-week_day)
  695. if merge_day_for_show <= 0 then
  696. show_str = "未合服"
  697. end
  698. elseif open_day < 7 then
  699. local open_day_for_show = open_day-(cur_weekday-week_day)
  700. if open_day_for_show <= 0 then
  701. show_str = "未开服"
  702. end
  703. end
  704. cale_list[i][week_day+1] = show_str
  705. end
  706. end
  707. return cale_list
  708. end
  709. function DailyModel:GetTimeSectionIndex( event_time_list, start_time_info )
  710. for i,v in ipairs(event_time_list) do
  711. local start_hour = start_time_info[1]
  712. local start_min = start_time_info[2]
  713. if v[1] == start_hour and v[2] == start_min then
  714. return i
  715. end
  716. end
  717. return nil
  718. end
  719. function DailyModel:IsEmptyListOrDayInList( list, day )
  720. if #list <= 0 then
  721. --列表为空时代表哪一天都可以
  722. return true
  723. end
  724. for i,v in ipairs(list) do
  725. if type(v) == "number" then
  726. --周列表的格式是{1,5,7}
  727. if v==day then
  728. return true
  729. end
  730. else
  731. --开服或合服列表格式是{{1,1},{5,9999}}
  732. local start_day = v[1]
  733. local end_day = v[2]
  734. if day >= start_day and day <= end_day then
  735. return true
  736. end
  737. end
  738. end
  739. return false
  740. end
  741. ---------------------------------------------------------------------------------------------------------------
  742. --获取活动奖励列表
  743. function DailyModel:GetRewardList(module,module_sub,ac_sub)
  744. local cfg_data = Config.Ac[module.."@"..module_sub.."@"..ac_sub]
  745. local rewardList = {}
  746. if not cfg_data then return rewardList end
  747. rewardList = stringtotable(cfg_data.reward)[1][2]
  748. return rewardList
  749. end
  750. -------------------------
  751. --活动活跃度基础信息
  752. function DailyModel:GetDailyBaseInfo( )
  753. return self.daily_base_info
  754. end
  755. function DailyModel:SetDailyBaseInfo( value )
  756. if not value then return end
  757. -------------------------
  758. for k,v in pairs(value.ac_list) do
  759. v.conf_data = self:GetAcConfig(v.module, v.module_sub, v.ac_sub)
  760. local liveness_conf = self:GetActLivenessConfig(v.module, v.module_sub)
  761. v.conf_max = liveness_conf and liveness_conf.conf_max or 0
  762. end
  763. -------------------------
  764. self.daily_base_info = self.daily_base_info or {}
  765. self.daily_base_info.time = value.time
  766. self.daily_base_info.power_live = value.power_live
  767. self.daily_base_info.collect_coin = value.coin
  768. self.daily_base_info.collect_honor = value.honor
  769. self.daily_base_info.ac_list = self.daily_base_info.ac_list or {}
  770. self.daily_base_info.ac_list[value.act_type] = value.ac_list
  771. end
  772. function DailyModel:GetOneDailyBaseInfo( module_id,module_sub,type_id )
  773. if not self.daily_base_info then return end
  774. if type_id then
  775. if self.daily_base_info.ac_list[type_id] then
  776. for k,v in pairs(self.daily_base_info.ac_list[type_id]) do
  777. if v.module == module_id and v.module_sub == module_sub then
  778. return v
  779. end
  780. end
  781. end
  782. else
  783. for i=1,2 do
  784. if self.daily_base_info.ac_list[i] then
  785. for k,v in pairs(self.daily_base_info.ac_list[i]) do
  786. if v.module == module_id and v.module_sub == module_sub then
  787. return v
  788. end
  789. end
  790. end
  791. end
  792. end
  793. end
  794. function DailyModel:RefreshOutLineHookTime( time )
  795. if (not self.daily_base_info) or (not time) then return end
  796. self.daily_base_info.time = time
  797. end
  798. -------------------------
  799. --查询活动状态
  800. function DailyModel:GetAcOpenStatus( module_id,module_sub )
  801. if (not module_id) or (not module_sub) then return end
  802. self.ac_open_status = self.ac_open_status or {}
  803. return self.ac_open_status[module_id .. "@" .. module_sub]
  804. end
  805. function DailyModel:SetAcOpenStatus( value )
  806. if not value then return end
  807. self.ac_open_status = {}
  808. for k,v in pairs(value) do
  809. self.ac_open_status[v.module .. "@" .. v.module_sub] = v
  810. end
  811. end
  812. function DailyModel:RefreshOneAcOpenStatus( value )
  813. if not value then return end
  814. if self.ac_open_status then
  815. self.ac_open_status[value.module .. "@" .. value.module_sub] = value
  816. return true
  817. end
  818. end
  819. -- 通过活动数据控制活动开放情况
  820. function DailyModel:SetActivityIconShow(act_data)
  821. --双倍护送
  822. if act_data.module == 500 and act_data.status == 1 then
  823. ActivityIconManager:getInstance():addIcon(500, math.max(0,act_data.end_time - TimeUtil:getServerTime()))
  824. GlobalEventSystem:Fire(EventName.OPEN_ACITVITY_TIP,500, 1, true)
  825. end
  826. --本服团战图标开放情况
  827. if act_data.module == 405 and act_data.module_sub == 1 then
  828. GuildModel:getInstance():Fire(GuildModel.GUILD_WAR_OPEN_STATE, act_data.status, act_data.end_time)
  829. end
  830. -- 狂战领域按钮开放
  831. if act_data.module == 415 then
  832. -- 活动状态为1也不稳,再多判断一个过期时间
  833. if act_data.status == 1 and act_data.end_time - TimeUtil:getServerTime() > 0 then
  834. ActivityIconManager:getInstance():addIcon(415, math.max(0, act_data.end_time - TimeUtil:getServerTime()))
  835. -- RageWarModel:getInstance():CheckRageWarEventTipsView()
  836. else
  837. ActivityIconManager:getInstance():deleteIcon(415)
  838. GlobalEventSystem:Fire(EventName.CLOSE_ACITVITY_TIP, 415, nil)
  839. end
  840. end
  841. end
  842. -------------------------
  843. --查询活跃度信息
  844. function DailyModel:GetLivenessInfo( )
  845. return self.liveness_info
  846. end
  847. --查询活跃度
  848. function DailyModel:GetLivenessInfoLive( )
  849. return self.liveness_info and self.liveness_info.live or 0
  850. end
  851. function DailyModel:SetLivenessInfo( value )
  852. self.liveness_info = value
  853. end
  854. -------------------------
  855. --玩家活跃度形象
  856. function DailyModel:GetLivenessFigureInfo( )
  857. return self.liveness_figure_info
  858. end
  859. function DailyModel:SetLivenessFigureInfo( value )
  860. self.liveness_figure_info = value
  861. end
  862. -------------------------
  863. --资源找回界面信息
  864. function DailyModel:GetResourceRecoveryList( )
  865. local result_data = {}
  866. local back_conf = false
  867. local guild_id = RoleManager.Instance.mainRoleInfo.guild_id
  868. for i,v in ipairs(self.resource_recovery_list or {}) do
  869. back_conf = self:GetResactConfig(v.act_id, v.act_sub)
  870. if back_conf then
  871. -- if back_conf.guild_limit == 1 and guild_id == 0 then
  872. -- --社团限制
  873. -- else
  874. local special_recover = self:RetRecoverSpecialReward(v.act_id, v.act_sub)
  875. if special_recover and #special_recover == 0 then
  876. --几个特殊的没有奖励不要显示啦
  877. else
  878. result_data[#result_data+1] = v
  879. end
  880. -- end
  881. end
  882. end
  883. return result_data
  884. end
  885. function DailyModel:SetResourceRecoveryList( value )
  886. self.resource_recovery_list = value or {}
  887. end
  888. function DailyModel:ChangeResourceRecoveryList( data )
  889. if (not self.resource_recovery_list) or (not data) then return end
  890. for k,v in pairs(self.resource_recovery_list or {}) do
  891. if v.act_id == data.act_id and v.act_sub == data.act_sub then
  892. v.lefttimes = value.lefttimes
  893. v.reward_lv = value.reward_lv
  894. return true
  895. end
  896. end
  897. end
  898. -------------------------
  899. function DailyModel:GetTodayRewardIsLock( id )
  900. local my_lv = RoleManager.Instance.mainRoleInfo.level
  901. for k,v in pairs(Config.Activityreward) do
  902. if v.id == id then
  903. return my_lv < v.min_lv
  904. end
  905. end
  906. return true
  907. end
  908. function DailyModel:CanGetTodayReward( check_new,id )
  909. if not id then return false end
  910. local liveness_data = self:GetLivenessInfo()
  911. if not liveness_data then
  912. return false
  913. end
  914. -------------------------
  915. if check_new then
  916. self.red_today_reward[id] = false
  917. local lv_lock = self:GetTodayRewardIsLock(id)--未解锁状态
  918. if lv_lock then
  919. else
  920. for k,v in pairs(liveness_data.reward_list) do
  921. if v.id == id then
  922. self.red_today_reward[id] = v.state == 1
  923. break
  924. end
  925. end
  926. end
  927. end
  928. return self.red_today_reward[id]
  929. end
  930. function DailyModel:CanGetTodayRewardAll( check_new )
  931. if check_new then
  932. local liveness_data = self:GetLivenessInfo()
  933. if not liveness_data then return false end
  934. -------------------------
  935. for k,v in pairs(liveness_data.reward_list) do
  936. self:CanGetTodayReward(true,v.id)
  937. end
  938. end
  939. for k,v in pairs(self.red_today_reward) do
  940. if v then return true end
  941. end
  942. return false
  943. end
  944. function DailyModel:GetCanUpLive( check_new )
  945. if check_new then
  946. self.red_liveness_up = false
  947. if self:IsLivenessMaxLevel() then
  948. else
  949. local data = self:GetLivenessFigureInfo()
  950. if data then
  951. local conf = self:GetLivenessLvConfig(data.lv)
  952. -------------------------
  953. if data.exp >= conf.exp then
  954. self.red_liveness_up = true
  955. end
  956. end
  957. end
  958. end
  959. return self.red_liveness_up
  960. end
  961. function DailyModel:IsLivenessMaxLevel( )
  962. local data = self:GetLivenessFigureInfo()
  963. if not data then return false end
  964. if self:GetLivenessLvConfig(data.lv+1) then
  965. return false
  966. else
  967. return true
  968. end
  969. end
  970. function DailyModel:GetTodayActivityList( )
  971. local cur_weekday = tonumber(os.date("%w", TimeUtil:getServerTime()))
  972. cur_weekday = cur_weekday ~= 0 and cur_weekday or 7
  973. local data = self:GetWeekCalendarInfo()
  974. local result_data = {}
  975. for i,v in ipairs(data) do
  976. if v[cur_weekday+1] ~= "" then
  977. v[cur_weekday+1].time = v[1]
  978. table.insert( result_data, v[cur_weekday+1] )
  979. end
  980. end
  981. return result_data
  982. end
  983. --传参数判断是否活动时间内以及今天是否已结束以及下一次的开启时间
  984. function DailyModel:GetActivityGoingStatus( time_region ,curTime )
  985. -- local time_region = [[ [{{15,30},{16,0}},{{20,30},{20,40}}] ]]
  986. if not time_region then return end
  987. local time_list = false
  988. if type(time_region) == "string" then
  989. time_list = stringtotable(time_region)
  990. else
  991. time_list = time_region
  992. end
  993. -------------------------
  994. curTime = curTime or TimeUtil:getServerTime()
  995. local date = os.date("*t", curTime)
  996. local date_zero={year=date.year,month=date.month,day=date.day,hour=0,min=0,sec=0}
  997. -------------------------
  998. local today_over = true--今天是否已结束
  999. local is_going = false--是否时间内
  1000. local ending_time = false--最后的结束时间
  1001. local next_time = false
  1002. for i,v in ipairs(time_list) do
  1003. local start_time = os.time({year=date.year,month=date.month,day=date.day,hour=tonumber(v[1][1]),min=tonumber(v[1][2]),sec=0})
  1004. local end_time = os.time({year=date.year,month=date.month,day=date.day,hour=tonumber(v[2][1]),min=tonumber(v[2][2]),sec=0})
  1005. ending_time = ending_time or end_time
  1006. ending_time = ending_time > end_time and ending_time or end_time
  1007. if curTime >= start_time and curTime <= end_time then
  1008. is_going = true
  1009. break
  1010. end
  1011. if start_time > curTime then
  1012. next_time = next_time or start_time
  1013. next_time = next_time < start_time and next_time or start_time
  1014. end
  1015. end
  1016. if ending_time and ending_time > curTime then
  1017. today_over = false
  1018. end
  1019. return is_going,today_over,next_time
  1020. end
  1021. --找回红点
  1022. function DailyModel:GetRecoverRed( )
  1023. -- if self.mask_recover_red then return false end--一次性红点机制去除
  1024. local recover_list = self:GetResourceRecoveryList()
  1025. if recover_list and TableSize(recover_list) > 0 then
  1026. return true
  1027. end
  1028. return false
  1029. end
  1030. function DailyModel:RetRecoverSpecialReward( act_id, act_sub )
  1031. local function sort_func( data )
  1032. local result = {}
  1033. for k,v in pairs(data or {}) do
  1034. table.insert( result, v )
  1035. end
  1036. return result
  1037. end
  1038. if act_id == 610 then
  1039. if act_sub == BaseDungeonModel.DUN_TYPE.ONE_TOWER then--单人爬塔4
  1040. return sort_func(BaseDungeonModel:GetInstance():GetTowerDailyReward())
  1041. elseif act_sub == BaseDungeonModel.DUN_TYPE.IllusoryLight then--幻光副本(波数副本)7
  1042. return sort_func(BaseDungeonModel:GetInstance():GetLigthDunSweepAward())
  1043. elseif act_sub == BaseDungeonModel.DUN_TYPE.PET then--守卫幼宠8
  1044. return sort_func(BaseDungeonModel:GetInstance():GetDunPetHistoryMaxScore())
  1045. end
  1046. elseif act_id == 215 and act_sub == 2 then--绝地守卫
  1047. return sort_func(BaseDungeonModel:GetInstance():GetGuardianRecoveryReward())
  1048. end
  1049. return false
  1050. end
  1051. -------------------------------- 托管开始 --------------------------------
  1052. --获取托管配置列表
  1053. function DailyModel:GetHostingCfg( )
  1054. local config = DeepCopy(Config.Offlinehostingact)
  1055. local cur_weekday = tonumber(os.date("%w", TimeUtil:getServerTime()))
  1056. cur_weekday = cur_weekday ~= 0 and cur_weekday or 7
  1057. local list = {}
  1058. for k,v in pairs(config) do
  1059. local d = self:GetHostingItemCfg(v.module_id)
  1060. if d then
  1061. local tt = {}
  1062. for kk,vv in pairs(d) do
  1063. tt = vv
  1064. break
  1065. end
  1066. --今日是否已经开启
  1067. if d[cur_weekday] then
  1068. v.today_open = 1
  1069. else
  1070. v.today_open = 0
  1071. end
  1072. v.time_str = tt.time or "00:00~00:00"
  1073. table_insert(list, v)
  1074. end
  1075. end
  1076. --处理活动是否已经结束
  1077. local date = os.date("*t", TimeUtil:getServerTime())
  1078. local zero_min = date.hour * 60 + date.min -- 当前时区距0点的分钟数
  1079. local evt_time_start, evt_start_hour, evt_start_min
  1080. for k, v in ipairs(list) do
  1081. evt_time_start = Split((Split(v.time_str, "~")[1]),":")
  1082. evt_start_hour = evt_time_start[1]
  1083. evt_start_min = evt_time_start[2]
  1084. v.open_time = evt_start_hour * 60 + evt_start_min
  1085. if evt_start_hour * 60 + evt_start_min >= zero_min then
  1086. v.is_opened = 0
  1087. else
  1088. v.is_opened = 1
  1089. end
  1090. end
  1091. table.sort( list, function (a,b)
  1092. if a.today_open ~= b.today_open then
  1093. return a.today_open > b.today_open
  1094. else
  1095. return a.open_time < b.open_time
  1096. end
  1097. end)
  1098. return list
  1099. end
  1100. --获取托管配置列表
  1101. function DailyModel:GetHostingCfgItem(module_id, sub_id )
  1102. local config = Config.Offlinehostingact
  1103. for k,v in pairs(config) do
  1104. if v.module_id == module_id and v.mod_sub == sub_id then
  1105. return v
  1106. end
  1107. end
  1108. end
  1109. --获取托管配置列表
  1110. function DailyModel:GetHostingCfgItemBySubId(module_id, sub_id )
  1111. local config = Config.Offlinehostingact
  1112. for k,v in pairs(config) do
  1113. if v.module_id == module_id and v.sub_id == sub_id then
  1114. return v
  1115. end
  1116. end
  1117. end
  1118. --获取托管日常
  1119. function DailyModel:GetHostingItemCfg(module_id)
  1120. if not self.hosting_time_cfg then
  1121. local config = self:GetWeekCalendarInfo()
  1122. local time_cfg = {}
  1123. for k,v in pairs(config) do
  1124. for i=2,8 do
  1125. local tt = v[i]
  1126. if type(tt) == "table" then
  1127. time_cfg[tt.module_id] = time_cfg[tt.module_id] or {}
  1128. time_cfg[tt.module_id][i - 1] = time_cfg[tt.module_id][i - 1] or {}
  1129. time_cfg[tt.module_id][i - 1].time = v[1]
  1130. time_cfg[tt.module_id][i - 1].name = tt.name
  1131. end
  1132. end
  1133. end
  1134. self.hosting_time_cfg = time_cfg
  1135. end
  1136. return self.hosting_time_cfg[module_id]
  1137. end
  1138. --获取托管日常描述字符串
  1139. function DailyModel:GetHostingTimeString(module_id)
  1140. self.hosting_time_string_list = self.hosting_time_string_list or {}
  1141. if not self.hosting_time_string_list[module_id] then
  1142. local cfg = self:GetHostingItemCfg(module_id)
  1143. local str_list = {[1] ="", [2] = ""}
  1144. if cfg then
  1145. local time_list = {}
  1146. local day_list = {}
  1147. for day,v in pairs(cfg) do
  1148. table.insert(day_list, day)
  1149. local exit_time = false
  1150. if #time_list > 0 then
  1151. for ii,vv in ipairs(time_list) do
  1152. if vv == v.time then
  1153. exit_time = true
  1154. break
  1155. end
  1156. end
  1157. end
  1158. if not exit_time then
  1159. table.insert(time_list, v.time)
  1160. end
  1161. end
  1162. local time_str = ""
  1163. local day_str = ""
  1164. if #day_list == 7 then
  1165. day_str = "每天"
  1166. elseif #day_list == 6 then
  1167. local no_in_day = 1
  1168. for i,v in ipairs(day_list) do
  1169. if v ~= no_in_day or no_in_day == 7 then
  1170. break
  1171. end
  1172. no_in_day = no_in_day + 1
  1173. end
  1174. day_str = string.format("除周%s外", TimeUtil:GetWeekStrNum(no_in_day))
  1175. else
  1176. for i,v in ipairs(day_list) do
  1177. day_str = day_str == "" and ("".. TimeUtil:GetWeekStrNum(v)) or (day_str .."".. TimeUtil:GetWeekStrNum(v))
  1178. end
  1179. end
  1180. --只需要显示开始时间
  1181. local t_list = {}
  1182. for i,v in ipairs(time_list) do
  1183. local s_list = Split(v, "~")
  1184. if s_list and s_list[1] then
  1185. table_insert(t_list, s_list[1])
  1186. end
  1187. end
  1188. time_list = t_list
  1189. for i,v in ipairs(time_list) do
  1190. time_str = time_str == "" and v or (time_str .."".. v)
  1191. end
  1192. str_list[1] = day_str
  1193. str_list[2] = time_str
  1194. end
  1195. self.hosting_time_string_list[module_id] = str_list
  1196. end
  1197. return self.hosting_time_string_list[module_id]
  1198. end
  1199. --获取托管日常
  1200. function DailyModel:GetHostingIsOpenToday(module_id, weekday)
  1201. self.hosting_time_day_list = self.hosting_time_day_list or {}
  1202. if not self.hosting_time_day_list[module_id] then
  1203. local cfg = self:GetHostingItemCfg(module_id)
  1204. local day_list = {}
  1205. if cfg then
  1206. for day,v in pairs(cfg) do
  1207. day_list[day] = true
  1208. end
  1209. end
  1210. self.hosting_time_day_list[module_id] = day_list
  1211. end
  1212. if not weekday then
  1213. local time = TimeUtil:getServerTime()
  1214. local weekday = tonumber(os.date("%w", time))
  1215. if weekday == 0 then
  1216. weekday = 7
  1217. end
  1218. end
  1219. return self.hosting_time_day_list[module_id] and self.hosting_time_day_list[module_id][weekday]
  1220. end
  1221. --托管设置信息
  1222. function DailyModel:SetHostingInfo(vo)
  1223. self.hosting_info.now_value = vo.now_value
  1224. self.hosting_info.daily_value = vo.daily_value
  1225. self.hosting_info.setting_list = vo.close_list
  1226. if #self.hosting_info.setting_list > 0 then
  1227. for i,v in ipairs(self.hosting_info.setting_list) do
  1228. v.status = 0
  1229. end
  1230. end
  1231. self:Fire(DailyModel.HOSTING_SETTING_INFO)
  1232. end
  1233. --托管设置
  1234. function DailyModel:SetHostingSetting(vo)
  1235. local setting = false
  1236. self.hosting_info.setting_list = self.hosting_info.setting_list or {}
  1237. for i,v in ipairs(self.hosting_info.setting_list) do
  1238. if v.module == vo.module and v.sub_id == vo.sub_id then
  1239. setting = v
  1240. end
  1241. end
  1242. if not setting then
  1243. table.insert(self.hosting_info.setting_list, {module = vo.module, sub_id = vo.sub_id, status = vo.status})
  1244. else
  1245. setting.status = vo.status
  1246. end
  1247. self:Fire(DailyModel.HOSTING_SETTING_UPDATE, vo.module, vo.sub_id, vo.status)
  1248. end
  1249. --获取托管设置
  1250. function DailyModel:GetHostingSetting(module_id, sub_id)
  1251. local setting = false
  1252. self.hosting_info.setting_list = self.hosting_info.setting_list or {}
  1253. for i,v in ipairs(self.hosting_info.setting_list) do
  1254. if v.module == module_id and v.sub_id == sub_id then
  1255. setting = v
  1256. end
  1257. end
  1258. if not setting then
  1259. setting = {module = module_id, sub_id = sub_id, status = 1}
  1260. table.insert(self.hosting_info.setting_list, setting)
  1261. end
  1262. return setting and setting.status == 1
  1263. end
  1264. --获取托管设置
  1265. function DailyModel:GetHostingSettingAc(module_id, sub_id)
  1266. local ac = false
  1267. local cfg = Config.Offlinehostingact
  1268. for k,v in pairs(cfg) do
  1269. if module_id == v.module_id and sub_id == v.mod_sub then
  1270. ac = v
  1271. break
  1272. end
  1273. end
  1274. return ac
  1275. end
  1276. --托管记录
  1277. function DailyModel:SetHostingRecord(vo)
  1278. self.hosting_info.record_list = vo.list or {}
  1279. self:Fire(DailyModel.HOSTING_RECORE_UPDATE)
  1280. end
  1281. --托管图标
  1282. function DailyModel:GetHostingSettingIcon(module_id)
  1283. local config = Config.Ac
  1284. for k,v in pairs(config) do
  1285. if v.module == module_id then
  1286. return v.ac_icon
  1287. end
  1288. end
  1289. return ""
  1290. end
  1291. --托管奖励
  1292. function DailyModel:SetHostingReward(vo)
  1293. self.hosting_info.reward = {}
  1294. if #vo.list > 0 then
  1295. local cost = 0
  1296. local record_list = {}
  1297. local reward_list = {}
  1298. ----------容错,先清掉没有配置的条目-------
  1299. local list = {}
  1300. for i,v in ipairs(vo.list) do
  1301. local item = self:GetHostingCfgItemBySubId(v.module, v.sub_id)
  1302. if item then
  1303. table.insert(list, v)
  1304. end
  1305. end
  1306. vo.list = list
  1307. ----------容错,先清掉没有配置的条目 ------
  1308. for i,v in ipairs(vo.list) do
  1309. cost = cost + v.cost_value
  1310. local item = self:GetHostingCfgItemBySubId(v.module, v.sub_id)
  1311. local time_str = TimeUtil:timeConversion(v.time,"mm-dd hh:MM:ss")
  1312. local str = string.format("%s 为您托管%s活动", time_str, HtmlColorTxt(Trim(item.desc) , "#f3fcff"))
  1313. record_list[i] = {}
  1314. record_list[i].record_text = str
  1315. local list = v.reward_list or {}
  1316. if #list > 1 then
  1317. for i,v in ipairs(list) do
  1318. local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(v.typeId)
  1319. v.color = goodVo.color
  1320. end
  1321. table.sort(list, function (a,b)
  1322. if a.color ~= b.color then
  1323. return a.color > b.color
  1324. elseif a.typeId ~= b.typeId then
  1325. return a.typeId < b.typeId
  1326. else
  1327. return a.count > b.count
  1328. end
  1329. end)
  1330. end
  1331. record_list[i].reward_list = list
  1332. end
  1333. self.hosting_info.reward.record_list = record_list
  1334. self.hosting_info.reward.cost = cost
  1335. self:Fire(DailyModel.OPEN_HOSTING_REWARD_VIEW)
  1336. end
  1337. end
  1338. --获取托管红点
  1339. function DailyModel:GetHostingRed()
  1340. return self.hosting_red_dot
  1341. end
  1342. --完成托管红点
  1343. function DailyModel:SaveHostingRed()
  1344. if self.hosting_red_dot then
  1345. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.HOSTING_SETTING_RED_SHOW, false)
  1346. CookieWrapper.Instance:WriteAll()
  1347. self.hosting_red_dot = false
  1348. end
  1349. end
  1350. --加载托管红点
  1351. function DailyModel:LoadHostingRed()
  1352. self.hosting_red_dot = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.HOSTING_SETTING_RED_SHOW) == nil and true or false
  1353. return self.hosting_red_dot
  1354. end
  1355. -------------------------------- 托管结束 --------------------------------
  1356. -------------------------------- 日常预约开始 --------------------------------
  1357. --设置日常预约所有数据
  1358. function DailyModel:SetDailyOrderAllData(vo)
  1359. self.daily_order_info = vo.reserve_list
  1360. local is_red = false
  1361. for k,v in pairs(self.daily_order_info ) do
  1362. if (v.status == DailyOrderStatus.UN_ORDER and not self:IsInActiviteDailyOrderOver(v.module, v.sub_module, v.ac_sub) or v.status == DailyOrderStatus.UN_GET) then
  1363. is_red = true
  1364. break
  1365. end
  1366. end
  1367. self.daily_order_red_dot = is_red
  1368. if self.daily_order_red_dot then
  1369. ActivityIconManager:getInstance():addIcon(1571, -1)
  1370. else
  1371. ActivityIconManager:getInstance():deleteIcon(1571)
  1372. end
  1373. GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 1571, is_red)
  1374. self:Fire(DailyModel.UPDATE_DAILY_ORDER_ALL_DATA)
  1375. end
  1376. --获取托管红点
  1377. function DailyModel:GetDailyOrderRed()
  1378. return self.daily_order_red_dot
  1379. end
  1380. function DailyModel:SetDailyOrderTargetData(target_vo)
  1381. if target_vo and self.daily_order_info then
  1382. for k,v in pairs(self.daily_order_info) do
  1383. if v.module == target_vo.module and v.sub_module == target_vo.sub_module and v.ac_sub == target_vo.ac_sub then
  1384. v.status = target_vo.status
  1385. end
  1386. end
  1387. local is_red = false
  1388. for k,v in pairs(self.daily_order_info ) do
  1389. if (v.status == DailyOrderStatus.UN_ORDER and not self:IsInActiviteDailyOrderOver(v.module, v.sub_module, v.ac_sub) or v.status == DailyOrderStatus.UN_GET) then
  1390. is_red = true
  1391. break
  1392. end
  1393. end
  1394. self.daily_order_red_dot = is_red
  1395. if self.daily_order_red_dot then
  1396. ActivityIconManager:getInstance():addIcon(1571, -1)
  1397. else
  1398. ActivityIconManager:getInstance():deleteIcon(1571)
  1399. end
  1400. self:Fire(DailyModel.UPDATE_DAILY_ORDER_TARGET_DATA, target_vo.module, target_vo.sub_module, target_vo.ac_sub)
  1401. GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 1571, is_red)
  1402. end
  1403. end
  1404. function DailyModel:GetDailyOrderTargetData(i_module, i_module_sub, i_ac_sub)
  1405. if self.daily_order_info then
  1406. for k,v in pairs(self.daily_order_info) do
  1407. if v.module == i_module and v.sub_module == i_module_sub and v.ac_sub == i_ac_sub then
  1408. return v.status
  1409. end
  1410. end
  1411. end
  1412. return -1
  1413. end
  1414. function DailyModel:GetDailyOrderTipsData(i_module, i_module_sub, i_ac_sub)
  1415. if not i_module or not i_module_sub or not i_ac_sub then
  1416. return false
  1417. end
  1418. local key = i_module .. "@" .. i_module_sub .. "@" .. i_ac_sub
  1419. local cfg_ac = Config.Ac[key]
  1420. if cfg_ac then
  1421. return cfg_ac
  1422. end
  1423. end
  1424. function DailyModel:GetDailyOrderList()
  1425. local list = {}
  1426. if self.daily_order_info and #self.daily_order_info > 0 then
  1427. local cfg =Config.Actreserve
  1428. for k,v in pairs(self.daily_order_info) do
  1429. local key = v.module .. "@" .. v.sub_module .. "@" .. v.ac_sub
  1430. if cfg[key] then
  1431. local d = cfg[key]
  1432. d.status = v.status
  1433. table.insert(list, d)
  1434. end
  1435. end
  1436. if #list > 1 then
  1437. for i,v in ipairs(list) do
  1438. local is_end = self:IsActiviteDailyOrderEnd(v.module_id, v.module_sub, v.ac_sub)
  1439. local is_over = self:IsInActiviteDailyOrderOver(v.module_id, v.module_sub, v.ac_sub)
  1440. if v.status == DailyOrderStatus.UN_GET then
  1441. v.sort = 2
  1442. elseif v.status == DailyOrderStatus.UN_JOIN then
  1443. v.sort = 3
  1444. else
  1445. if is_end then
  1446. v.sort = 6
  1447. elseif is_over then
  1448. v.sort = 5
  1449. else
  1450. if v.status == DailyOrderStatus.UN_ORDER then
  1451. v.sort = 2
  1452. elseif v.status == DailyOrderStatus.DONE then
  1453. v.sort = 4
  1454. else
  1455. v.sort = 5
  1456. end
  1457. end
  1458. end
  1459. end
  1460. table.sort(list, function (a, b)
  1461. if a.sort == b.sort then
  1462. return a.index < b.index
  1463. else
  1464. return a.sort < b.sort
  1465. end
  1466. end)
  1467. end
  1468. end
  1469. return list
  1470. end
  1471. -- 获取预约活动每天的世界
  1472. function DailyModel:GetDailyOrderActiviteOpenTime( evt_time_data, need_week)
  1473. local time = false
  1474. local key = evt_time_data.module_id .. "@" .. evt_time_data.module_sub .. "@" .. evt_time_data.ac_sub
  1475. local cfg = Config.Ac[key]
  1476. if cfg then
  1477. local weekList = DailyModel.getInstance():GetParseList(cfg.week)
  1478. local time_region = stringtotable(cfg.time_region)
  1479. local week_time = ""
  1480. if #weekList == 7 or #weekList == 0 then
  1481. week_time = "每周"
  1482. else
  1483. for i,v in ipairs(weekList) do
  1484. if week_time == "" then
  1485. week_time = "" .. TimeUtil:GetWeekStrNum(tonumber(v))
  1486. else
  1487. week_time = week_time .. "" .. TimeUtil:GetWeekStrNum(tonumber(v))
  1488. end
  1489. end
  1490. end
  1491. local start_time
  1492. local end_time
  1493. if time_region and time_region[1] and time_region[1][1] and time_region[1][2] then
  1494. local t1 = time_region[1][1]
  1495. local t2 = time_region[1][2]
  1496. if t1[2] == 0 then
  1497. t1[2] = "00"
  1498. end
  1499. if t2[2] == 0 then
  1500. t2[2] = "00"
  1501. end
  1502. start_time = t1[1] .. ":" .. t1[2]
  1503. end_time = t2[1] .. ":" .. t2[2]
  1504. else
  1505. return false
  1506. end
  1507. if need_week then
  1508. time = week_time .. start_time .."-"..end_time
  1509. else
  1510. time = start_time .."-"..end_time
  1511. end
  1512. end
  1513. return time
  1514. end
  1515. -- 获取活动的每天活跃度
  1516. function DailyModel:GetDailyActiviteLive( i_module, i_module_sub)
  1517. local live = 0
  1518. local key = i_module .. "@" .. i_module_sub
  1519. local cfg = Config.Activityliveness[key]
  1520. if cfg then
  1521. if cfg.max < 100 then
  1522. live = cfg.max * cfg.live
  1523. else
  1524. live = cfg.live
  1525. end
  1526. end
  1527. return live
  1528. end
  1529. -- 获取预约活动每天的世界
  1530. function DailyModel:IsActiviteDailyOrderEnd( i_module, i_module_sub, i_ac_sub)
  1531. local is_end = false
  1532. local key = i_module .. "@" .. i_module_sub .. "@" .. i_ac_sub
  1533. local cfg = Config.Ac[key]
  1534. if cfg then
  1535. local time_region = stringtotable(cfg.time_region)
  1536. if time_region and time_region[1] and #time_region[1] > 0 then
  1537. local cur_hour, cur_min = TimeUtil:getCurHourMinSce()
  1538. local time_table = time_region[1]
  1539. local end_hour = tonumber(time_table[#time_table][1])
  1540. local end_min = tonumber(time_table[#time_table][2])
  1541. if cur_hour > end_hour or (cur_hour == end_hour and cur_min >= end_min) then
  1542. is_end = true
  1543. end
  1544. end
  1545. end
  1546. return is_end
  1547. end
  1548. -- 当前是否在活动中(活动中,不让预约)
  1549. function DailyModel:IsInActiviteDailyOrderOver( i_module, i_module_sub, i_ac_sub)
  1550. local is_over = false
  1551. local key = i_module .. "@" .. i_module_sub .. "@" .. i_ac_sub
  1552. local cfg = Config.Ac[key]
  1553. if cfg then
  1554. local time_region = stringtotable(cfg.time_region)
  1555. if time_region and time_region[1] and #time_region[1] > 0 then
  1556. local cur_hour, cur_min = TimeUtil:getCurHourMinSce()
  1557. local time_table = time_region[1]
  1558. local end_hour = tonumber(time_table[1][1])
  1559. local end_min = tonumber(time_table[1][2])
  1560. if cur_hour > end_hour or (cur_hour == end_hour and cur_min >= end_min) then
  1561. is_over = true
  1562. end
  1563. end
  1564. end
  1565. return is_over
  1566. end
  1567. -------------------------------- 日常预约结束 --------------------------------
  1568. -- 获取指定活动的基本数据
  1569. function DailyModel:GetTargetDailyBaseInfo( i_module, i_module_sub)
  1570. local target_base_info = nil
  1571. local base_data = self:GetCommonShowList( )
  1572. if base_data then
  1573. -- for i,v in ipairs(base_data.ac_list) do
  1574. for ii,vv in ipairs(base_data) do
  1575. if vv.module == i_module and vv.module_sub == i_module_sub then
  1576. target_base_info = vv
  1577. break
  1578. end
  1579. end
  1580. -- end
  1581. end
  1582. return target_base_info
  1583. end
  1584. -- 获取指定活动的基本数据
  1585. function DailyModel:DailyCommonTipsCurNumAndMaxNum( base_data)
  1586. local ret_cur_num, ret_max_num = 0, 0
  1587. if base_data then
  1588. local cur_num = base_data.num
  1589. local max_num = base_data.show_max_times or base_data.max_times
  1590. -------------------------
  1591. local is_money_collect = base_data.module == 130 and base_data.ac_sub == 1
  1592. if is_money_collect then
  1593. if base_data.module_sub == 5 then
  1594. --交易券收集
  1595. max_num = Config.Counterdaily["157@3"].limit
  1596. cur_num = self.daily_base_info and self.daily_base_info.collect_coin or 0
  1597. elseif base_data.module_sub == 6 then
  1598. --名望券收集
  1599. max_num = Config.Counterdaily["157@4"].limit
  1600. cur_num = self.daily_base_info and self.daily_base_info.collect_honor or 0
  1601. end
  1602. end
  1603. -------------------------
  1604. if cur_num > max_num and max_num > 0 then
  1605. ret_cur_num = max_num
  1606. ret_max_num = max_num
  1607. else
  1608. local show_max_num = max_num
  1609. ret_cur_num = cur_num
  1610. ret_max_num = show_max_num
  1611. end
  1612. end
  1613. return ret_cur_num, ret_max_num
  1614. end
  1615. -- 日常活动前往
  1616. function DailyModel:DailyCommomItemGo(daily_data)
  1617. if daily_data then
  1618. if daily_data.module == 610 and daily_data.module_sub == 5001 and daily_data.ac_sub == 1 then
  1619. if ExpDunModel:getInstance():IsPassAllExpDun() then
  1620. --经验挂机达到上限之后,转成领取经验奖励
  1621. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61050, 0, 0)
  1622. return
  1623. end
  1624. end
  1625. if daily_data.module == 130 and daily_data.ac_sub == 1 then
  1626. if daily_data.module_sub == 6 then
  1627. UIToolTipMgr:getInstance():AppendGoodsTips(Config.ConfigNotNormalGoods[4].goods_id,nil,nil,nil,nil,nil,nil,true)
  1628. return
  1629. elseif daily_data.module_sub == 5 then
  1630. UIToolTipMgr:getInstance():AppendGoodsTips(Config.ConfigNotNormalGoods[3].goods_id,nil,nil,nil,nil,nil,nil,true)
  1631. return
  1632. end
  1633. end
  1634. if daily_data.module == 300 and daily_data.conf_data.jump_id == 2 then
  1635. self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
  1636. if RoleManager.Instance.mainRoleInfo.guild_id>0 then
  1637. OpenFun.Open(daily_data.module,daily_data.conf_data.jump_id)
  1638. else
  1639. OpenFun.Open(400,0)
  1640. Message.show("请先加入社团")
  1641. end
  1642. elseif daily_data.module == 142 and daily_data.module_sub == 0 then
  1643. self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
  1644. OpenFun.Open(400,5)
  1645. elseif daily_data.module == 500 then
  1646. self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
  1647. EscortModel:getInstance():FlyToNpc()
  1648. else
  1649. self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
  1650. OpenFun.Open(daily_data.module, daily_data.conf_data.jump_id)
  1651. end
  1652. end
  1653. end