源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

890 行
24 KiB

  1. CSMainModel = CSMainModel or BaseClass(BaseVo, true)
  2. local CSMainModel = CSMainModel
  3. function CSMainModel:__init()
  4. CSMainModel.Instance = self
  5. self:Reset()
  6. end
  7. function CSMainModel:Reset()
  8. self.legion_kv_cfg = {}--��������
  9. self.task_cfg = {}--��������
  10. self.active_awards_cfg = {}--��Ծ��������
  11. self.max_active_cfg_num = 0
  12. self.exploit_rank_reward_cfg = {}--����������������
  13. self.military_ranks_cfg = {}--��������
  14. self.exploit_can_get_reward_rank = 0--����ȡ��������������
  15. self.director_role_data = {}--ָ����������������
  16. self.active_process = 0--��Ծ����
  17. self.active_dot = 0--��ǰ��ȡ����
  18. self.arms_num = 0--����ֵ
  19. self.military_ranks = 0--����
  20. self.exploit_rank_score = 0--�����
  21. self.active_dot_list = {}--�����Ļ�Ծ�����ڵ��б�
  22. self.my_country_exploit_rank_num = 0--�ҵĹ��Ҿ�����������
  23. self.last_guild_war_rank_data = {}--���ڿ�����ս���У���¼ֻ����һ�β����渴��
  24. self.last_military_score_rank_data = {}--���ھ�������
  25. self.appoint_data_0 = {}--��ʷ������¼ ǰ������
  26. self.appoint_data_1 = {}--��ʷ������¼ ָ�ӹ�Ա
  27. self.click_worship_role_list = {}--��Ĥ�������б�
  28. self.click_worship_role = 0--��Ĥ������
  29. self.my_exploit_last_rank = 0--ǰ������
  30. self.my_day_reward_state = 0--��ȡ״̬1����ȡ
  31. self.cs_main_task_data = {}--��������
  32. self.cs_main_red_info = {}--������Ϣ
  33. self.task_red_by_color = {}--����Ʒ�ʺ���
  34. self.advance_notice_reward_data = {}--Ԥ�潱������
  35. self.has_request_60314 = false
  36. self.has_request_60311 = false
  37. self:InitCSMainCfg()
  38. end
  39. --�رս�������Ҫ���õ�����
  40. function CSMainModel:ResetDataAfterCloseView( )
  41. self.director_role_data = {}
  42. end
  43. function CSMainModel:getInstance()
  44. if CSMainModel.Instance == nil then
  45. CSMainModel.Instance = CSMainModel.New()
  46. end
  47. return CSMainModel.Instance
  48. end
  49. function CSMainModel:InitCSMainCfg( )
  50. --��������
  51. self.legion_kv_cfg = Config.Legionkv
  52. --��������
  53. for k,v in pairs(Config.Legiontask) do
  54. self.task_cfg[v.color] = self.task_cfg[v.color] or {}
  55. table.insert(self.task_cfg[v.color],v)
  56. end
  57. for k,v in pairs(self.task_cfg) do
  58. local sort_func = function ( a, b )
  59. return a.sort < b.sort
  60. end
  61. table.sort(v, sort_func)
  62. end
  63. --��Ծ��������
  64. self.max_active_cfg_num = 0
  65. for k,v in pairs(Config.Legionactiveawards) do
  66. self.active_awards_cfg[v.round] = self.active_awards_cfg[v.round] or {}
  67. table.insert(self.active_awards_cfg[v.round],v)
  68. self.max_active_cfg_num = self.max_active_cfg_num + 1
  69. end
  70. for k,v in pairs(self.active_awards_cfg) do
  71. local sort_func = function ( a, b )
  72. return a.id < b.id
  73. end
  74. table.sort(v, sort_func)
  75. end
  76. --����������������
  77. local max_rank = 0
  78. for k,v in pairs(Config.Legionrankreward) do
  79. v.is_top = 0
  80. table.insert(self.exploit_rank_reward_cfg,v)
  81. if v.min_rank>max_rank then
  82. max_rank = v.min_rank
  83. end
  84. end
  85. self.exploit_can_get_reward_rank = max_rank
  86. --��������
  87. self.military_ranks_cfg = Config.Legionpost
  88. end
  89. --��ȡ��������������ʾ����
  90. function CSMainModel:GetCSMainHonorMaxRank( )
  91. return self.legion_kv_cfg["honor_max_rank"].value
  92. end
  93. --��ȡ����Ĥ�ݽ���
  94. function CSMainModel:GetCSMainWorshipReward( )
  95. return stringtotable(self.legion_kv_cfg["like_reward"].value)
  96. end
  97. --��ȡ��������������ʾ����
  98. function CSMainModel:GetCSMainMilitaryMaxRank( )
  99. -- return self.legion_kv_cfg["military_max_rank"].value
  100. return 0
  101. end
  102. function CSMainModel:GetCSMainChaimanMaxRank( )
  103. return self.legion_kv_cfg["chairman_max_rank"].value
  104. end
  105. function CSMainModel:GetCSMainCommanderMaxRank( )
  106. return self.legion_kv_cfg["commander_max_rank"].value
  107. end
  108. --d_type 1|ִ���� 2|ָ�ӹ�
  109. function CSMainModel:GetCSMainDsgtId(d_type)
  110. if d_type == 1 then
  111. return stringtotable(self.legion_kv_cfg["chairman_reward"].value)[1][2]
  112. elseif d_type == 2 then
  113. return stringtotable(self.legion_kv_cfg["commander_reward"].value)[1][2]
  114. end
  115. return 0
  116. end
  117. --��������id��ȡ��������
  118. --Ʒ�� cfg.color
  119. --���� Trim(cfg.desc)
  120. --��ת stringtotable(cfg.link)[1], stringtotable(cfg.link)[2]
  121. --���� stringtotable(cfg.content)[3]
  122. --���� stringtotable(cfg.awards)
  123. function CSMainModel:GetCSMainTaskCfgByTaskId(task_id)
  124. for k,v in pairs(self.task_cfg) do
  125. for m,n in pairs(v) do
  126. if n.id == task_id then
  127. return n
  128. end
  129. end
  130. end
  131. return nil
  132. end
  133. --����Ʒ�ʻ�ȡ���������б�
  134. function CSMainModel:GetCSMainTaskCfgByColor(color)
  135. return self.task_cfg[color] and self.task_cfg[color] or {}
  136. end
  137. --�����������������б�
  138. function CSMainModel:GetCSMainTaskCfgAfterSort(color)
  139. if not self.task_cfg[color] then return {} end
  140. local final_task = DeepCopy(self.task_cfg[color])
  141. for k,v in pairs(final_task) do
  142. local task_data = self:GetCSMainTaskDataById(v.id)
  143. if task_data then--0������1����ȡ2����ȡ
  144. if task_data.state == 0 then
  145. v.first_sort = 2
  146. elseif task_data.state == 1 then
  147. v.first_sort = 3
  148. elseif task_data.state == 2 then
  149. v.first_sort = 0
  150. else
  151. v.first_sort = 1
  152. end
  153. else
  154. v.first_sort = 1
  155. end
  156. end
  157. local arg = {"first_sort", "sort"}
  158. local condition = {Array.UPPER, Array.LOWER}
  159. SortTools.MoreKeysSorter(final_task, arg, condition)
  160. return final_task
  161. end
  162. --�����콱���Ȼ�ȡ���µ�һ��5����Ծ����
  163. function CSMainModel:GetCSMainActiveRewardsCfgByProgress(progress_id)
  164. if progress_id%5 == 0 and progress_id ~= 0 and progress_id ~= self.max_active_cfg_num then--Ҫ��һλ����һ������
  165. progress_id = progress_id + 1
  166. end
  167. local round = 1
  168. for k,v in pairs(self.active_awards_cfg) do
  169. for m,n in pairs(v) do
  170. if n.id == progress_id then
  171. round = n.round
  172. return self.active_awards_cfg[round]
  173. end
  174. end
  175. end
  176. return self.active_awards_cfg[round] and self.active_awards_cfg[round] or nil
  177. end
  178. --��ȡ��һҳ�Ļ�Ծ����
  179. function CSMainModel:GetCSMainLastPageActiveCfg(progress_id)
  180. -- if progress_id%5 == 0 and progress_id ~= 0 then--Ҫ��һλ����һ������
  181. -- progress_id = progress_id + 1
  182. -- end
  183. local round = 0
  184. for k,v in pairs(self.active_awards_cfg) do
  185. for m,n in pairs(v) do
  186. if n.id == progress_id then
  187. round = n.round
  188. return self.active_awards_cfg[round]
  189. end
  190. end
  191. end
  192. return self.active_awards_cfg[round] and self.active_awards_cfg[round] or nil
  193. end
  194. --���ݾ��εȼ���ȡ��������
  195. function CSMainModel:GetCSMainLegionMilitaryRanksCfg(military_ranks_lv)
  196. return self.military_ranks_cfg[military_ranks_lv] and self.military_ranks_cfg[military_ranks_lv] or nil
  197. end
  198. ------------------����----start
  199. function CSMainModel:IsNeedRedAll( )
  200. for k,v in pairs(CSMainConst.RedType) do
  201. self:IsNeedRed(v)
  202. end
  203. end
  204. function CSMainModel:IsNeedRed(tab_id)
  205. local bool = false
  206. if GetModuleIsOpen(603) and self:IsCSMainKfNumEnough() then
  207. if tab_id == CSMainConst.RedType.Task then--��������1
  208. bool = self:CheckTaskRed()
  209. elseif tab_id == CSMainConst.RedType.Active then--������Ծ����2
  210. bool = self:CheckActiveRed()
  211. elseif tab_id == CSMainConst.RedType.DailyReward then--ÿ�ս�������ȡ3
  212. bool = self:CheckDailyRewardRed()
  213. elseif tab_id == CSMainConst.RedType.MilitaryRanks then--���οɽ���4
  214. bool = self:CheckMilitaryRanksRed()
  215. elseif tab_id == CSMainConst.RedType.SandTable then--����ɳ���ܺ���5
  216. bool = self:CheckSandTableRed()
  217. elseif tab_id == CSMainConst.RedType.WorShip then--Ĥ�ݺ���
  218. bool = self:CheckWorShipRed()
  219. end
  220. else
  221. if tab_id == CSMainConst.RedType.NoticeReward then--Ԥ�潱������
  222. bool = self:CheckNoticeRewardRed()
  223. end
  224. end
  225. self.cs_main_red_info[tab_id] = bool
  226. self:Fire(CSMainConst.ANS_UPDATE_RED_DOT,tab_id)
  227. end
  228. function CSMainModel:GetMainRed( )
  229. local bool = false
  230. for i,v in pairs(self.cs_main_red_info) do
  231. if v then
  232. bool = true
  233. break
  234. end
  235. end
  236. return bool
  237. end
  238. --������������1
  239. function CSMainModel:GetTaskRed( )
  240. return self.cs_main_red_info[CSMainConst.RedType.Task]
  241. end
  242. --��ȡ��ӦƷ�ʵ��������ɺ���
  243. function CSMainModel:GetTaskRedByColor(color)
  244. return self.task_red_by_color[color] and self.task_red_by_color[color] or false
  245. end
  246. function CSMainModel:CheckTaskRed( )
  247. local bool = false
  248. for k,v in pairs(self.task_cfg) do
  249. self.task_red_by_color[k] = false
  250. for m,n in pairs(v) do
  251. local task_data = self:GetCSMainTaskDataById(n.id)
  252. if task_data and task_data.state == 1 then--����ȡ
  253. bool = true
  254. self.task_red_by_color[n.color] = true
  255. end
  256. end
  257. end
  258. return bool
  259. end
  260. --������Ծ��������2
  261. function CSMainModel:GetActiveRed( )
  262. return self.cs_main_red_info[CSMainConst.RedType.Active]
  263. end
  264. function CSMainModel:CheckActiveRed( )
  265. local bool = false
  266. for k,v in pairs(self.active_awards_cfg) do
  267. for m,n in pairs(v) do
  268. if self.active_process >= n.active then
  269. if not self:IsCSMainActiveDotRewardGet(n.id) then
  270. bool = true
  271. break
  272. end
  273. end
  274. end
  275. end
  276. return bool
  277. end
  278. --ÿ�ս�������ȡ����3
  279. function CSMainModel:GetDailyRewardRed( )
  280. return self.cs_main_red_info[CSMainConst.RedType.DailyReward]
  281. end
  282. function CSMainModel:CheckDailyRewardRed( )
  283. local bool = false
  284. --�ϰ������콱״̬Ϊ0 ���Ը�����
  285. if self.my_exploit_last_rank ~= 0 and self.my_day_reward_state == 0 then
  286. bool = true
  287. end
  288. return bool
  289. end
  290. --���οɽ�������4
  291. function CSMainModel:GetMilitaryRanksRed( )
  292. return self.cs_main_red_info[CSMainConst.RedType.MilitaryRanks]
  293. end
  294. function CSMainModel:CheckMilitaryRanksRed( )
  295. local bool = false
  296. local military_ranks = self:GetCSMainMilitaryRanks()
  297. local now_military_cfg = self:GetCSMainLegionMilitaryRanksCfg(military_ranks)
  298. local next_military_cfg = self:GetCSMainLegionMilitaryRanksCfg(military_ranks+1)
  299. local have_next = next_military_cfg and true or false
  300. if not have_next then return false end
  301. --ս������
  302. local enough_power = RoleManager.Instance.mainRoleInfo.fighting >= now_military_cfg.need
  303. --������
  304. local cost_goods_data = stringtotable(now_military_cfg.cost)
  305. if not cost_goods_data[1] or (cost_goods_data[1] and cost_goods_data[1][3] == 0)then
  306. cost_goods_data[1] = {0,100019,0}
  307. end
  308. local goods_type_id = cost_goods_data[1][2]
  309. local cost_need_num = cost_goods_data[1][3]
  310. local cost_have_num = GoodsModel:getInstance():GetTypeGoodsNum(goods_type_id)
  311. local enough_cost = cost_have_num >= cost_need_num
  312. bool = enough_cost and enough_power
  313. return bool
  314. end
  315. --����ɳ���ܺ���5
  316. function CSMainModel:GetSandTableRed( )
  317. return self.cs_main_red_info[CSMainConst.RedType.SandTable]
  318. end
  319. function CSMainModel:CheckSandTableRed( )
  320. local bool = false
  321. bool = SandTableModel:getInstance():GetRedDot(false)
  322. return bool
  323. end
  324. --Ĥ�ݺ���
  325. function CSMainModel:GetWorShipRed( )
  326. return self.cs_main_red_info[CSMainConst.RedType.WorShip]
  327. end
  328. function CSMainModel:CheckWorShipRed( )
  329. local bool = false
  330. --Ĥ���б��������������а����˿��Ը�����
  331. if self.my_country_exploit_rank_num > 5 then
  332. if #self.click_worship_role_list < 5 then
  333. bool = true
  334. end
  335. else
  336. if #self.click_worship_role_list < self.my_country_exploit_rank_num then
  337. bool = true
  338. end
  339. end
  340. return bool
  341. end
  342. --Ԥ�潱������
  343. function CSMainModel:GetNoticeRewardRed( )
  344. return self.cs_main_red_info[CSMainConst.RedType.NoticeReward]
  345. end
  346. function CSMainModel:CheckNoticeRewardRed( )
  347. local bool = false
  348. --����Ԥ���׶����н����������Ը�����
  349. local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
  350. local _,cfg = GetModuleIsOpen(603)
  351. local left_day = cfg.open_day-openDay
  352. local open_lv = GetModuleOpenLevel(603)
  353. local is_kf_num_enough, is_kf_state = CSMainModel:getInstance():IsCSMainKfNumEnough()
  354. if open_lv <= RoleManager.Instance.mainRoleInfo.level and left_day <= 0 and is_kf_state and is_kf_num_enough then
  355. bool = false
  356. else
  357. local now_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
  358. for i=1,now_day do
  359. local can_get_reward = self:CanDayGetCSMainAdvanceNoticeReward(i)
  360. if can_get_reward then
  361. bool = true
  362. break
  363. end
  364. end
  365. end
  366. return bool and RoleManager.Instance.mainRoleInfo.level >= 96
  367. end
  368. ------------------����----end
  369. --����ָ����������ˢ��
  370. function CSMainModel:UpdateCSMainMilitaryAdvanceCostNum( )
  371. self:Fire(CSMainConst.UPDATE_CS_MAIN_GOODS_NUM)
  372. end
  373. --60300 ָ��������figure��Ϣ
  374. function CSMainModel:SetCSMainDirectorData(vo)
  375. for i=1,7 do
  376. self.director_role_data[i] = {}
  377. self.director_role_data[i].pos = i
  378. self.director_role_data[i].rid = 0
  379. end
  380. for k,v in pairs(vo.director_role) do
  381. self.director_role_data[v.pos] = v
  382. end
  383. end
  384. --60306 ��������ˢ�µ�����figure��Ϣ
  385. function CSMainModel:UpdateCSMainDirectorData(vo)
  386. local change_pos = 0
  387. for k,v in pairs(self.director_role_data) do
  388. if v.rid == vo.role_id then
  389. change_pos = v.pos
  390. break
  391. end
  392. end
  393. if change_pos ~= 0 then
  394. self.director_role_data[change_pos] = vo
  395. self.director_role_data[change_pos].pos = change_pos
  396. self.director_role_data[change_pos].rid = vo.role_id
  397. end
  398. end
  399. --����λ�û�ȡ����figure��Ϣ
  400. function CSMainModel:GetCSMainDirectorDataByPos(pos)
  401. return self.director_role_data[pos]
  402. end
  403. --60301 ����������
  404. function CSMainModel:SetCSMainTaskData(vo)
  405. self.active_process = vo.process--��Ծ����
  406. self.arms_num = vo.arms--����ֵ
  407. self.active_dot_list = vo.dot_list
  408. local sort_func = function ( a, b )
  409. return a.hot < b.hot
  410. end
  411. table.sort(self.active_dot_list, sort_func)
  412. self.active_dot = self:SetCSMainActiveDot(self.active_dot_list)--��ǰ��ȡ����
  413. self.military_ranks = vo.post--����
  414. self.exploit_rank_score = vo.rank_score--�����
  415. self:ChangeVar("active_process", self.active_process, false, true)
  416. self:ChangeVar("active_dot", self.active_dot, false, true)
  417. self:ChangeVar("arms_num", self.arms_num, false, true)
  418. self:ChangeVar("exploit_rank_score", self.exploit_rank_score, false, true)
  419. for k,v in pairs(vo.missions) do
  420. self.cs_main_task_data[v.id] = v
  421. end
  422. end
  423. function CSMainModel:TestActiveDotList( )
  424. self.active_dot_list = {
  425. {hot = 1},
  426. {hot = 2},
  427. {hot = 3},
  428. {hot = 4},
  429. {hot = 5},
  430. {hot = 6},
  431. -- {hot = 8},
  432. -- {hot = 10},
  433. }
  434. self.active_dot = self:SetCSMainActiveDot(self.active_dot_list)--��ǰ��ȡ����
  435. Message.show(self.active_dot)
  436. self:ChangeVar("active_dot", self.active_dot, false, true)
  437. end
  438. --������Ծ������ȡ���ȣ������ж�����һҳ��Ծ��
  439. function CSMainModel:SetCSMainActiveDot(vo)
  440. local last_dot = 0
  441. for i,v in ipairs(vo) do
  442. if last_dot == v.hot - 1 then
  443. last_dot = v.hot
  444. else
  445. return last_dot
  446. end
  447. end
  448. return last_dot
  449. end
  450. --60304 ��ȡ������������Ծ������ˢ������
  451. function CSMainModel:SetCSMainGetRewardData(vo)
  452. if vo.opty == 0 then--��Ծ
  453. local have_same = false
  454. for k,v in pairs(self.active_dot_list) do
  455. if v.hot == vo.args then
  456. have_same = true
  457. end
  458. end
  459. if not have_same then
  460. local temp = {hot = vo.args}
  461. table.insert(self.active_dot_list,temp)
  462. end
  463. local sort_func = function ( a, b )
  464. return a.hot < b.hot
  465. end
  466. table.sort(self.active_dot_list, sort_func)
  467. self.active_dot = self:SetCSMainActiveDot(self.active_dot_list)--��ǰ��ȡ����
  468. self:ChangeVar("active_dot", self.active_dot, false, true)
  469. elseif vo.opty == 1 then--����
  470. end
  471. end
  472. --�жϸû�Ծ�ڵ㽱���Ƿ��Ѿ���ȡ��
  473. function CSMainModel:IsCSMainActiveDotRewardGet(dot)
  474. local bool = false
  475. for k,v in pairs(self.active_dot_list) do
  476. if dot == v.hot then
  477. bool = true
  478. end
  479. end
  480. return bool
  481. end
  482. --60302 ��������
  483. function CSMainModel:UpdateCSMainTaskData(vo)
  484. self.cs_main_task_data[vo.id] = self.cs_main_task_data[vo.id] or {}
  485. self.cs_main_task_data[vo.id].id = vo.id
  486. self.cs_main_task_data[vo.id].bar = vo.bar
  487. self.cs_main_task_data[vo.id].state = vo.state
  488. end
  489. function CSMainModel:Test60303( )
  490. local vo = {
  491. updatas = {
  492. [1] = {kdata=1,vdata=550},
  493. }
  494. }
  495. self:UpdateCSMainKeyValue(vo)
  496. end
  497. --60303 ָ��ֵ����
  498. function CSMainModel:UpdateCSMainKeyValue(vo)
  499. for k,v in pairs(vo.updatas) do
  500. if v.kdata == 1 then--process��Ծ����
  501. self.active_process = v.vdata
  502. self:ChangeVar("active_process", self.active_process, false, true)
  503. -- elseif v.kdata == 2 then--dot��ǰ��ȡ����
  504. -- self.active_dot = v.vdata
  505. -- self:ChangeVar("active_dot", self.active_dot, false, true)
  506. elseif v.kdata == 3 then--arms����ֵ
  507. self.arms_num = v.vdata
  508. self:ChangeVar("arms_num", self.arms_num, false, true)
  509. -- elseif v.kdata == 4 then--score����(û��������)
  510. -- self.exploit_score = v.vdata
  511. -- self:ChangeVar("exploit_score", self.exploit_score, false, true)
  512. elseif v.kdata == 5 then--score�����
  513. self.exploit_rank_score = v.vdata
  514. self:ChangeVar("exploit_rank_score", self.exploit_rank_score, false, true)
  515. end
  516. end
  517. end
  518. --��ȡ��ǰ��Ծ����
  519. function CSMainModel:GetCSMainActiveProcess( )
  520. return self.active_process
  521. end
  522. --��ȡ��ǰ��Ծ��ȡ����
  523. function CSMainModel:GetCSMainActiveDot( )
  524. return self.active_dot
  525. end
  526. --��ȡ��ǰ����ֵ
  527. function CSMainModel:GetCSMainArmsNum( )
  528. return self.arms_num
  529. end
  530. --��ȡ��ǰ����
  531. function CSMainModel:GetCSMainMilitaryRanks( )
  532. return self.military_ranks
  533. end
  534. --���ݾ����жϴ����εȼ������ڻ�ȡ������ͼ��
  535. function CSMainModel:GetCSMainHighMilitaryRanks(ranks)
  536. if ranks == 0 then return 1 end
  537. return math.floor((ranks-1)/5)+1
  538. end
  539. --��ȡ��ǰ���о���
  540. function CSMainModel:GetCSMainExploitRankScore( )
  541. return self.exploit_rank_score
  542. end
  543. --��ȡָ��id������
  544. function CSMainModel:GetCSMainTaskDataById(task_id)
  545. return self.cs_main_task_data[task_id] and self.cs_main_task_data[task_id] or nil
  546. end
  547. --60305 ���ν��׸�������
  548. function CSMainModel:UpdateCSMainMilitaryRanksData(vo)
  549. self.military_ranks = vo.post
  550. end
  551. --60308 �񵥽����������ݸ��� Ĥ�����ҡ�ǰ��������ÿ�ս�����ȡ״̬��
  552. function CSMainModel:UpdateCSMainExploitData(vo)
  553. -- self.click_worship_role = vo.click_role--��Ĥ������
  554. self.click_worship_role_list = vo.click_list--��Ĥ�������б�
  555. -- self.click_worship_role_list = {}
  556. self.my_exploit_last_rank = vo.last_rank--ǰ������
  557. self.my_day_reward_state = vo.day_award--��ȡ״̬1����ȡ
  558. for i,v in ipairs(self.exploit_rank_reward_cfg) do
  559. v.is_top = 0
  560. if v.min_rank <= self.my_exploit_last_rank and v.max_rank >= self.my_exploit_last_rank then
  561. if self.my_day_reward_state == 0 then
  562. v.is_top = 1
  563. end
  564. end
  565. end
  566. end
  567. --60310 ˢ�½�����ȡ״̬Ϊ��ȡ��
  568. function CSMainModel:UpdateRankRewardState( )
  569. for i,v in ipairs(self.exploit_rank_reward_cfg) do
  570. v.is_top = 0
  571. end
  572. self.my_day_reward_state = 1
  573. end
  574. --��ȡ���������н�������
  575. function CSMainModel:GetCSMainSortExploitRankRewardCfg( )
  576. local arg = {"is_top","id"}
  577. local condition = {Array.UPPER,Array.LOWER}
  578. SortTools.MoreKeysSorter(self.exploit_rank_reward_cfg, arg, condition)
  579. return self.exploit_rank_reward_cfg
  580. end
  581. --��ȡ����ǰ��Ĥ�ݵ�����id
  582. function CSMainModel:GetCSMainClickWorshipRole( )
  583. return self.click_worship_role
  584. end
  585. --�жϵ�ǰ�����Ƿ�����Ĥ��
  586. function CSMainModel:CanPlayerWorship(role_id)
  587. local can_worship = true
  588. local max_worship_num = 5
  589. if self.my_country_exploit_rank_num < 5 then
  590. max_worship_num = self.my_country_exploit_rank_num
  591. end
  592. if #self.click_worship_role_list >= max_worship_num then
  593. return false
  594. end
  595. for k,v in pairs(self.click_worship_role_list) do
  596. if v.click_role == role_id then
  597. can_worship = false
  598. end
  599. end
  600. return can_worship
  601. end
  602. --��ȡ�Լ�ǰ�յľ�������
  603. function CSMainModel:GetCSMainMyExploitLastRank( )
  604. return self.my_exploit_last_rank
  605. end
  606. --ǰ�վ������������Ƿ�����ȡ
  607. function CSMainModel:CanGetCSMainExploitDailyReward( )
  608. return self.my_day_reward_state == 1
  609. end
  610. --60309 Ĥ�ݺ�ˢ��
  611. function CSMainModel:UpdateCSMainClickWorshipRole(vo)
  612. local can_join = true
  613. for k,v in pairs(self.click_worship_role_list) do
  614. if v.click_role == vo.aim then
  615. can_join = false
  616. end
  617. end
  618. if can_join then
  619. local temp = {click_role = vo.aim}
  620. table.insert(self.click_worship_role_list,temp)
  621. end
  622. end
  623. --60314 �������ڿ�����ս�ɼ�����
  624. function CSMainModel:SetLastGuildWarScoreRankData(vo)
  625. self.last_guild_war_rank_data = vo.ranks
  626. local max_rank_num = self:GetCSMainChaimanMaxRank()
  627. --��������50����������
  628. for i=#self.last_guild_war_rank_data+1, max_rank_num do
  629. local temp = {rank = i, empty_data = true}
  630. table.insert(self.last_guild_war_rank_data,temp)
  631. end
  632. local sort_func = function ( a, b )
  633. return a.rank < b.rank
  634. end
  635. table.sort(self.last_guild_war_rank_data, sort_func)
  636. self.has_request_60314 = true
  637. end
  638. --��ȡ���ڿ�����ս�ɼ�����
  639. function CSMainModel:GetLastGuildWarScoreRankData( )
  640. return self.last_guild_war_rank_data
  641. end
  642. --60311 �������ھ����ɼ�����
  643. function CSMainModel:SetLastMilitaryScoreRankData(vo)
  644. self.last_military_score_rank_data = vo.ranks
  645. local max_rank_num = self:GetCSMainCommanderMaxRank()
  646. --��������50����������
  647. for i=#self.last_military_score_rank_data+1, max_rank_num do
  648. local temp = {rank = i, empty_data = true}
  649. table.insert(self.last_military_score_rank_data,temp)
  650. end
  651. local sort_func = function ( a, b )
  652. return a.rank < b.rank
  653. end
  654. table.sort(self.last_military_score_rank_data, sort_func)
  655. self.has_request_60311 = true
  656. end
  657. --��ȡ���ڿ�����ս�ɼ�����
  658. function CSMainModel:GetLastMilitaryScoreRankData( )
  659. return self.last_military_score_rank_data
  660. end
  661. --60312 ��ʷ��������
  662. function CSMainModel:SetAppointData(vo)
  663. local final_time_logs = {}
  664. for k,v in pairs(vo.time_logs) do
  665. local can_join = true
  666. for m,n in pairs(v.servers) do
  667. if #n.directors == 0 then
  668. can_join = false
  669. end
  670. end
  671. if can_join then
  672. table.insert(final_time_logs,v)
  673. end
  674. end
  675. self["appoint_data_"..vo.opty] = final_time_logs
  676. local sort_func = function ( a, b )
  677. return a.issue > b.issue
  678. end
  679. table.sort(self["appoint_data_"..vo.opty], sort_func)
  680. end
  681. --��ȡ��������
  682. function CSMainModel:GetAppointData(appoint_type)
  683. return self["appoint_data_"..appoint_type] and self["appoint_data_"..appoint_type] or {}
  684. end
  685. --60307 ��¼�ҵĹ��Ҿ�����������
  686. function CSMainModel:SetMyCountryExploitRankNum(vo)
  687. local my_contray_id = KfWorldModel:GetInstance():GetMyCountryId()
  688. if my_contray_id and my_contray_id == vo.fact then
  689. if vo and vo.ranks then
  690. self.my_country_exploit_rank_num = #vo.ranks
  691. end
  692. end
  693. end
  694. --�Ƿ��ﵽ�����ȼ�
  695. function CSMainModel:IsCSMainKfNumEnough( )
  696. -- local world_lv = RoleManager.Instance.mainRoleInfo.worldLv
  697. -- local need_world_lv = 999
  698. -- return world_lv >= need_world_lv
  699. local tip_info = KfWorldModel:GetInstance():GetKfWorldTipInfo()
  700. if not tip_info or TableSize(tip_info) < 1 then return false end
  701. local kf_num = math.pow(2, tip_info.next_stage-1)
  702. local enough_kf_num = kf_num >= 4
  703. local is_kf_state = true
  704. local info = KfWorldModel:GetInstance():GetKfWorldInfo()
  705. if IsTableEmpty(info) then
  706. is_kf_state = false
  707. end
  708. if info.stage and info.stage == 0 then
  709. is_kf_state = false
  710. end
  711. return enough_kf_num, is_kf_state
  712. end
  713. --60315 Ԥ�潱����ȡ����
  714. function CSMainModel:SetCSMainAdvanceNoticeRewardData(vo)
  715. self.advance_notice_reward_data = vo.lists
  716. end
  717. --60316 ����Ԥ�潱����ȡ����
  718. function CSMainModel:UpdateCSMainAdvanceNoticeRewardData(vo)
  719. local has_same_day = false
  720. for k,v in pairs(self.advance_notice_reward_data) do
  721. if v.day == vo.day then
  722. has_same_day = true
  723. break
  724. end
  725. end
  726. if not has_same_day then
  727. local temp = {day = vo.day}
  728. table.insert(self.advance_notice_reward_data,temp)
  729. end
  730. end
  731. --��ȡԤ�潱������
  732. function CSMainModel:GetCSMainAdvanceNoticeRewardData( )
  733. return self.advance_notice_reward_data
  734. end
  735. --�ж�ij���Ľ����Ƿ�������ȡ
  736. function CSMainModel:CanDayGetCSMainAdvanceNoticeReward(day)
  737. if day <= 0 then return false end
  738. local _,cfg = GetModuleIsOpen(603)
  739. if cfg.open_day == day then return false end
  740. local can_get_reward = true
  741. for k,v in pairs(self.advance_notice_reward_data) do
  742. if v.day == day then
  743. can_get_reward = false
  744. break
  745. end
  746. end
  747. local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
  748. local enough_day = day <= openDay
  749. return can_get_reward and enough_day
  750. end
  751. --�ж�ij��֮ǰ��֮���Ƿ��н���������ȡ day_type 1|֮ǰ 2|֮��
  752. function CSMainModel:CanDayGetCSMainAdvanceNoticeRewardBeforeOrAfter(day,day_type)
  753. local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
  754. local _,cfg = GetModuleIsOpen(603)
  755. local max_show_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
  756. local bool = false
  757. if day_type == 1 then
  758. for i=1,day-1 do
  759. if self:CanDayGetCSMainAdvanceNoticeReward(i) then
  760. bool = true
  761. break
  762. end
  763. end
  764. elseif day_type == 2 then
  765. for i=day+1,max_show_day do
  766. if self:CanDayGetCSMainAdvanceNoticeReward(i) then
  767. bool = true
  768. break
  769. end
  770. end
  771. end
  772. return bool
  773. end