163 lines
5.2 KiB
JavaScript
163 lines
5.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'adcdcZ2+zhGmp2V4omNBpEC', 'act.team.summon.mod.3');
|
||
|
|
// Scripts/mod/acts/teamSummon/act.team.summon.mod.3.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/*******************************************************************************
|
||
|
|
*
|
||
|
|
* 活动:阵营招募
|
||
|
|
*
|
||
|
|
*
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
var ActBase = require("act.base");
|
||
|
|
var BackPackController = require("backpack_controller");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
var SummonMod = require("summon.mod");
|
||
|
|
var ActTeamSummonMod3 = cc.Class({
|
||
|
|
"extends": ActBase,
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function initConfig() {
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add(this, ["view"]);
|
||
|
|
this.vattach("Acts");
|
||
|
|
},
|
||
|
|
// 注册监听事件
|
||
|
|
registerEvents: function registerEvents() {
|
||
|
|
if (!!this.bagEvent1) {
|
||
|
|
gcore.GlobalEvent.unbind(this.bagEvent1);
|
||
|
|
gcore.GlobalEvent.unbind(this.bagEvent2);
|
||
|
|
gcore.GlobalEvent.unbind(this.bagEvent3);
|
||
|
|
this.bagEvent1 = null;
|
||
|
|
this.bagEvent2 = null;
|
||
|
|
this.bagEvent3 = null;
|
||
|
|
}
|
||
|
|
this.bagEvent1 = gcore.GlobalEvent.bind(EventId.ADD_GOODS, this.onBagItemUpdate.bind(this));
|
||
|
|
this.bagEvent2 = gcore.GlobalEvent.bind(EventId.DELETE_GOODS, this.onBagItemUpdate.bind(this));
|
||
|
|
this.bagEvent3 = gcore.GlobalEvent.bind(EventId.MODIFY_GOODS_NUM, this.onBagItemUpdate.bind(this));
|
||
|
|
},
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function registerProtocals() {
|
||
|
|
this.RegisterProtocal(23263, this.handle23263.bind(this));
|
||
|
|
},
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
||
|
|
var _this = this;
|
||
|
|
nx.dt.fnInvoke(_cb, true);
|
||
|
|
this.configs = this.queryConfigs();
|
||
|
|
setTimeout(function () {
|
||
|
|
_this.freshTips();
|
||
|
|
}, 50);
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 基本操作
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 点击抽奖
|
||
|
|
reqSummon: function reqSummon(_once, _cb) {
|
||
|
|
SummonMod.getInstance().reqSummonTeamItem(this.configs.group_id, _once ? 1 : 10, _cb);
|
||
|
|
},
|
||
|
|
// 抽积分
|
||
|
|
reqScore: function reqScore(_cb) {
|
||
|
|
SummonMod.getInstance().reqSummonTeamScore(_cb);
|
||
|
|
},
|
||
|
|
// 召唤状态
|
||
|
|
reqState: function reqState(_cb) {
|
||
|
|
this.SendProtocal(23263, {
|
||
|
|
camp_id: this.data.camp_id
|
||
|
|
}, _cb);
|
||
|
|
},
|
||
|
|
// 召唤状态
|
||
|
|
handle23263: function handle23263(_data) {
|
||
|
|
if (!this.isGoodData(_data, false) || _data.camp_id != this.data.camp_id) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 道具相关
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 道具更新
|
||
|
|
onBagItemUpdate: function onBagItemUpdate(_bagCode, _itemList) {
|
||
|
|
var id1 = this.configs ? this.configs.item_id : -1;
|
||
|
|
for (var k in _itemList) {
|
||
|
|
var tm = _itemList[k];
|
||
|
|
if (tm.base_id == id1) {
|
||
|
|
this.freshTips();
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 获取道具数量
|
||
|
|
itemHave: function itemHave() {
|
||
|
|
if (nx.dt.objEmpty(this.configs) || !nx.dt.numPositive(this.configs.item_id, false)) {
|
||
|
|
nx.error("$SummonLimit:\u83B7\u53D6\u9053\u5177\u6570\u91CF\u5931\u8D25! " + this.data.camp_id);
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
var BC = BackPackController.getInstance();
|
||
|
|
return BC.getModel().getBackPackItemNumByBid(this.configs.item_id);
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 活动红点提示
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 活动用到的提示KEY
|
||
|
|
tipKeys: function tipKeys() {
|
||
|
|
return ["once", "ten", "score"];
|
||
|
|
},
|
||
|
|
// 红点提示更新
|
||
|
|
freshTips: function freshTips() {
|
||
|
|
this.openTip("reward", false);
|
||
|
|
if (!this.configs) {
|
||
|
|
this.openTip("once", false);
|
||
|
|
this.openTip("ten", false);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 抽取提示
|
||
|
|
var count = this.itemHave();
|
||
|
|
this.openTip("once", count >= this.configs.item_once[0][1]);
|
||
|
|
this.openTip("ten", count >= this.configs.item_ten[0][1]);
|
||
|
|
|
||
|
|
// VIP积分
|
||
|
|
var role = RoleController.getInstance().getRoleVo();
|
||
|
|
var key = game.configs.item_data.data_assets_id2label[this.configs.score_id];
|
||
|
|
var score = role[key];
|
||
|
|
if (role.vip_lev >= this.configs.score_vip && score >= this.configs.score_limit) {
|
||
|
|
this.openTip("score", true);
|
||
|
|
} else {
|
||
|
|
this.openTip("score", false);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 配置相关
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 获取配置
|
||
|
|
queryConfigs: function queryConfigs() {
|
||
|
|
var DATA = game.configs.recruit_gather_data;
|
||
|
|
if (!DATA) {
|
||
|
|
nx.error("$TeamSummon:\u914D\u7F6E\u8868\u7F3A\u5931!");
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
var cfgs = DATA.data_partnersummon_const;
|
||
|
|
var info = DATA.data_partnersummon_data[this.data.camp_id];
|
||
|
|
if (!cfgs || !info) {
|
||
|
|
nx.error("$TeamSummon:\u914D\u7F6E\u7F3A\u5931! " + this.data.camp_id);
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
var ret = nx.dt.objClone(info);
|
||
|
|
ret.item_id = cfgs.common_s.val;
|
||
|
|
ret.score_id = cfgs.gpoints.val;
|
||
|
|
ret.score_limit = cfgs.gpoints_per.val;
|
||
|
|
ret.score_vip = cfgs.gather_vip.val;
|
||
|
|
ret.rule = cfgs.rules.desc;
|
||
|
|
return ret;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 模块导出
|
||
|
|
module.exports = ActTeamSummonMod3;
|
||
|
|
|
||
|
|
cc._RF.pop();
|