351 lines
11 KiB
JavaScript
351 lines
11 KiB
JavaScript
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 跨服时空,zys
|
|
// <br/>Create: 2019-07-29 10:38:42
|
|
// --------------------------------------------------------------------
|
|
const 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() {
|
|
},
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
var CrosschampionModel = require( "crosschampion_model" );
|
|
|
|
this.model = new CrosschampionModel();
|
|
this.model.initConfig();
|
|
this.first = true;
|
|
},
|
|
|
|
// 返回当前的model
|
|
getModel: function() {
|
|
return this.model;
|
|
},
|
|
|
|
// 注册监听事件
|
|
registerEvents: function() {
|
|
// 點贊事件監聽,判斷紅點
|
|
// 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() {
|
|
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( _cb ) {
|
|
|
|
let cfgs = [
|
|
"arena_champion_data",
|
|
"arena_cluster_champion_data",
|
|
];
|
|
this.loadConfigs( cfgs, ( _ret, _data ) => {
|
|
this.reqChampion( _cb );
|
|
} )
|
|
|
|
},
|
|
|
|
reqChampion: function( _cb ) {
|
|
this.SendProtocal( 26200, {} ); // 冠军赛进程状态
|
|
this.SendProtocal( 26213, {}, _cb ); // 前三名数据(用于红点)
|
|
},
|
|
|
|
|
|
|
|
sender26200: function() {
|
|
this.SendProtocal( 26200, {} );
|
|
},
|
|
|
|
handle26200: function( data ) {
|
|
let self = this;
|
|
self.model.updateChampionBaseInfo( data )
|
|
self.sender26201()
|
|
|
|
let 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() {
|
|
this.SendProtocal( 26201, {} )
|
|
},
|
|
|
|
handle26201( data ) {
|
|
this.model.setRoleInfo( data )
|
|
},
|
|
|
|
// 請求我的比賽信息
|
|
sender26202() {
|
|
this.SendProtocal( 26202, {} )
|
|
},
|
|
|
|
handle26202( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateMyMatchInfoEvent, data )
|
|
},
|
|
|
|
// 請求競猜
|
|
sender26203() {
|
|
this.SendProtocal( 26203, {} )
|
|
},
|
|
|
|
handle26203( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateGuessMatchInfoEvent, data )
|
|
},
|
|
|
|
// 競猜押注
|
|
sender26204( bet_type, bet_val ) {
|
|
let protocal = {}
|
|
protocal.bet_type = bet_type
|
|
protocal.bet_val = bet_val
|
|
this.SendProtocal( 26204, protocal )
|
|
},
|
|
|
|
handle26204( data ) {
|
|
if( data.msg ) {
|
|
nx.tbox( data.msg )
|
|
}
|
|
if( data.code == 1 ) {
|
|
let 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() {
|
|
this.SendProtocal( 26205, {} )
|
|
},
|
|
|
|
handle26205( data ) {
|
|
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateMylogListEvent, data.list )
|
|
},
|
|
|
|
// 上次比賽結果
|
|
sender26206() {
|
|
this.SendProtocal( 26206, {} );
|
|
|
|
},
|
|
|
|
handle26206( data ) {
|
|
nx.bridge.createPanel( "WndCChampionFinal", data );
|
|
},
|
|
|
|
// 競猜押注實時更新
|
|
handle26207( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateBetMatchValueEvent, data )
|
|
},
|
|
|
|
// 我的PK信息
|
|
sender26208() {
|
|
this.SendProtocal( 26208, {} )
|
|
},
|
|
|
|
handle26208( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateMylogListEvent, data.list )
|
|
},
|
|
|
|
// 64 強賽信息
|
|
sender26209() {
|
|
this.SendProtocal( 26209, {} )
|
|
},
|
|
|
|
handle26209( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateTop32InfoEvent, data.list )
|
|
},
|
|
|
|
// 8 強賽信息
|
|
sender26210() {
|
|
this.SendProtocal( 26210, {} )
|
|
},
|
|
|
|
handle26210( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateTop4InfoEvent, data.pos_list )
|
|
},
|
|
|
|
// 64/8強賽競猜位置
|
|
sender26211() {
|
|
this.SendProtocal( 26211, {} )
|
|
},
|
|
|
|
handle26211( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateTop324GuessGroupEvent, data.group, data.pos )
|
|
},
|
|
|
|
// 64/8強賽指定位置對戰信息
|
|
sender26212( group, pos ) {
|
|
let protocal = {}
|
|
protocal.group = group
|
|
protocal.pos = pos
|
|
this.SendProtocal( 26212, protocal )
|
|
},
|
|
|
|
handle26212( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateTop324GroupPosEvent, data )
|
|
},
|
|
|
|
// 前三名排行信息
|
|
sender26213() {
|
|
this.SendProtocal( 26213, {} )
|
|
},
|
|
|
|
handle26213( data ) {
|
|
if( data ) {
|
|
this.model.setTopThreeRoleData( data.rank_list )
|
|
this.model.saveTopThreeRoleData( data );
|
|
gcore.GlobalEvent.fire( CrosschampionEvent.UpdateChampionTop3Event, data.rank_list, 2 )
|
|
}
|
|
|
|
let 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() {
|
|
this.SendProtocal( 26214, {} )
|
|
},
|
|
|
|
handle26214( data ) {
|
|
gcore.GlobalEvent.fire( ArenaEvent.UpdateChampionRankEvent, data )
|
|
},
|
|
|
|
// 冠軍信息彈窗
|
|
sender26215() {
|
|
this.SendProtocal( 26215, {} )
|
|
},
|
|
|
|
handle26215( data ) {
|
|
nx.bridge.createPanel( "WndCChampionFinal", data );
|
|
},
|
|
|
|
// 進入周冠軍賽玩家主界面(通知後端,用於觸發成就)
|
|
sender26216() {
|
|
this.SendProtocal( 26216, {} )
|
|
},
|
|
|
|
////////////////////-@ 界面相關
|
|
// 打開跨服冠軍賽入口主界面
|
|
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() {
|
|
return this.open_flag
|
|
},
|
|
|
|
setCrosschampionOpenFlag( flag ) {
|
|
this.open_flag = flag
|
|
},
|
|
|
|
// 打開跨服冠軍賽商店
|
|
openCrosschampionShopWindow( status ) {
|
|
let 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; |