145 lines
3.5 KiB
JavaScript
145 lines
3.5 KiB
JavaScript
|
|
/*******************************************************************************
|
||
|
|
*
|
||
|
|
* 活动: 限定挑戰
|
||
|
|
*
|
||
|
|
*
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
const ActBase = require( "act.base" );
|
||
|
|
|
||
|
|
const LimitChallenge = cc.Class( {
|
||
|
|
|
||
|
|
extends: ActBase,
|
||
|
|
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function() {
|
||
|
|
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add( this, [ "view" ] );
|
||
|
|
this.vattach( "Acts" );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function() {
|
||
|
|
this.RegisterProtocal( 31010, this.handle31010.bind( this ) ); //限定挑戰基本信息
|
||
|
|
this.RegisterProtocal( 31011, this.handle31011.bind( this ) ); //開始挑戰
|
||
|
|
this.RegisterProtocal( 31012, this.handle31012.bind( this ) ); //領獎
|
||
|
|
this.RegisterProtocal( 31013, this.handle31013.bind( this ) ); //排行榜
|
||
|
|
this.RegisterProtocal( 31014, this.handle31014.bind( this ) ); //掃蕩
|
||
|
|
},
|
||
|
|
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function( _cb ) {
|
||
|
|
let cfgs = [
|
||
|
|
"limit_challenge_data",
|
||
|
|
]
|
||
|
|
|
||
|
|
let _data = this.vget("LimitChallengeInfos");
|
||
|
|
_data[this.data.camp_id] = {};
|
||
|
|
this.vset("LimitChallengeInfos",_data);
|
||
|
|
|
||
|
|
this.loadConfigs( cfgs, ( _ret, _data ) =>{
|
||
|
|
nx.dt.fnInvoke( _cb, true );
|
||
|
|
} )
|
||
|
|
},
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// 消息
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 请求信息
|
||
|
|
reqLimitData: function(_camp_id, _cb ) {
|
||
|
|
|
||
|
|
this.SendProtocal( 31010, {
|
||
|
|
camp_id : _camp_id,
|
||
|
|
}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求相關配置信息
|
||
|
|
handle31010: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let old_data = this.vget("LimitChallengeInfos");
|
||
|
|
old_data[_data.camp_id] = _data;
|
||
|
|
this.vset( "LimitChallengeInfos", old_data );
|
||
|
|
this.setCurCamp(_data.camp_id);
|
||
|
|
},
|
||
|
|
|
||
|
|
reqBat: function(_camp_id, _cb ) {
|
||
|
|
|
||
|
|
this.SendProtocal( 31011, {
|
||
|
|
camp_id : _camp_id,
|
||
|
|
}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求相關配置信息
|
||
|
|
handle31011: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求獎勵
|
||
|
|
reqAward: function(_camp_id, _cb ) {
|
||
|
|
|
||
|
|
this.SendProtocal( 31012, {
|
||
|
|
camp_id : _camp_id
|
||
|
|
}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求相關配置信息
|
||
|
|
handle31012: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求排行榜
|
||
|
|
reqRank: function(_camp_id, _cb ) {
|
||
|
|
|
||
|
|
this.SendProtocal( 31013, {
|
||
|
|
camp_id : _camp_id
|
||
|
|
}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求相關配置信息
|
||
|
|
handle31013: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.vset("LimitChallengeRanks",_data);
|
||
|
|
},
|
||
|
|
|
||
|
|
reqBatClear: function(_camp_id, _cb ) {
|
||
|
|
|
||
|
|
this.SendProtocal( 31014, {
|
||
|
|
camp_id : _camp_id,
|
||
|
|
}, _cb );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求相關配置信息
|
||
|
|
handle31014: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if(_data.flag == 1){
|
||
|
|
nx.tbox("startower_tip3");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
setCurCamp(camp_id){
|
||
|
|
this.cur_camp_id = camp_id;
|
||
|
|
},
|
||
|
|
|
||
|
|
getCurCamp(){
|
||
|
|
return this.cur_camp_id;
|
||
|
|
}
|
||
|
|
|
||
|
|
} );
|
||
|
|
|
||
|
|
// 模块导出
|
||
|
|
module.exports = LimitChallenge;
|