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

215 lines
7.9 KiB

  1. -- require("game.proto.416.Require416")
  2. require("game.mobilization.MobilizationModel")
  3. require("game.mobilization.view.MobilizationView")--全民动员主界面
  4. require("game.mobilization.view.MobilizationTab")--全民动员主界面tab
  5. require("game.mobilization.view.MobilizationSubTab")--全民动员主界面tab
  6. require("game.mobilization.view.MobilizationItem")--全民动员子界面item
  7. require("game.mobilization.view.MobilizationGroupBuyingItem")--全民动员系列界面item
  8. require("game.mobilization.view.MobilizationGroupBuyingDiscountItem")--全民动员系列界面打折和购买人数item
  9. MobilizationController = MobilizationController or BaseClass(BaseController)
  10. MobilizationController.Is_Debug = false
  11. function MobilizationController:__init()
  12. MobilizationController.Instance = self
  13. self.model = MobilizationModel:getInstance()
  14. self.mainVo = RoleManager.Instance.mainRoleInfo
  15. self:RegisterAllProtocals()
  16. self:AddAllEvents()
  17. end
  18. function MobilizationController:__delete()
  19. end
  20. function MobilizationController:AddAllEvents()
  21. local function game_start_func()
  22. end
  23. GlobalEventSystem:Bind(EventName.GAME_START,game_start_func)
  24. -- local function CheckRedPoint( ... )
  25. -- end
  26. -- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func)
  27. local onOpenMobilizationView = function (sub_type,day,is_close)
  28. if not GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.MOBILIZATION) then return end
  29. sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(CustomActivityModel.CustomActBaseType.MOBILIZATION)
  30. local open_bool = self.model:CheckActOpen(sub_type)--是否开启
  31. if not open_bool then
  32. Message.show("活动未开启","fault")
  33. return
  34. end
  35. self:OpenView("MobilizationView",not is_close,sub_type,day)
  36. -- 检查一下是否需要展示宣传图 并展示
  37. AdvertisementModel:getInstance():CheckAndShowActivityAd( CustomActivityModel.CustomActBaseType.MOBILIZATION )
  38. end
  39. GlobalEventSystem:Bind(MobilizationModel.OPEN_MOBILIZATION_VIEW, onOpenMobilizationView)
  40. local function request_info(request_id , ... )
  41. if not MobilizationController.Is_Debug then
  42. local fun_name = string.format("send%s",request_id)
  43. if self[fun_name] then
  44. print('----in MobilizationController.lua,line 53 request_id',request_id , ...)
  45. self[fun_name](self,...)
  46. end
  47. elseif request_id == 33225 then
  48. local fun_name = string.format("Handler%s",request_id)
  49. if self[fun_name] then
  50. print('----in MobilizationController.lua,line 59 request_idIs_Debug',request_id , ...)
  51. self[fun_name](self,...)
  52. end
  53. end
  54. end
  55. self.model:Bind(MobilizationModel.REQUEST_INFO,request_info)
  56. local function init_open_day( ... )--开服天数初始化
  57. -- self.model:checkRuneIconBoolOpen()
  58. end
  59. GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
  60. --升级
  61. local function onLevelUp(level)
  62. if Config.Modulesub["331@71"].open_lv == level then
  63. local base_type = CustomActivityModel.CustomActBaseType.MOBILIZATION
  64. local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
  65. if act_list then
  66. for i,v in ipairs(act_list) do
  67. self.model:CheckIconBoolOpen(v.sub_type)
  68. end
  69. end
  70. end
  71. end
  72. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  73. local function chnage_day_func(type)
  74. if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
  75. local base_type = CustomActivityModel.CustomActBaseType.MOBILIZATION
  76. local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
  77. if act_list then
  78. for i,v in pairs(act_list) do
  79. MobilizationModel:getInstance():Fire(MobilizationModel.REQUEST_INFO,33225,v.sub_type)
  80. self.model:CheckIconBoolOpen(v.sub_type)
  81. end
  82. end
  83. local base_type = CustomActivityModel.CustomActBaseType.KF_GROUP_BUYING
  84. local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
  85. if act_list then
  86. for i,v in pairs(act_list) do
  87. for ii,vv in ipairs(v.condition_list) do
  88. if vv[1] == "custom_act" and tonumber(vv[2]) == 71 then
  89. MobilizationModel:getInstance():Fire(MobilizationModel.REQUEST_INFO,33225,tonumber(vv[3]))
  90. break
  91. end
  92. end
  93. end
  94. end
  95. end
  96. end
  97. GlobalEventSystem:Bind(EventName.CHANE_DAY, chnage_day_func)
  98. local function onSceneStartHandler()
  99. if self.model.need_load_scene_open_view then
  100. -- GlobalEventSystem:Fire(MobilizationModel.OPEN_MERCENARY_SUPPLY_VIEW,self.model.need_load_scene_open_view)
  101. self.model.need_load_scene_open_view = nil
  102. end
  103. end
  104. self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
  105. end
  106. function MobilizationController:RegisterAllProtocals()
  107. self:RegisterProtocal(33225, "Handler33225")--查询全民动员
  108. self:RegisterProtocal(33226, "Handler33226")--全民动员 奖励领取
  109. self:RegisterProtocal(33227, "Handler33227")--全民动员 日奖励领取
  110. end
  111. -- ########## 查询全民动员 ###########
  112. -- protocol=33225
  113. -- {
  114. -- c2s{
  115. -- sub_type :int16 // 活动子类型
  116. -- }
  117. -- s2c{
  118. -- sub_type :int16 // 活动子类型
  119. -- list:array{ // 每日任务状态列表
  120. -- start_day :int16 // 开始天数
  121. -- end_day :int16 // 结束天数
  122. -- total :int16 // 大奖进度
  123. -- total_state :int8 // 0:未完成 1:可领取 2:已完成
  124. -- task_list:array{ // 任务列表
  125. -- task_type :int16 // 任务类型id
  126. -- id :int16 // 任务id
  127. -- server_pro :int32 // 全服进度
  128. -- person_pro :int32 // 个人进度
  129. -- finish_pro :int8 // 领取条件0未完成1完成
  130. -- state :int8 // 0:未完成 1:可领取 2:已完成
  131. -- }
  132. -- }
  133. -- }
  134. -- }
  135. function MobilizationController:send33225(sub_type)
  136. self:SendFmtToGame(33225,"h",sub_type)
  137. end
  138. function MobilizationController:Handler33225()
  139. local vo = SCMD33225.New(true)
  140. self.model:SetMobilizationInfo(vo)
  141. self.model:Fire(MobilizationModel.UPDATE_MOBILIZATION_VIEW,vo.sub_type)
  142. self.model:CheckIconBoolOpen(vo.sub_type)
  143. end
  144. -- ########## 全民动员 奖励领取 ###########
  145. -- protocol=33226
  146. -- {
  147. -- c2s{
  148. -- sub_type :int16 // 活动子类型
  149. -- task_type :int16 // 任务类型id
  150. -- id :int16 // 任务id
  151. -- }
  152. -- s2c{
  153. -- sub_type :int16 // 活动子类型
  154. -- res :int32 // 返回码(1即成功否则返回错误码)
  155. -- }
  156. -- }
  157. function MobilizationController:send33226(sub_type,task_type,id)
  158. self:SendFmtToGame(33226,"hhh",sub_type,task_type,id)
  159. end
  160. function MobilizationController:Handler33226()
  161. local scmd = SCMD33226.New(true)
  162. if scmd.res == 1 then
  163. Message.show("领取成功","success")
  164. self.model:Fire(MobilizationModel.REQUEST_INFO,33225,scmd.sub_type)
  165. else
  166. ErrorCodeShow(scmd.res)
  167. end
  168. end
  169. -- ########## 全民动员 天数奖励领取 ###########
  170. -- protocol=33227
  171. -- {
  172. -- c2s{
  173. -- sub_type :int16 // 活动子类型
  174. -- start_day :int16 // 开始天
  175. -- end_day :int16 // 结算天
  176. -- }
  177. -- s2c{
  178. -- sub_type :int16 // 活动子类型
  179. -- res :int32 // 返回码(1即成功否则返回错误码)
  180. -- }
  181. -- }
  182. function MobilizationController:send33227(sub_type,start_day,end_day)
  183. self:SendFmtToGame(33227,"hhh",sub_type,start_day,end_day)
  184. end
  185. function MobilizationController:Handler33227()
  186. local scmd = SCMD33227.New(true)
  187. if scmd.res == 1 then
  188. Message.show("领取成功","success")
  189. self.model:Fire(MobilizationModel.REQUEST_INFO,33225,scmd.sub_type)
  190. else
  191. ErrorCodeShow(scmd.res)
  192. end
  193. end