251 lines
6.7 KiB
JavaScript
251 lines
6.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '94f21CxFpJJLJpgNAfVaXWy', 'act.stepup.mod');
|
|
// Scripts/mod/acts/stepup/act.stepup.mod.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 活动: StepUP
|
|
*
|
|
******************************************************************/
|
|
|
|
var ActBase = require("act.base");
|
|
var SummonDefine = require("summon.define");
|
|
var HeroController = require("hero_controller");
|
|
var FID = require("bridge.function.ids");
|
|
|
|
// 桥接替换的界面
|
|
|
|
var STStage = SummonDefine.StepUpStage;
|
|
var ActStepUp = cc.Class({
|
|
"extends": ActBase,
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
// 视图附着
|
|
nx.plugin.add(this, ["view"]);
|
|
this.vattach("Acts");
|
|
},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(23236, this.handle23236.bind(this));
|
|
this.RegisterProtocal(23237, this.handle23237.bind(this));
|
|
this.RegisterProtocal(23240, this.handle23240.bind(this));
|
|
this.RegisterProtocal(23238, this.handle23238.bind(this));
|
|
this.RegisterProtocal(23239, this.handle23239.bind(this));
|
|
this.RegisterProtocal(23241, this.handle23241.bind(this));
|
|
this.RegisterProtocal(23243, this.handle23243.bind(this));
|
|
},
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
// 配置加载
|
|
var cfgs = ["step_up_recruit_data" // step——up 召唤
|
|
];
|
|
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.fetchData(_cb);
|
|
});
|
|
},
|
|
// 原始数据
|
|
getData: function getData() {
|
|
return this.stepData || {
|
|
state: STStage.Empty,
|
|
// 开启状态
|
|
gold_times: 0,
|
|
// 钻石次数
|
|
camp_id: 0,
|
|
// 活动ID
|
|
turns: 0,
|
|
// 轮次信息
|
|
step: 0,
|
|
// 当前步骤
|
|
debris_num: 0,
|
|
// 碎片数量
|
|
integral: 0,
|
|
// 积分
|
|
reward_status: 0,
|
|
// 最终奖励是否领取
|
|
get_reward: [] // 达成奖励领取情况
|
|
};
|
|
},
|
|
|
|
// 当前配置
|
|
getConfig: function getConfig() {
|
|
// 已经存在
|
|
if (nx.dt.objNEmpty(this.stepConfigs)) {
|
|
return this.stepConfigs;
|
|
}
|
|
|
|
// 活动无效
|
|
if (nx.dt.objEmpty(this.stepData) || !nx.dt.numPositive(this.stepData.camp_id, false)) {
|
|
this.stepConfigs = null;
|
|
nx.error("STEP-UP 当前配置无效!");
|
|
return null;
|
|
}
|
|
|
|
// 配置无效
|
|
var DATA = game.configs.step_up_recruit_data;
|
|
var campId = this.stepData.camp_id;
|
|
if (nx.dt.objEmpty(DATA.data_action[campId])) {
|
|
this.stepConfigs = null;
|
|
nx.error("STEP-UP 当前配置无效:", campId);
|
|
return null;
|
|
}
|
|
var data = {
|
|
diamond_times: DATA.data_const.diamond_times,
|
|
turns: DATA.data_const.turns,
|
|
cfgs: nx.dt.objClone(DATA.data_action[campId]),
|
|
rewards: DATA.data_reward_items[campId],
|
|
steps: []
|
|
};
|
|
var SINFO = DATA.data_interface;
|
|
var groups = data.cfgs.group_id;
|
|
for (var i = 0; i < groups.length; ++i) {
|
|
var gid = groups[i];
|
|
var tmp = SINFO[gid];
|
|
if (nx.dt.objEmpty(tmp)) {
|
|
nx.error("STEP-UP 无效的group配置:", gid);
|
|
continue;
|
|
}
|
|
data.steps.push(tmp);
|
|
}
|
|
this.stepConfigs = data;
|
|
return data;
|
|
},
|
|
// 信息请求
|
|
fetchData: function fetchData(_cb) {
|
|
this.SendProtocal(23237, {}, _cb);
|
|
},
|
|
// 信息请求返回
|
|
handle23237: function handle23237(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
var props = this.getData();
|
|
nx.dt.copyProperties(props, _data);
|
|
this.stepData = props;
|
|
this.stepConfigs = null;
|
|
this.freshTips();
|
|
},
|
|
// 信息更新推送
|
|
handle23240: function handle23240(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
var props = this.getData();
|
|
nx.dt.copyProperties(props, _data);
|
|
this.stepData = props;
|
|
gcore.GlobalEvent.fire(SummonDefine.StepUpFresh);
|
|
this.freshTips();
|
|
},
|
|
// 召唤请求
|
|
reqSummon: function reqSummon(_type, _cb) {
|
|
// 容量检查
|
|
if (!this.checkVolume(10)) {
|
|
nx.tbox("PartnerBagFull");
|
|
nx.bridge.jumper.jump2Window(FID.Recycle);
|
|
return;
|
|
}
|
|
this.SendProtocal(23236, {
|
|
times: 10,
|
|
recruit_type: _type
|
|
}, _cb);
|
|
},
|
|
// 背包容量检查
|
|
checkVolume: function checkVolume(_count) {
|
|
var HC = HeroController.getInstance();
|
|
var HM = HC.getModel();
|
|
|
|
// 背包容量判断
|
|
var bagInfo = HM.getHeroMaxCount();
|
|
var remains = bagInfo.max_count - bagInfo.have_coutn;
|
|
return _count <= remains;
|
|
},
|
|
// 召唤请求返回
|
|
handle23236: function handle23236(_data) {},
|
|
// 角色奖励
|
|
reqReward: function reqReward(_cb) {
|
|
this.SendProtocal(23238, {}, _cb);
|
|
},
|
|
// 角色奖励回复
|
|
handle23238: function handle23238(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
// 轮次奖励
|
|
reqTurnReward: function reqTurnReward(_turn, _cb) {
|
|
this.SendProtocal(23239, {
|
|
turn: _turn
|
|
}, _cb);
|
|
},
|
|
// 轮次奖励回复
|
|
handle23239: function handle23239(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
// 请求排行榜
|
|
reqRankList: function reqRankList(_cb) {
|
|
this.SendProtocal(23241, {}, _cb);
|
|
},
|
|
// 排行榜回复
|
|
handle23241: function handle23241(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
this.rankData = _data;
|
|
},
|
|
// ============================================================
|
|
// 礼包相关
|
|
// ============================================================
|
|
|
|
// 礼包请求
|
|
reqGiftList: function reqGiftList(_cb) {
|
|
this.SendProtocal(23243, {}, _cb);
|
|
},
|
|
// 礼包更新
|
|
handle23243: function handle23243(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
this.vset("stepGifts", _data.gift_buy_info || []);
|
|
},
|
|
// ============================================================
|
|
// 活动红点提示
|
|
// ============================================================
|
|
|
|
// 活动用到的提示KEY
|
|
tipKeys: function tipKeys() {
|
|
return ["card", "rd2", "rd4", "rd6", "rd8", "rd10"];
|
|
},
|
|
// 红点提示更新
|
|
freshTips: function freshTips() {
|
|
var _this2 = this;
|
|
var keys = [2, 4, 6, 8, 10];
|
|
var data = this.getData();
|
|
if (data.state != STStage.Open && data.state != STStage.Complete) {
|
|
this.openTip("card", false);
|
|
keys.forEach(function (_t) {
|
|
_this2.openTip("rd" + _t, false);
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 轮次奖励
|
|
keys.forEach(function (_t) {
|
|
var got = nx.dt.arrMember(data.get_reward, null, function (_m) {
|
|
return _m && _m.turn == _t;
|
|
});
|
|
_this2.openTip("rd" + _t, !got && _t <= data.turns);
|
|
});
|
|
|
|
// 收卡
|
|
var tip = data.debris_num >= 10 && data.reward_status == 0;
|
|
this.openTip("card", tip);
|
|
}
|
|
});
|
|
module.exports = ActStepUp;
|
|
|
|
cc._RF.pop(); |