Files
fc/dev/project/library/imports/17/17aa3ae6-9994-4ecc-98f6-18e1e46ac9c4.js
2026-05-24 10:21:26 +08:00

150 lines
4.0 KiB
JavaScript

"use strict";
cc._RF.push(module, '17aa3rmmZROzJj2GOHkasnE', 'act.newherosum.mod');
// Scripts/mod/acts/newherosum/act.newherosum.mod.js
"use strict";
var ActBase = require("act.base");
var ActNewHeroSummon = cc.Class({
"extends": ActBase,
// 初始化配置数据
initConfig: function initConfig() {
// 视图附着
nx.plugin.add(this, ["view"]);
this.vattach("Acts");
},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
// // // 前端准备完毕
this.RegisterProtocal(23270, this.dealBaseInfoBack.bind(this));
this.RegisterProtocal(23271, this.dealSummonDatas.bind(this));
this.RegisterProtocal(23272, this.dealSummonLog.bind(this));
},
// 从服务器初始化数据
reqBaseFromServer: function reqBaseFromServer(_cb) {
var _this = this;
var cfgs = [this.data.config //付費活動
];
this.loadConfigs(cfgs, function (_ret, _data) {
nx.dt.fnInvoke(_cb, true);
_this.reqBaseInfo();
});
},
reqBaseInfo: function reqBaseInfo() {
this.SendProtocal(23270, {});
},
dealBaseInfoBack: function dealBaseInfoBack(_data) {
this.vset("newheroSummonInfo", _data);
this.openTip("reward", _data.free_time == 0);
var info = this.getNewHeroCfg();
},
reqSummon: function reqSummon(_times, _type) {
var info = {
times: _times,
recruit_type: _type
};
this.SendProtocal(23271, info);
},
dealSummonDatas: function dealSummonDatas(_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}
*/
var rewards = [];
var rewardsdata = _data.rewards || [];
rewardsdata.forEach(function (_re) {
rewards.push({
bid: _re.base_id,
num: _re.num
});
});
if (nx.dt.arrNEmpty(rewards)) {
nx.bridge.createPanel("PopupRewards", {
list: rewards
});
}
},
reqSummonLog: function reqSummonLog() {
this.SendProtocal(23272, {});
},
dealSummonLog: function dealSummonLog(_data) {
this.vset("newheroSummonLog", _data);
},
getNewHeroCfg: function getNewHeroCfg() {
var cfg = gdata(this.data.config, "data_summon");
var info = {};
if (cfg) {
for (var i in cfg) {
var item = cfg[i];
if (item.camp_id == this.data.camp_id) {
info = item;
this.group_id = item.group_id;
}
}
}
return info;
},
// 概率顯示
getNewHeroRate: function getNewHeroRate() {
var cfg = gdata(this.data.config, "data_probability");
var txt = "";
if (cfg) {
for (var i in cfg) {
if (i == this.group_id) {
var txtt = cfg[i];
for (var c in txtt) {
txt += txtt[c].name + "," + txtt[c].probability + "%\n";
}
}
}
}
return txt;
},
// 概率顯示
getNewHeroHelp: function getNewHeroHelp() {
var cfg = gdata(this.data.config, "data_desc");
var help = {};
if (cfg) {
for (var i in cfg) {
var explain = cfg[i];
if (explain.camp_id == this.data.camp_id) {
help = explain;
}
}
}
return help;
},
getNewHeroMat: function getNewHeroMat() {
var cfg = gdata(this.data.config, "data_summon");
var mat = [];
if (cfg) {
for (var i in cfg) {
var 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 getNewHeroRankReward() {
var 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;
cc._RF.pop();