Files
fc/dev/project/library/imports/d0/d0d9a54c-3bd8-4d38-95c3-9f7874c515be.js
2026-05-24 10:21:26 +08:00

299 lines
11 KiB
JavaScript

"use strict";
cc._RF.push(module, 'd0d9aVMO9hNOJXDn3h0xRW+', 'crosschampion_controller');
// Scripts/mod/pvp/crosschampion/crosschampion_controller.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 跨服时空,zys
// <br/>Create: 2019-07-29 10:38:42
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
var RoleEvent = require("role_event");
var ArenaConst = require("arena_const");
var ArenaController = require("arena_controller");
var ArenaEvent = require("arena_event");
var CrosschampionEvent = require("crosschampion_event");
var CrosschampionController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var CrosschampionModel = require("crosschampion_model");
this.model = new CrosschampionModel();
this.model.initConfig();
this.first = true;
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
// 注册监听事件
registerEvents: function registerEvents() {
// 點贊事件監聽,判斷紅點
// this.role_worship_event = gcore.GlobalEvent.bind( RoleEvent.WorshipOtherRole, ( rid, srv_id, idx, _type ) => {
// if( _type == WorshipType.crosschampion ) {
// this.model.updateTopThreeRoleWorshipStatus( rid, srv_id )
// }
// } )
},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
this.RegisterProtocal(26200, this.handle26200); //賽程整體實時狀態信息
this.RegisterProtocal(26201, this.handle26201); //個人信息
this.RegisterProtocal(26202, this.handle26202); //我的比賽信息
this.RegisterProtocal(26203, this.handle26203); //競猜信息
this.RegisterProtocal(26204, this.handle26204); //競猜押注
this.RegisterProtocal(26205, this.handle26205); //我的競猜信息
this.RegisterProtocal(26206, this.handle26206); //上次比賽結果
this.RegisterProtocal(26207, this.handle26207); //競猜押注實時更新
this.RegisterProtocal(26208, this.handle26208); //我的PK信息
this.RegisterProtocal(26209, this.handle26209); //64強賽信息
this.RegisterProtocal(26210, this.handle26210); //8強賽信息
this.RegisterProtocal(26211, this.handle26211); //64/8強賽競猜位置
this.RegisterProtocal(26212, this.handle26212); //64/8強賽指定位置對戰信息
this.RegisterProtocal(26213, this.handle26213); //前三名排行信息
this.RegisterProtocal(26214, this.handle26214); //排行榜信息
this.RegisterProtocal(26215, this.handle26215); //冠軍信息彈窗
},
reqBaseFromServer: function reqBaseFromServer(_cb) {
var _this = this;
var cfgs = ["arena_champion_data", "arena_cluster_champion_data"];
this.loadConfigs(cfgs, function (_ret, _data) {
_this.reqChampion(_cb);
});
},
reqChampion: function reqChampion(_cb) {
this.SendProtocal(26200, {}); // 冠军赛进程状态
this.SendProtocal(26213, {}, _cb); // 前三名数据(用于红点)
},
sender26200: function sender26200() {
this.SendProtocal(26200, {});
},
handle26200: function handle26200(data) {
var self = this;
self.model.updateChampionBaseInfo(data);
self.sender26201();
var is_open = self.model.checkCrossChampionIsOpen(true);
if (!is_open) return;
nx.bridge.vset("CChampionPro", data);
// nx.mTip.openTip( "pvp.crosschampion", ( data.step != ArenaConst.champion_step.unopened && data.step_status == ArenaConst.champion_step_status.opened ) );
if (data.step_status == ArenaConst.champion_step_status.opened) {
if (self.crosschampion_wnd == null && !ArenaController.getInstance().checkChampionWndIsOpen()) {
// if (data.round_status == ArenaConst.champion_round_status.guess) { // 每次競猜都要彈提示
// ActivityController.getInstance().openSignView(true, ActivityConst.ActivitySignType.cross_champion_guess, {timer : true})
// }else{
// if (!self.had_show_notice) {
// ActivityController.getInstance().openSignView(true, ActivityConst.ActivitySignType.cross_champion, {timer : true})
// self.had_show_notice = true
// }
// }
}
}
},
// 請求個人信息
sender26201: function sender26201() {
this.SendProtocal(26201, {});
},
handle26201: function handle26201(data) {
this.model.setRoleInfo(data);
},
// 請求我的比賽信息
sender26202: function sender26202() {
this.SendProtocal(26202, {});
},
handle26202: function handle26202(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateMyMatchInfoEvent, data);
},
// 請求競猜
sender26203: function sender26203() {
this.SendProtocal(26203, {});
},
handle26203: function handle26203(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateGuessMatchInfoEvent, data);
},
// 競猜押注
sender26204: function sender26204(bet_type, bet_val) {
var protocal = {};
protocal.bet_type = bet_type;
protocal.bet_val = bet_val;
this.SendProtocal(26204, protocal);
},
handle26204: function handle26204(data) {
if (data.msg) {
nx.tbox(data.msg);
}
if (data.code == 1) {
var role_info = this.model.getRoleInfo();
role_info.can_bet = data.can_bet;
gcore.GlobalEvent.fire(ArenaEvent.UpdateRoleInfoBetEvent, data.can_bet, data.bet_type);
ArenaController.getInstance().openArenaChampionGuessWindow(false);
}
},
// 我的競猜信息
sender26205: function sender26205() {
this.SendProtocal(26205, {});
},
handle26205: function handle26205(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateMylogListEvent, data.list);
},
// 上次比賽結果
sender26206: function sender26206() {
this.SendProtocal(26206, {});
},
handle26206: function handle26206(data) {
nx.bridge.createPanel("WndCChampionFinal", data);
},
// 競猜押注實時更新
handle26207: function handle26207(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateBetMatchValueEvent, data);
},
// 我的PK信息
sender26208: function sender26208() {
this.SendProtocal(26208, {});
},
handle26208: function handle26208(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateMylogListEvent, data.list);
},
// 64 強賽信息
sender26209: function sender26209() {
this.SendProtocal(26209, {});
},
handle26209: function handle26209(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateTop32InfoEvent, data.list);
},
// 8 強賽信息
sender26210: function sender26210() {
this.SendProtocal(26210, {});
},
handle26210: function handle26210(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateTop4InfoEvent, data.pos_list);
},
// 64/8強賽競猜位置
sender26211: function sender26211() {
this.SendProtocal(26211, {});
},
handle26211: function handle26211(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateTop324GuessGroupEvent, data.group, data.pos);
},
// 64/8強賽指定位置對戰信息
sender26212: function sender26212(group, pos) {
var protocal = {};
protocal.group = group;
protocal.pos = pos;
this.SendProtocal(26212, protocal);
},
handle26212: function handle26212(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateTop324GroupPosEvent, data);
},
// 前三名排行信息
sender26213: function sender26213() {
this.SendProtocal(26213, {});
},
handle26213: function handle26213(data) {
if (data) {
this.model.setTopThreeRoleData(data.rank_list);
this.model.saveTopThreeRoleData(data);
gcore.GlobalEvent.fire(CrosschampionEvent.UpdateChampionTop3Event, data.rank_list, 2);
}
var showdata = {
showlist: data
};
if (nx.dt.arrNEmpty(data.rank_list)) {
if (this.first) {
nx.bridge.vset("CChampionPro", showdata);
this.first = false;
}
}
// if( !nx.bridge.getBridgeWindow( "WndCChampionFinal" ) ){
// nx.bridge.createPanel( "WndCChampionFinal", data );
// }
},
// 排行榜信息
sender26214: function sender26214() {
this.SendProtocal(26214, {});
},
handle26214: function handle26214(data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateChampionRankEvent, data);
},
// 冠軍信息彈窗
sender26215: function sender26215() {
this.SendProtocal(26215, {});
},
handle26215: function handle26215(data) {
nx.bridge.createPanel("WndCChampionFinal", data);
},
// 進入周冠軍賽玩家主界面(通知後端,用於觸發成就)
sender26216: function sender26216() {
this.SendProtocal(26216, {});
},
////////////////////-@ 界面相關
// 打開跨服冠軍賽入口主界面
openCrosschampionMainWindow: function openCrosschampionMainWindow(status, force) {
if (status) {
nx.bridge.createPanel("WndCChampionChallenge", force);
} else {
nx.bridge.closePanel("WndCChampionChallenge");
}
// let self = this;
// if( status ) {
// // 玩法是否開啟
// if( !self.model.checkCrossChampionIsOpen( true ) ) {
// return
// }
// // 如果冠軍賽正在進行,則直接進入冠軍賽玩法界面
// if( !force && self.model.getMyMatchStatus() != ArenaConst.champion_my_status.unopened && self.model.getOpenCrosschampionViewStatus() ) {
// self.setCrosschampionOpenFlag( true )
// self.sender26206()
// self.sender26201()
// ArenaController.getInstance().openArenaChampionMatchWindow( true, 1, ArenaConst.champion_type.cross )
// return
// }
// self.setCrosschampionOpenFlag( false )
// if( !self.crosschampion_wnd ) {
// var CrosschampionMainWindow = require( "crosschampion_main_window" )
// self.crosschampion_wnd = new CrosschampionMainWindow()
// }
// self.crosschampion_wnd.open()
// } else {
// if( self.crosschampion_wnd ) {
// self.crosschampion_wnd.close()
// self.crosschampion_wnd = null
// }
// }
},
getCrosschampionOpenFlag: function getCrosschampionOpenFlag() {
return this.open_flag;
},
setCrosschampionOpenFlag: function setCrosschampionOpenFlag(flag) {
this.open_flag = flag;
},
// 打開跨服冠軍賽商店
openCrosschampionShopWindow: function openCrosschampionShopWindow(status) {
var self = this;
if (status) {
if (!self.crosschampion_shop) {
var CrosschampionShopWindow = require("crosschampion_shop_window");
self.crosschampion_shop = new CrosschampionShopWindow();
}
self.crosschampion_shop.open();
} else {
if (self.crosschampion_shop) {
self.crosschampion_shop.close();
self.crosschampion_shop = null;
}
}
}
});
module.exports = CrosschampionController;
cc._RF.pop();