require("game.proto.407.Require407") require("game.guildSpeedAct.GuildSpeedModel") require("game.guildSpeedAct.view.GuildSpeedBaseView")--公会竞速主界面 require("game.guildSpeedAct.view.GuildSpeedRankItem")--公会竞速rankitem require("game.guildSpeedAct.view.GuildSpeedGuildRankItem")--公会竞速Guildrankitem require("game.guildSpeedAct.view.GuildSpeedTaskItem")--公会竞速任务item require("game.guildSpeedAct.view.GuildSpeedTabItem")--页签 GuildSpeedController = GuildSpeedController or BaseClass(BaseController) GuildSpeedController.Is_Debug = false function GuildSpeedController:__init() GuildSpeedController.Instance = self self.model = GuildSpeedModel:getInstance() self.mainVo = RoleManager.Instance.mainRoleInfo self:RegisterAllProtocals() self:AddAllEvents() end function GuildSpeedController:__delete() end function GuildSpeedController:AddAllEvents() local function game_start_func() end GlobalEventSystem:Bind(EventName.GAME_START,game_start_func) local function onSceneStartHandler() if not self.is_login_load then self.is_login_load = true local all_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.GUILD_SPEED) or {} local server_time = TimeUtil:getServerTime() for k,v in pairs(all_list) do if server_time > v.stime and v.etime > server_time then if GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.GUILD_SPEED) then GuildSpeedModel:getInstance():Fire(GuildSpeedModel.REQUEST_INFO,40702)--开局游戏请求 GuildSpeedModel:getInstance():Fire(GuildSpeedModel.REQUEST_INFO,40706)--开局游戏请求 break end end end end end self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler) -- local function CheckRedPoint( ... ) -- end -- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func) local onOpenGuildSpeedBaseView = function () if self.GuildSpeedBaseView == nil then self.GuildSpeedBaseView = GuildSpeedBaseView.New() end if self.GuildSpeedBaseView:HasOpen() then self.GuildSpeedBaseView:UpdateView(base_type,sub_type) else self.GuildSpeedBaseView:Open(base_type,sub_type) end end GlobalEventSystem:Bind(GuildSpeedModel.OPEN_GUILD_SPEED_VIEW, onOpenGuildSpeedBaseView) local function onTaskFinishHandler(taskId) if taskId == Config.Modulesub["331@66"].task_id then self.model:CheckIconBoolOpen() end end GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST, onTaskFinishHandler) -- local function onSendCmdFunc( ... ) -- local args_list = {...} -- self:SendFmtToGame(args_list[1]) -- end -- self.model:Bind(GuildSpeedModel.REQUEST_INFO, onSendCmdFunc) local function request_info(request_id , ... ) if not GuildSpeedController.Is_Debug then local fun_name = string.format("send%s",request_id) if self[fun_name] then print('----in GuildSpeedController.lua,line 44 request_id',request_id , ...) self[fun_name](self,...) end elseif request_id == 40702 then local fun_name = string.format("handle%s",request_id) if self[fun_name] then print('----in GuildSpeedController.lua,line 96 request_idIs_Debug',request_id , ...) self[fun_name](self,...) end end end self.model:Bind(GuildSpeedModel.REQUEST_INFO,request_info) local function init_open_day( ... )--开服天数初始化 -- self.model:Fire(GuildSpeedModel.REQUEST_INFO,40700) -- self.model:Fire(GuildSpeedModel.REQUEST_INFO,40701) end GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day) local function chnage_day_func(type) if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点 local open_day = ServerTimeModel:getInstance():GetOpenServerDay() if open_day == 8 then for i=1,4 do self.model:Fire(GuildSpeedModel.REQUEST_INFO,40704,i) end end end end GlobalEventSystem:Bind(EventName.CHANE_DAY, chnage_day_func) --升级 local function onLevelUp(level) if level == Config.Modulesub["331@66"].open_lv then for i=1,4 do self.model:Fire(GuildSpeedModel.REQUEST_INFO,40704,i) end end end RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp) end function GuildSpeedController:RegisterAllProtocals() self:RegisterProtocal(40700, "handle40700") -- 社团榜信息 self:RegisterProtocal(40701, "handle40701") -- 个人榜信息 self:RegisterProtocal(40702, "handle40702") -- 奖励推送提示 self:RegisterProtocal(40703, "handle40703") -- 社团活跃榜信息 self:RegisterProtocal(40704, "handle40704") -- 奖励领取情况 self:RegisterProtocal(40705, "handle40705") -- 领取奖励 self:RegisterProtocal(40706, "handle40706") -- 团长任务信息 self:RegisterProtocal(40707, "handle40707") -- 领取团长任务奖励 end -- ############## 社团榜信息 ############## -- protocol=40700 -- { -- c2s{} -- s2c{ -- guild_list:array{ -- rank :int8 // 排名 -- guild_id :int64 // 公会Id -- guild_name :string // 社团名称 -- captain_name:string // 团长名称 -- mem_number :int8 // 成员数量 -- mem_limit :int8 // 成员上限 -- sum_power :int64 // 总战力 -- old_rank :int8 // 旧排名 -- } -- my_guild_rank :int8 // 本社团排行 -- } -- } function GuildSpeedController:send40700() self:SendFmtToGame(40700) end function GuildSpeedController:handle40700() local scmd = {} if not GuildSpeedController.Is_Debug then scmd = SCMD40700.New(true) else scmd.guild_list = {} for i=1,20 do local guild_data = { rank = i, guild_name = "别人家的公会", captain_name = "会长名字六个字", guild_id = i, mem_number = 50, mem_limit = 50, sum_power = 1000000 - i*10000, } if i <= 3 then scmd.old_rank = i else scmd.old_rank = 0 end scmd.guild_list[#scmd.guild_list + 1] = guild_data end scmd.my_guild_rank = 2 end -- print("huangcong:GuildSpeedController [89]: ",scmd) -- PrintTable(scmd) self.model.my_guild_rank = scmd.my_guild_rank self.model:SetGuildRankInfo(scmd.guild_list) self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW) end -- ############## 个人榜信息 ############## -- protocol=40701 -- { -- c2s{} -- s2c{ -- rank_list:array{ -- rank :int8 // 排名 -- role_id :int64 // 角色Id -- role_name :string // 玩家名称 -- power :int64 // 战力 -- position :int8 // 职位 -- vip_flag :int8 //vip等级 -- sup_vip_type:int8 //贵族类型 -- } -- my_rank :int8 // 个人排行 -- } -- } function GuildSpeedController:send40701() self:SendFmtToGame(40701) end function GuildSpeedController:handle40701() local scmd = {} if not GuildSpeedController.Is_Debug then scmd = SCMD40701.New(true) else scmd.rank_list = {} for i=1,50 do local rank_data = { rank = i, role_id = i*10086, role_name = "名字有六个字", power = 1000000 - i * 10000 } if i <= 5 then rank_data.position = i else rank_data.position = 5 end if 15 - i > 0 then rank_data.vip_flag = 15-i rank_data.sup_vip_type = math.floor((15-i)/3) else rank_data.vip_flag = 0 rank_data.sup_vip_type = 0 end scmd.rank_list[#scmd.rank_list + 1] = rank_data end scmd.my_rank = 2 end -- print("huangcong:GuildSpeedController [186]: ",scmd) -- PrintTable(scmd) self.model.my_rank = scmd.my_rank self.model:SetRankInfo(scmd.rank_list) self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Fight) end -- ############## 奖励推送提示 ############## -- protocol=40702 -- { -- c2s{} -- s2c{ -- rank :int8 // 排行 -- goods_id :int32 // 奖励id -- } -- } function GuildSpeedController:send40702() self:SendFmtToGame(40702) end function GuildSpeedController:handle40702() local scmd = {} if not GuildSpeedController.Is_Debug then scmd = SCMD40702.New(true) else scmd.rank = 2 scmd.goods_id = 433018 end -- print("huangcong:GuildSpeedController [255]: ",scmd) -- PrintTable(scmd) if scmd.goods_id ~= 0 then GlobalEventSystem:Fire(AchieveModel.OPEN_GUILD_SPEED_TIP_VIEW,scmd) end end -- ############## 社团活跃榜信息 ############## -- protocol=40703 -- { -- c2s{} -- s2c{ -- guild_list:array{ -- rank :int8 // 排名 -- guild_id :int64 // 公会Id -- guild_name :string // 社团名称 -- captain_name:string // 团长名称 -- mem_number :int8 // 成员数量 -- mem_limit :int8 // 成员上限 -- sum_live :int32 // 总活跃值 -- } -- my_live :int32 // 我的活跃值 -- } -- } function GuildSpeedController:send40703() self:SendFmtToGame(40703) end function GuildSpeedController:handle40703() local scmd = SCMD40703.New(true) -- print("huangcong:GuildSpeedController [276]: ",scmd) -- PrintTable(scmd) self.model.my_live = scmd.my_live local my_guild_live_rank = 0 local my_guild_id = RoleManager.Instance.mainRoleInfo.guild_id if my_guild_id and my_guild_id ~= 0 then for i,v in ipairs(scmd.guild_list) do if v.guild_id == my_guild_id then my_guild_live_rank = v.rank break end end end self.model.my_guild_live_rank = my_guild_live_rank self.model:SetActiveRankInfo(scmd.guild_list) self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Active) end -- ############## 奖励领取情况 ############## -- protocol=40704 -- { -- c2s{ -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属 -- } -- s2c{ -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属 -- is_receive :int8 // 是否已经领取 0-未领取 1-可领取 2-已领取 -- } -- } function GuildSpeedController:send40704(type) self:SendFmtToGame(40704,"c",type) end function GuildSpeedController:handle40704() local scmd = SCMD40704.New(true) -- print("huangcong:GuildSpeedController [299]: ",scmd) -- PrintTable(scmd) self.model:SetTypeAwardInfo(scmd) local tab_refresh = scmd.type ~= 4 and scmd.type or GuildSpeedBaseView.TabId.Leader self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,scmd.type) end -- ############## 领取奖励 ############## -- protocol=40705 -- { -- c2s{ -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属 -- } -- s2c{ -- res :int32 // 返回码 -- type :int8 // 1-战力奖励 2-活跃奖励 3-战力榜团长专属 4-活跃榜团长专属 -- } -- } function GuildSpeedController:send40705(type) self:SendFmtToGame(40705,"c",type) end function GuildSpeedController:handle40705() local scmd = SCMD40705.New(true) if scmd.res == 1 then Message.show("领取成功","success") self.model:SetTypeAwardInfo({is_receive = 2,type = scmd.type}) local tab_refresh_type = scmd.type ~= 4 and scmd.type or GuildSpeedBaseView.TabId.Leader self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,tab_refresh_type) else ErrorCodeShow(scmd.res) end end -- ############## 团长任务信息 ############## -- protocol=40706 -- { -- c2s{} -- s2c{ -- task_list:array{ -- task_id :int16 // 任务Id -- progress :int64 // 任务进度(包括战力任务) -- status :int8 // 任务状态 0-未完成 1-已完成 2-已领取 -- } -- } -- } function GuildSpeedController:send40706() self:SendFmtToGame(40706) end function GuildSpeedController:handle40706() local scmd = SCMD40706.New(true) -- print("huangcong:GuildSpeedController [start:382] :", scmd) -- PrintTable(scmd) -- print("huangcong:GuildSpeedController [end]") self.model:SetTaskInfo(scmd) self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Leader) end -- ############## 领取团长任务奖励 ############## -- protocol=40707 -- { -- c2s{ -- task_id :int16 // 任务Id -- } -- s2c{ -- res :int32 // 返回码 -- task_id :int16 // 任务Id -- progress :int64 // 任务进度(包括战力任务) -- status :int8 // 任务状态 0-未完成 1-已完成 2-已领取 -- } -- } function GuildSpeedController:send40707(task_id) self:SendFmtToGame(40707,"h",task_id) end function GuildSpeedController:handle40707() local scmd = SCMD40707.New(true) if scmd.res == 1 then Message.show("领取成功","success") local task_info = self.model:GetTaskInfo(scmd.task_id) task_info.progress = scmd.progress task_info.status = scmd.status self.model:CheckMainIconRedDot() self.model:Fire(GuildSpeedModel.UPDATE_GUILD_SPEED_VIEW,GuildSpeedBaseView.TabId.Leader) else ErrorCodeShow(scmd.res) end end