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

418 lines
12 KiB

пре 1 месец
  1. require("game.proto.407.Require407")
  2. require("game.guildSpeedAct.GuildSpeedModel")
  3. require("game.guildSpeedAct.view.GuildSpeedBaseView")--公会竞速主界面
  4. require("game.guildSpeedAct.view.GuildSpeedRankItem")--公会竞速rankitem
  5. require("game.guildSpeedAct.view.GuildSpeedGuildRankItem")--公会竞速Guildrankitem
  6. require("game.guildSpeedAct.view.GuildSpeedTaskItem")--公会竞速任务item
  7. require("game.guildSpeedAct.view.GuildSpeedTabItem")--页签
  8. GuildSpeedController = GuildSpeedController or BaseClass(BaseController)
  9. GuildSpeedController.Is_Debug = false
  10. function GuildSpeedController:__init()
  11. GuildSpeedController.Instance = self
  12. self.model = GuildSpeedModel:getInstance()
  13. self.mainVo = RoleManager.Instance.mainRoleInfo
  14. self:RegisterAllProtocals()
  15. self:AddAllEvents()
  16. end
  17. function GuildSpeedController:__delete()
  18. end
  19. function GuildSpeedController:AddAllEvents()
  20. local function game_start_func()
  21. end
  22. GlobalEventSystem:Bind(EventName.GAME_START,game_start_func)
  23. local function onSceneStartHandler()
  24. if not self.is_login_load then
  25. self.is_login_load = true
  26. local all_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.GUILD_SPEED) or {}
  27. local server_time = TimeUtil:getServerTime()
  28. for k,v in pairs(all_list) do
  29. if server_time > v.stime and v.etime > server_time then
  30. if GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.GUILD_SPEED) then
  31. GuildSpeedModel:getInstance():Fire(GuildSpeedModel.REQUEST_INFO,40702)--开局游戏请求
  32. GuildSpeedModel:getInstance():Fire(GuildSpeedModel.REQUEST_INFO,40706)--开局游戏请求
  33. break
  34. end
  35. end
  36. end
  37. end
  38. end
  39. self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
  40. -- local function CheckRedPoint( ... )
  41. -- end
  42. -- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func)
  43. local onOpenGuildSpeedBaseView = function ()
  44. if self.GuildSpeedBaseView == nil then
  45. self.GuildSpeedBaseView = GuildSpeedBaseView.New()
  46. end
  47. if self.GuildSpeedBaseView:HasOpen() then
  48. self.GuildSpeedBaseView:UpdateView(base_type,sub_type)
  49. else
  50. self.GuildSpeedBaseView:Open(base_type,sub_type)
  51. end
  52. end
  53. GlobalEventSystem:Bind(GuildSpeedModel.OPEN_GUILD_SPEED_VIEW, onOpenGuildSpeedBaseView)
  54. local function onTaskFinishHandler(taskId)
  55. if taskId == Config.Modulesub["331@66"].task_id then
  56. self.model:CheckIconBoolOpen()
  57. end
  58. end
  59. GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST, onTaskFinishHandler)
  60. -- local function onSendCmdFunc( ... )
  61. -- local args_list = {...}
  62. -- self:SendFmtToGame(args_list[1])
  63. -- end
  64. -- self.model:Bind(GuildSpeedModel.REQUEST_INFO, onSendCmdFunc)
  65. local function request_info(request_id , ... )
  66. if not GuildSpeedController.Is_Debug then
  67. local fun_name = string.format("send%s",request_id)
  68. if self[fun_name] then
  69. print('----in GuildSpeedController.lua,line 44 request_id',request_id , ...)
  70. self[fun_name](self,...)
  71. end
  72. elseif request_id == 40702 then
  73. local fun_name = string.format("handle%s",request_id)
  74. if self[fun_name] then
  75. print('----in GuildSpeedController.lua,line 96 request_idIs_Debug',request_id , ...)
  76. self[fun_name](self,...)
  77. end
  78. end
  79. end
  80. self.model:Bind(GuildSpeedModel.REQUEST_INFO,request_info)
  81. local function init_open_day( ... )--开服天数初始化
  82. -- self.model:Fire(GuildSpeedModel.REQUEST_INFO,40700)
  83. -- self.model:Fire(GuildSpeedModel.REQUEST_INFO,40701)
  84. end
  85. GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
  86. local function chnage_day_func(type)
  87. if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
  88. local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
  89. if open_day == 8 then
  90. for i=1,4 do
  91. self.model:Fire(GuildSpeedModel.REQUEST_INFO,40704,i)
  92. end
  93. end
  94. end
  95. end
  96. GlobalEventSystem:Bind(EventName.CHANE_DAY, chnage_day_func)
  97. --升级
  98. local function onLevelUp(level)
  99. if level == Config.Modulesub["331@66"].open_lv then
  100. for i=1,4 do
  101. self.model:Fire(GuildSpeedModel.REQUEST_INFO,40704,i)
  102. end
  103. end
  104. end
  105. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  106. end
  107. function GuildSpeedController:RegisterAllProtocals()
  108. self:RegisterProtocal(40700, "handle40700") -- 社团榜信息
  109. self:RegisterProtocal(40701, "handle40701") -- 个人榜信息
  110. self:RegisterProtocal(40702, "handle40702") -- 奖励推送提示
  111. self:RegisterProtocal(40703, "handle40703") -- 社团活跃榜信息
  112. self:RegisterProtocal(40704, "handle40704") -- 奖励领取情况
  113. self:RegisterProtocal(40705, "handle40705") -- 领取奖励
  114. self:RegisterProtocal(40706, "handle40706") -- 团长任务信息
  115. self:RegisterProtocal(40707, "handle40707") -- 领取团长任务奖励
  116. end
  117. -- ############## 社团榜信息 ##############
  118. -- protocol=40700
  119. -- {
  120. -- c2s{}
  121. -- s2c{
  122. -- guild_list:array{
  123. -- rank :int8 // 排名
  124. -- guild_id :int64 // 公会Id
  125. -- guild_name :string // 社团名称
  126. -- captain_name:string // 团长名称
  127. -- mem_number :int8 // 成员数量
  128. -- mem_limit :int8 // 成员上限
  129. -- sum_power :int64 // 总战力
  130. -- old_rank :int8 // 旧排名
  131. -- }
  132. -- my_guild_rank :int8 // 本社团排行
  133. -- }
  134. -- }
  135. function GuildSpeedController:send40700()
  136. self:SendFmtToGame(40700)
  137. end
  138. function GuildSpeedController:handle40700()
  139. local scmd = {}
  140. if not GuildSpeedController.Is_Debug then
  141. scmd = SCMD40700.New(true)
  142. else
  143. scmd.guild_list = {}
  144. for i=1,20 do
  145. local guild_data = {
  146. rank = i,
  147. guild_name = "别人家的公会",
  148. captain_name = "会长名字六个字",
  149. guild_id = i,
  150. mem_number = 50,
  151. mem_limit = 50,
  152. sum_power = 1000000 - i*10000,
  153. }
  154. if i <= 3 then
  155. scmd.old_rank = i
  156. else
  157. scmd.old_rank = 0
  158. end
  159. scmd.guild_list[#scmd.guild_list + 1] = guild_data
  160. end
  161. scmd.my_guild_rank = 2
  162. end
  163. -- print("huangcong:GuildSpeedController [89]: ",scmd)
  164. -- PrintTable(scmd)
  165. self.model.my_guild_rank = scmd.my_guild_rank
  166. self.model:SetGuildRankInfo(scmd.guild_list)
  167. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW)
  168. end
  169. -- ############## 个人榜信息 ##############
  170. -- protocol=40701
  171. -- {
  172. -- c2s{}
  173. -- s2c{
  174. -- rank_list:array{
  175. -- rank :int8 // 排名
  176. -- role_id :int64 // 角色Id
  177. -- role_name :string // 玩家名称
  178. -- power :int64 // 战力
  179. -- position :int8 // 职位
  180. -- vip_flag :int8 //vip等级
  181. -- sup_vip_type:int8 //贵族类型
  182. -- }
  183. -- my_rank :int8 // 个人排行
  184. -- }
  185. -- }
  186. function GuildSpeedController:send40701()
  187. self:SendFmtToGame(40701)
  188. end
  189. function GuildSpeedController:handle40701()
  190. local scmd = {}
  191. if not GuildSpeedController.Is_Debug then
  192. scmd = SCMD40701.New(true)
  193. else
  194. scmd.rank_list = {}
  195. for i=1,50 do
  196. local rank_data = {
  197. rank = i,
  198. role_id = i*10086,
  199. role_name = "名字有六个字",
  200. power = 1000000 - i * 10000
  201. }
  202. if i <= 5 then
  203. rank_data.position = i
  204. else
  205. rank_data.position = 5
  206. end
  207. if 15 - i > 0 then
  208. rank_data.vip_flag = 15-i
  209. rank_data.sup_vip_type = math.floor((15-i)/3)
  210. else
  211. rank_data.vip_flag = 0
  212. rank_data.sup_vip_type = 0
  213. end
  214. scmd.rank_list[#scmd.rank_list + 1] = rank_data
  215. end
  216. scmd.my_rank = 2
  217. end
  218. -- print("huangcong:GuildSpeedController [186]: ",scmd)
  219. -- PrintTable(scmd)
  220. self.model.my_rank = scmd.my_rank
  221. self.model:SetRankInfo(scmd.rank_list)
  222. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Fight)
  223. end
  224. -- ############## 奖励推送提示 ##############
  225. -- protocol=40702
  226. -- {
  227. -- c2s{}
  228. -- s2c{
  229. -- rank :int8 // 排行
  230. -- goods_id :int32 // 奖励id
  231. -- }
  232. -- }
  233. function GuildSpeedController:send40702()
  234. self:SendFmtToGame(40702)
  235. end
  236. function GuildSpeedController:handle40702()
  237. local scmd = {}
  238. if not GuildSpeedController.Is_Debug then
  239. scmd = SCMD40702.New(true)
  240. else
  241. scmd.rank = 2
  242. scmd.goods_id = 433018
  243. end
  244. -- print("huangcong:GuildSpeedController [255]: ",scmd)
  245. -- PrintTable(scmd)
  246. if scmd.goods_id ~= 0 then
  247. GlobalEventSystem:Fire(AchieveModel.OPEN_GUILD_SPEED_TIP_VIEW,scmd)
  248. end
  249. end
  250. -- ############## 社团活跃榜信息 ##############
  251. -- protocol=40703
  252. -- {
  253. -- c2s{}
  254. -- s2c{
  255. -- guild_list:array{
  256. -- rank :int8 // 排名
  257. -- guild_id :int64 // 公会Id
  258. -- guild_name :string // 社团名称
  259. -- captain_name:string // 团长名称
  260. -- mem_number :int8 // 成员数量
  261. -- mem_limit :int8 // 成员上限
  262. -- sum_live :int32 // 总活跃值
  263. -- }
  264. -- my_live :int32 // 我的活跃值
  265. -- }
  266. -- }
  267. function GuildSpeedController:send40703()
  268. self:SendFmtToGame(40703)
  269. end
  270. function GuildSpeedController:handle40703()
  271. local scmd = SCMD40703.New(true)
  272. -- print("huangcong:GuildSpeedController [276]: ",scmd)
  273. -- PrintTable(scmd)
  274. self.model.my_live = scmd.my_live
  275. local my_guild_live_rank = 0
  276. local my_guild_id = RoleManager.Instance.mainRoleInfo.guild_id
  277. if my_guild_id and my_guild_id ~= 0 then
  278. for i,v in ipairs(scmd.guild_list) do
  279. if v.guild_id == my_guild_id then
  280. my_guild_live_rank = v.rank
  281. break
  282. end
  283. end
  284. end
  285. self.model.my_guild_live_rank = my_guild_live_rank
  286. self.model:SetActiveRankInfo(scmd.guild_list)
  287. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Active)
  288. end
  289. -- ############## 奖励领取情况 ##############
  290. -- protocol=40704
  291. -- {
  292. -- c2s{
  293. -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属
  294. -- }
  295. -- s2c{
  296. -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属
  297. -- is_receive :int8 // 是否已经领取 0-未领取 1-可领取 2-已领取
  298. -- }
  299. -- }
  300. function GuildSpeedController:send40704(type)
  301. self:SendFmtToGame(40704,"c",type)
  302. end
  303. function GuildSpeedController:handle40704()
  304. local scmd = SCMD40704.New(true)
  305. -- print("huangcong:GuildSpeedController [299]: ",scmd)
  306. -- PrintTable(scmd)
  307. self.model:SetTypeAwardInfo(scmd)
  308. local tab_refresh = scmd.type ~= 4 and scmd.type or GuildSpeedBaseView.TabId.Leader
  309. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,scmd.type)
  310. end
  311. -- ############## 领取奖励 ##############
  312. -- protocol=40705
  313. -- {
  314. -- c2s{
  315. -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属
  316. -- }
  317. -- s2c{
  318. -- res :int32 // 返回码
  319. -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属
  320. -- }
  321. -- }
  322. function GuildSpeedController:send40705(type)
  323. self:SendFmtToGame(40705,"c",type)
  324. end
  325. function GuildSpeedController:handle40705()
  326. local scmd = SCMD40705.New(true)
  327. if scmd.res == 1 then
  328. Message.show("领取成功","success")
  329. self.model:SetTypeAwardInfo({is_receive = 2,type = scmd.type})
  330. local tab_refresh_type = scmd.type ~= 4 and scmd.type or GuildSpeedBaseView.TabId.Leader
  331. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,tab_refresh_type)
  332. else
  333. ErrorCodeShow(scmd.res)
  334. end
  335. end
  336. -- ############## 团长任务信息 ##############
  337. -- protocol=40706
  338. -- {
  339. -- c2s{}
  340. -- s2c{
  341. -- task_list:array{
  342. -- task_id :int16 // 任务Id
  343. -- progress :int64 // 任务进度(包括战力任务)
  344. -- status :int8 // 任务状态 0-未完成 1-已完成 2-已领取
  345. -- }
  346. -- }
  347. -- }
  348. function GuildSpeedController:send40706()
  349. self:SendFmtToGame(40706)
  350. end
  351. function GuildSpeedController:handle40706()
  352. local scmd = SCMD40706.New(true)
  353. -- print("huangcong:GuildSpeedController [start:382] :", scmd)
  354. -- PrintTable(scmd)
  355. -- print("huangcong:GuildSpeedController [end]")
  356. self.model:SetTaskInfo(scmd)
  357. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Leader)
  358. end
  359. -- ############## 领取团长任务奖励 ##############
  360. -- protocol=40707
  361. -- {
  362. -- c2s{
  363. -- task_id :int16 // 任务Id
  364. -- }
  365. -- s2c{
  366. -- res :int32 // 返回码
  367. -- task_id :int16 // 任务Id
  368. -- progress :int64 // 任务进度(包括战力任务)
  369. -- status :int8 // 任务状态 0-未完成 1-已完成 2-已领取
  370. -- }
  371. -- }
  372. function GuildSpeedController:send40707(task_id)
  373. self:SendFmtToGame(40707,"h",task_id)
  374. end
  375. function GuildSpeedController:handle40707()
  376. local scmd = SCMD40707.New(true)
  377. if scmd.res == 1 then
  378. Message.show("领取成功","success")
  379. local task_info = self.model:GetTaskInfo(scmd.task_id)
  380. task_info.progress = scmd.progress
  381. task_info.status = scmd.status
  382. self.model:CheckMainIconRedDot()
  383. self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Leader)
  384. else
  385. ErrorCodeShow(scmd.res)
  386. end
  387. end