192 lines
4.4 KiB
JavaScript
192 lines
4.4 KiB
JavaScript
const ActBase = require( "act.base" );
|
|
|
|
const ActNewHeroSummon = cc.Class({
|
|
|
|
extends: ActBase,
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
|
|
// 视图附着
|
|
nx.plugin.add( this, [ "view" ] );
|
|
this.vattach( "Acts" );
|
|
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
|
|
// // // 前端准备完毕
|
|
this.RegisterProtocal( 23270, this.dealBaseInfoBack.bind( this ) );
|
|
this.RegisterProtocal( 23271, this.dealSummonDatas.bind( this ) );
|
|
this.RegisterProtocal( 23272, this.dealSummonLog.bind( this ) );
|
|
},
|
|
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function( _cb ) {
|
|
|
|
let cfgs = [
|
|
this.data.config,//付費活動
|
|
]
|
|
this.loadConfigs( cfgs, ( _ret, _data ) =>{
|
|
|
|
nx.dt.fnInvoke( _cb, true );
|
|
this.reqBaseInfo();
|
|
} )
|
|
|
|
},
|
|
|
|
|
|
reqBaseInfo: function(){
|
|
|
|
this.SendProtocal( 23270, {} );
|
|
},
|
|
|
|
dealBaseInfoBack: function( _data ){
|
|
|
|
this.vset( "newheroSummonInfo", _data );
|
|
|
|
this.openTip( "reward", _data.free_time == 0 );
|
|
let info = this.getNewHeroCfg();
|
|
|
|
},
|
|
|
|
reqSummon: function( _times, _type ){
|
|
let info = {
|
|
times: _times,
|
|
recruit_type : _type,
|
|
}
|
|
this.SendProtocal( 23271, info );
|
|
},
|
|
|
|
dealSummonDatas: function( _data ){
|
|
|
|
/*****
|
|
[13:39:26:561][recv] <<<[23271]:
|
|
{"group_id":10001,"times":1,"flag":3,"msg":"",
|
|
"rewards":[{"base_id":25304,"num":1}],
|
|
"partner_bids":[{"partner_bid":20405,"init_star":4}],"partner_chips":[],"must_five_num":10}
|
|
|
|
*/
|
|
let rewards = [];
|
|
let rewardsdata = _data.rewards || [];
|
|
|
|
rewardsdata.forEach( _re => {
|
|
rewards.push( { bid: _re.base_id, num: _re.num } );
|
|
});
|
|
|
|
if( nx.dt.arrNEmpty( rewards ) ) {
|
|
nx.bridge.createPanel( "PopupRewards", {
|
|
list: rewards
|
|
} );
|
|
}
|
|
|
|
},
|
|
|
|
reqSummonLog: function(){
|
|
|
|
this.SendProtocal( 23272, {} );
|
|
},
|
|
|
|
dealSummonLog: function( _data ){
|
|
this.vset( "newheroSummonLog", _data );
|
|
},
|
|
|
|
getNewHeroCfg: function(){
|
|
|
|
let cfg = gdata( this.data.config, "data_summon" );
|
|
let info = {};
|
|
if( cfg ){
|
|
for (let i in cfg ) {
|
|
let item = cfg[i];
|
|
if( item.camp_id == this.data.camp_id ){
|
|
info = item;
|
|
this.group_id = item.group_id;
|
|
}
|
|
}
|
|
}
|
|
|
|
return info;
|
|
|
|
},
|
|
|
|
// 概率顯示
|
|
getNewHeroRate: function(){
|
|
|
|
let cfg = gdata( this.data.config, "data_probability" );
|
|
let txt = "";
|
|
if( cfg ){
|
|
for (let i in cfg ) {
|
|
if( i == this.group_id ){
|
|
let txtt = cfg[i];
|
|
for (let c in txtt ) {
|
|
txt += ( txtt[c].name + "," + txtt[c].probability + "%\n" );
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
return txt;
|
|
|
|
},
|
|
|
|
// 概率顯示
|
|
getNewHeroHelp: function(){
|
|
|
|
let cfg = gdata( this.data.config, "data_desc" );
|
|
let help = {};
|
|
if( cfg ){
|
|
for (let i in cfg ) {
|
|
let explain = cfg[i];
|
|
if( explain.camp_id == this.data.camp_id ){
|
|
help = explain;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
return help;
|
|
|
|
},
|
|
|
|
getNewHeroMat: function(){
|
|
|
|
let cfg = gdata( this.data.config, "data_summon" );
|
|
let mat = [];
|
|
if( cfg ){
|
|
for (let i in cfg ) {
|
|
let item = cfg[i];
|
|
if( item.camp_id == this.data.camp_id ){
|
|
mat[0] = item.loss_gold_once[0][0];
|
|
mat[1] = item.loss_item_once[0][0];
|
|
}
|
|
}
|
|
}
|
|
|
|
return mat;
|
|
|
|
},
|
|
|
|
getNewHeroRankReward: function(){
|
|
|
|
let cfg = gdata( this.data.config, "data_rank_reward" );
|
|
// let reward = [];
|
|
// if( cfg ){
|
|
// for (let i = 0; i < cfg.length; i++ ) {
|
|
// let item = cfg[i];
|
|
// reward.push( item );
|
|
// }
|
|
// }
|
|
|
|
return cfg;
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = ActNewHeroSummon; |