"use strict"; cc._RF.push(module, '4ffe8Cd9jZHjIPGaQI2sb02', 'pvprank.mod'); // Scripts/mod/pvp/rank/pvprank.mod.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 跨服时空,zys //
Create: 2019-07-29 10:38:42 // -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var RoleEvent = require("role_event"); var ElitematchEvent = require("elitematch_event"); var RoleController = require("role_controller"); var PartnerConst = require("partner_const"); var HeroController = require("hero_controller"); var BattleController = require("battle_controller"); var BattleConst = require("battle_const"); var PVPRank = cc.Class({ "extends": BridgeController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var ElitematchModel = require("elitematch_model"); this.model = new ElitematchModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() {}, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(24900, this.handle24900); //請求精英賽基礎信息 this.RegisterProtocal(24901, this.handle24901); //請求對手信息 this.RegisterProtocal(24902, this.handle24902); //請求匹配對手 this.RegisterProtocal(24903, this.handle24903); //挑戰對手 this.RegisterProtocal(24904, this.handle24904); //購買挑戰次數 this.RegisterProtocal(24905, this.handle24905); //"請求精英賽是否開戰" this.RegisterProtocal(24906, this.handle24906); //戰鬥結算 this.RegisterProtocal(24910, this.handle24910); //歷史賽季賽區信息 this.RegisterProtocal(24911, this.handle24911); //歷史賽季 this.RegisterProtocal(24915, this.handle24915); //領取獎勵 //陣法 this.RegisterProtocal(24920, this.handle24920); //請求精英賽功能陣法 this.RegisterProtocal(24921, this.handle24921); //設置精英賽功能陣法 this.RegisterProtocal(24930, this.handle24930); //獲取個人日誌 this.RegisterProtocal(24931, this.handle24931); //獲取個人詳情 this.RegisterProtocal(24940, this.handle24940); //獲取個人記錄信息 this.RegisterProtocal(24941, this.handle24941); //分享 this.RegisterProtocal(24942, this.handle24942); //分享 this.RegisterProtocal(24945, this.handle24945); //精英賽宣言 this.RegisterProtocal(24946, this.handle24946); //保存精英賽宣言 this.RegisterProtocal(24950, this.handle24950); //顯示精英賽宣言結束 this.RegisterProtocal(24952, this.handle24952); //段位賽戰令基本信息 this.RegisterProtocal(24953, this.handle24953); //段位賽戰令一鍵領取等級禮包 this.RegisterProtocal(24954, this.handle24954); //段位賽戰令紅點 this.RegisterProtocal(24955, this.handle24955); //段位賽活動提示 this.RegisterProtocal(24960, this.handle24960); //段位賽活動提示 this.RegisterProtocal(24961, this.getTaskAwardBack); //段位賽活動提示 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; // 配置加载 var cfgs = ["arena_elite_data", "arena_elite_war_order_data" // 段位赛通行证 ]; this.cfgs = cfgs; this.loadConfigs(cfgs, function (_ret, _data) { _this.reqOrderData(_cb); _this.sender24900(); _this.reqTaskStatus(); }); }, reqOrderData: function reqOrderData(_cb) { this.SendProtocal(24952, {}, _cb); }, //精英赛基础信息 sender24900: function sender24900() { this.SendProtocal(24900, {}); }, handle24900: function handle24900(data) { nx.mTip.openTip("pvp.pvprank.challenge", data.day_combat_count > 0); nx.bridge.vset("rankMatch", data); this.model.setSCData(data); gcore.GlobalEvent.fire(ElitematchEvent.Get_Elite_Main_Info_Event, data); if (this.is_check_redpoint) { this.sender24920(1); this.sender24920(2); //王者賽需要弄多一個陣法類型 this.is_check_redpoint = false; } this.model.setSCDataBack24900(); }, //精英赛基础信息 reqTaskStatus: function reqTaskStatus() { this.SendProtocal(24960, {}); }, handle24960: function handle24960(_data) { var count = 0; if (_data && nx.dt.arrNEmpty(_data.list)) { _data.list.forEach(function (_info) { if (_info.award_status == 2) { _info.getstatus = _data.list.length + 3; } else if (_info.award_status == 1) { _info.getstatus = 1; count++; } else { _info.getstatus = _info.id + 3; } }); } nx.mTip.openTip("pvp.pvprank.task", count > 0); nx.bridge.vset("PvpRankTask", _data); }, //精英赛基础信息 reqGetTaskAward: function reqGetTaskAward() { this.SendProtocal(24961, {}); }, //精英赛基础信息 getTaskAwardBack: function getTaskAwardBack(_data) { if (nx.dt.strNEmpty(_data.msg)) { nx.tbox(_data.msg); } }, getCfg: function getCfg() { return this.cfgs; }, // 請求对手信息 sender24901: function sender24901() { this.SendProtocal(24901, {}); }, handle24901: function handle24901(data) { gcore.GlobalEvent.fire(ElitematchEvent.Get_Elite_Enemy_Info_Event, data); nx.bridge.vset("rankMatching", data); }, dealUI: function dealUI(_lev) { var path = ""; if (_lev == 1) { path = "prefab/pvp/rank/ui/png_rank_1"; } else if (_lev >= 2 && _lev <= 3) { path = "prefab/pvp/rank/ui/png_rank_2"; } else if (_lev >= 4 && _lev <= 6) { path = "prefab/pvp/rank/ui/png_rank_3"; } else if (_lev >= 7 && _lev <= 9) { path = "prefab/pvp/rank/ui/png_rank_4"; } else if (_lev >= 10 && _lev <= 13) { path = "prefab/pvp/rank/ui/png_rank_5"; } else if (_lev >= 14 && _lev <= 17) { path = "prefab/pvp/rank/ui/png_rank_6"; } else { path = "prefab/pvp/rank/ui/png_rank_7"; } return path; }, // --請求匹配對手 sender24902: function sender24902(is_skip) { var protocal = {}; protocal.type = is_skip; this.SendProtocal(24902, protocal); var dataa = { rand_list: [], is_match: 1 }; nx.bridge.vset("rankMatching", dataa); }, handle24902: function handle24902(data) {}, // --挑戰對手 sender24903: function sender24903() { var protocal = {}; this.SendProtocal(24903, protocal); }, handle24903: function handle24903(data) { if (data.code == 1) {} else { nx.tbox(data.msg); gcore.GlobalEvent.fire(ElitematchEvent.Elite_Fight_Fail_Event); } }, // --購買次數 sender24904: function sender24904() { var protocal = {}; this.SendProtocal(24904, protocal); }, handle24904: function handle24904(data) { if (data.code == 1) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_buy_count_Event, data); } else { nx.tbox(data.msg); } }, // --開戰時間 sender24905: function sender24905() { var protocal = {}; this.SendProtocal(24905, protocal); }, handle24905: function handle24905(data) { this.model.setEliteMatchFightTime(data); gcore.GlobalEvent.fire(ElitematchEvent.Elite_Start_Time_Event, data); this.model.setSCDataBack24905(); }, // --戰鬥結算 handle24906: function handle24906(data) { this.new_result_data = data; data.award_list = []; var info = nx.bridge.vget("rankMatch"); if (info && data) { info.lev = data.new_elite_lev; info.score = data.end_score; } var awarddss = []; for (var r = 0; r < data.awards.length; r++) { var award = data.awards[r]; var showa = { bid: award.item_id, num: award.item_num, id: 0 }; awarddss.push(showa); } data.award_list = awarddss; nx.bridge.vset("rankMatch", info); nx.bridge.vset("ResultInfo", data); // BattleController.getInstance().openFinishView( true, BattleConst.Fight_Type.EliteMatchWar, this.new_result_data ); // nx.bridge.createPanel( "WndWinSettle" ); return; }, reqGetDailyTaskReward: function reqGetDailyTaskReward() {}, newResultWin: function newResultWin() { var _this2 = this; if (!this.new_result_data) return; var data = this.new_result_data; gcore.GlobalEvent.fire(ElitematchEvent.Elite_Fight_Result_Event); if (this.timer_id) { gcore.Timer.del(this.timer_id); this.timer_id = null; } this.scdata24906 = data; this.openElitematchFightResultPanel(false); this.timer_id = gcore.Timer.set(function () { if (_this2.timer_id) { gcore.Timer.del(_this2.timer_id); _this2.timer_id = null; } if (_this2.scdata24906) { _this2.openElitematchFightResultPanel(true, _this2.scdata24906); } }, 1000, 1); this.new_result_data = null; }, //歷史賽季賽區信息 sender24910: function sender24910() { var protocal = {}; this.SendProtocal(24910, protocal); }, handle24910: function handle24910(data) { // -- if data.code == TRUE { gcore.GlobalEvent.fire(ElitematchEvent.Elite_History_Zone_Event, data); // -- else // -- message(data.msg) // -- end }, // --歷史賽季 sender24911: function sender24911(match_index, start_index, end_index, zone_id) { var protocal = {}; protocal.period = match_index; protocal.start_rank = start_index; protocal.end_rank = end_index; protocal.zone_id = zone_id; this.SendProtocal(24911, protocal); }, handle24911: function handle24911(data) { // -- if data.code == TRUE { gcore.GlobalEvent.fire(ElitematchEvent.Elite_History_Record_Event, data); // -- else // -- message(data.msg) // -- end }, // --領取段位獎勵 sender24915: function sender24915(lev) { var protocal = {}; protocal.lev = lev; this.SendProtocal(24915, protocal); }, handle24915: function handle24915(data) { if (data.code == 1) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Receive_Reward_Event, data); } else { nx.tbox(data.msg); } }, // --請求陣法 sender24920: function sender24920(type) { var protocal = {}; protocal.type = type; this.SendProtocal(24920, protocal); }, handle24920: function handle24920(data) { gcore.GlobalEvent.fire(ElitematchEvent.Update_Elite_Fun_Form, data); gcore.GlobalEvent.fire(ElitematchEvent.Update_Elite_Fun_Form2, data); var _type = null; if (data.type == 1) { _type = PartnerConst.Fun_Form.EliteMatch; } else { _type = PartnerConst.Fun_Form.EliteKingMatch; } var model = HeroController.getInstance().getModel(); for (var i in data.formations) { var v = data.formations[i]; v.type = _type; model.setFormList(v, v.order); } }, sender24921: function sender24921(type, formations) { var protocal = {}; protocal.type = type; protocal.formations = formations; this.SendProtocal(24921, protocal); }, handle24921: function handle24921(data) { if (data.code == 1) { gcore.GlobalEvent.fire(ElitematchEvent.Update_Elite_Save_Form, data); this.sender24920(1); this.sender24920(2); } else { nx.tbox(data.msg); } }, sender24930: function sender24930(type) { var protocal = {}; protocal.type = type; this.SendProtocal(24930, protocal); }, handle24930: function handle24930(data) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Challenge_Record_Event, data); }, sender24931: function sender24931(type, id) { var protocal = {}; protocal.type = type; protocal.id = id; this.SendProtocal(24931, protocal); }, handle24931: function handle24931(data) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Challenge_Record_Info_Event, data); }, sender24940: function sender24940(period) { var protocal = {}; protocal.period = period; this.SendProtocal(24940, protocal); }, handle24940: function handle24940(data) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Personal_Info_Event, data); }, sender24941: function sender24941(channel) { var protocal = {}; protocal.channel = channel; this.SendProtocal(24941, protocal); }, handle24941: function handle24941(data) { nx.tbox(data.msg); }, sender24942: function sender24942(id, share_srv_id, period) { var protocal = {}; protocal.id = id; protocal.share_srv_id = share_srv_id; protocal.period = period; this.SendProtocal(24942, protocal); }, handle24942: function handle24942(data) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Personal_Info_Event2, data); }, // --打開宣言 sender24945: function sender24945() { var protocal = {}; this.SendProtocal(24945, protocal); }, handle24945: function handle24945(data) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_Declaration_Event, data); }, // --保存宣言設置 sender24946: function sender24946(manifesto) { var protocal = {}; protocal.manifesto = manifesto; this.SendProtocal(24946, protocal); }, handle24946: function handle24946(data) { nx.tbox(data.msg); }, // --show宣言結束 sender24950: function sender24950() { var protocal = {}; this.SendProtocal(24950, protocal); }, handle24950: function handle24950(data) { nx.tbox(data.msg); }, // ---------------------------@ 打開界面 // --打開精英大賽主界面 openElitematchMainWindow: function openElitematchMainWindow(status, setting) { if (status) { // -- 判斷精英大賽是否開啟 if (!this.model.checkElitematchIsOpen().is_open) { return; } if (this.elitematch_main_window == null) { var ElitematchMainWindow = require("elitematch_main_window"); this.elitematch_main_window = new ElitematchMainWindow(); } if (this.elitematch_main_window) { this.elitematch_main_window.open(setting); } } else { if (this.elitematch_main_window) { this.elitematch_main_window.close(); this.elitematch_main_window = null; } } }, // --打開精英大賽匹配界面 openElitematchMatchingWindow: function openElitematchMatchingWindow(status, match_type, scdata) { if (status) { if (this.elitematch_matching_window == null) { var ElitematchMatchingWindow = require("elitematch_matching_window"); this.elitematch_matching_window = new ElitematchMatchingWindow(); } if (this.elitematch_matching_window) { this.elitematch_matching_window.open(match_type, scdata); } } else { if (this.elitematch_matching_window) { this.elitematch_matching_window.close(); this.elitematch_matching_window = null; } } }, // --打開精英大賽戰鬥結果界面 openElitematchFightResultPanel: function openElitematchFightResultPanel(status, data) { if (status) { if (this.elitematch_fight_result_panel == null) { var ElitematchFightResultPanel = require("elitematch_fight_result_panel"); this.elitematch_fight_result_panel = new ElitematchFightResultPanel(); } if (this.elitematch_fight_result_panel.isOpen && this.elitematch_fight_result_panel) { this.elitematch_fight_result_panel.open(data); } } else { if (this.elitematch_fight_result_panel) { this.elitematch_fight_result_panel.close(); this.elitematch_fight_result_panel = null; } } }, // --打開獎勵界面 openElitematchRewardPanel: function openElitematchRewardPanel(status, index, level_id, rank) { if (status) { if (this.elitematch_reward_panel == null) { var ElitematchRewardPanel = require("elitematch_reward_panel"); this.elitematch_reward_panel = new ElitematchRewardPanel(); } if (this.elitematch_reward_panel) { this.elitematch_reward_panel.open(index, level_id, rank); } } else { if (this.elitematch_reward_panel) { this.elitematch_reward_panel.close(); this.elitematch_reward_panel = null; } } }, // --打開戰鬥記錄 openElitematchFightRecordPanel: function openElitematchFightRecordPanel(status, index, level_id) { if (status) { if (this.elitematch_fight_record_panel == null) { var ElitematchFightRecordPanel = require("elitematch_fight_record_panel"); this.elitematch_fight_record_panel = new ElitematchFightRecordPanel(); } if (this.elitematch_fight_record_panel) { this.elitematch_fight_record_panel.open(index, level_id); } } else { if (this.elitematch_fight_record_panel) { this.elitematch_fight_record_panel.close(); this.elitematch_fight_record_panel = null; } } }, // --打開錄像 openElitematchFightVedioPanel: function openElitematchFightVedioPanel(status, index, level_id, _type, setting) { if (status) { if (this.elitematch_fight_vedio_panel == null) { var ElitematchFightVedioPanel = require("elitematch_fight_vedio_panel"); this.elitematch_fight_vedio_panel = new ElitematchFightVedioPanel(); } if (this.elitematch_fight_vedio_panel) { var ojb = {}; ojb.data = index; ojb.index = level_id; ojb._type = _type; ojb.setting = setting; this.elitematch_fight_vedio_panel.open(ojb); } } else { if (this.elitematch_fight_vedio_panel) { this.elitematch_fight_vedio_panel.close(); this.elitematch_fight_vedio_panel = null; } } }, // --打開歷史賽季 openElitematchHistoryRecordWindow: function openElitematchHistoryRecordWindow(status, index, max_period, zone_id) { if (status) { if (this.elitematch_history_record_window == null) { var ElitematchHistoryRecordWindow = require("elitematch_history_record_window"); this.elitematch_history_record_window = new ElitematchHistoryRecordWindow(); } if (this.elitematch_history_record_window) { this.elitematch_history_record_window.open(index, max_period, zone_id); } } else { if (this.elitematch_history_record_window) { this.elitematch_history_record_window.close(); this.elitematch_history_record_window = null; } } }, // --個人戰績記錄 openElitematchPersonalInfoPanel: function openElitematchPersonalInfoPanel(status, period, data) { if (status) { if (this.elitematch_personal_info_panel == null) { var ElitematchPersonalInfoPanel = require("elitematch_personal_info_panel"); this.elitematch_personal_info_panel = new ElitematchPersonalInfoPanel(); } if (this.elitematch_personal_info_panel) { this.elitematch_personal_info_panel.open(period, data); } } else { if (this.elitematch_personal_info_panel) { this.elitematch_personal_info_panel.close(); this.elitematch_personal_info_panel = null; } } }, // --宣言設置 openElitematchDeclarationPanel: function openElitematchDeclarationPanel(status, msgType) { // if status == true { // if this.elitematch_declaration_panel == null { // this.elitematch_declaration_panel = ElitematchDeclarationPanel.New(msgType) // end // if this.elitematch_declaration_panel:isOpen() == false { // this.elitematch_declaration_panel:open() // end // else // if this.elitematch_declaration_panel { // this.elitematch_declaration_panel:close() // this.elitematch_declaration_panel = null // end // end }, // --宣言設置 openChooseFacePanel: function openChooseFacePanel(status, index, id, world_pos, msg_type) { if (status) { if (this.choose_face_panel == null) { var ChooseFacePanel = require("choose_face_panel"); this.choose_face_panel = new ChooseFacePanel(); } if (this.choose_face_panel) { this.choose_face_panel.open(index, id, world_pos, msg_type); } } else { if (this.choose_face_panel) { this.choose_face_panel.close(); this.choose_face_panel = null; } } }, // --宣言設置 openElitematchZoneListPanel: function openElitematchZoneListPanel(status, max_zone, callback) { if (status) { if (this.elitematch_zone_list_panel == null) { var ElitematchZoneListPanel = require("elitematch_zone_list_panel"); this.elitematch_zone_list_panel = new ElitematchZoneListPanel(); } if (this.elitematch_zone_list_panel) { this.elitematch_zone_list_panel.open(max_zone, callback); } else if (this.elitematch_zone_list_panel) { this.elitematch_zone_list_panel.close(); this.elitematch_zone_list_panel = null; } } }, // -----------------------------------------段位賽戰令活動--------------------------------------------- // -- 戰令基本信息 sender24952: function sender24952() { var protocal = {}; this.SendProtocal(24952, protocal); }, /*** * {"period":2,"cur_day":2,"end_time":1714665600,"lev":2,"rmb_status":0,"win_count":6,"list":[]} */ handle24952: function handle24952(data) { this.model.setOrderactionData(data); if (nx.dt.arrEmpty(data.list)) { var cfg = game.configs.arena_elite_war_order_data.data_lev_reward_list[data.period]; for (var c in cfg) { var item = cfg[c]; if (data.win_count >= item.win_count) { var newd = { "id": item.lev, "award_status": 0, "rmb_award_status": 0 }; data.list.push(newd); } } } nx.bridge.vset("rankOrder", data); this.model.setSCDataBackOrderaction(); gcore.GlobalEvent.fire(ElitematchEvent.Elite_OrderAction_Init_Event, data); }, // --一鍵領取禮包 sender24953: function sender24953(id) { var protocal = {}; protocal.id = id; this.SendProtocal(24953, protocal); }, handle24953: function handle24953(data) { if (data) { nx.tbox(data.msg); } }, // --紅點 sender24954: function sender24954() { var protocal = {}; this.SendProtocal(24954, protocal); }, handle24954: function handle24954(data) { if (data) { this.model.setOrderactionRedStatus(data.flag); this.model.setSCDataBackOrderaction(); } gcore.GlobalEvent.fire(ElitematchEvent.Elite_OrderAction_First_Red_Event); }, // --段位賽活動提示 sender24955: function sender24955() { var protocal = {}; this.SendProtocal(24955, protocal); }, handle24955: function handle24955(data) { gcore.GlobalEvent.fire(ElitematchEvent.Elite_OrderAction_IsPopWarn_Event, data); }, // --打開主界面 openElitematchOrderactionWindow: function openElitematchOrderactionWindow(status) { if (status) { // -- 判斷精英大賽是否開啟 if (!this.model.checkElitematchIsOpen().is_open) { return; } if (!this.elitematch_orderaction_window) { var ElitematchOrderactionWindow = require("elitematch_orderaction_window"); this.elitematch_orderaction_window = new ElitematchOrderactionWindow(); } this.elitematch_orderaction_window.open(); } else { if (this.elitematch_orderaction_window) { this.elitematch_orderaction_window.close(); this.elitematch_orderaction_window = null; } } }, // --購買進階卡 openBuyCardView: function openBuyCardView(status) { if (status) { if (!this.buy_card_view) { var ElitematchOrderactionUntieRewardWindow = require("elitematch_orderaction_untie_reward_window"); this.buy_card_view = new ElitematchOrderactionUntieRewardWindow(); } this.buy_card_view.open(); } else { if (this.buy_card_view) { this.buy_card_view.close(); this.buy_card_view = null; } } }, // --打開活動結束警告界面 openElitematchEndWarnView: function openElitematchEndWarnView(status, day) { if (status) { if (!this.end_warn_view) { var ElitematchOrderActionEndWarnWindow = require("elitematch_orderaction_end_warn_window"); this.end_warn_view = new ElitematchOrderActionEndWarnWindow(); } this.end_warn_view.open(day); } else { if (this.end_warn_view) { this.end_warn_view.close(); this.end_warn_view = null; } } } }); module.exports = PVPRank; cc._RF.pop();