160 lines
4.2 KiB
JavaScript
160 lines
4.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'f5bd9ou495NEY46Ej4Nq9Eu', 'act.elite.mod');
|
||
|
|
// Scripts/mod/acts/elite/act.elite.mod.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 活动: 精英召唤
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var ActBase = require("act.base");
|
||
|
|
var ActEliteSummon = cc.Class({
|
||
|
|
"extends": ActBase,
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function initConfig() {
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add(this, ["view"]);
|
||
|
|
this.vattach("Acts");
|
||
|
|
},
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function registerProtocals() {
|
||
|
|
this.RegisterProtocal(23230, this.handle23230.bind(this));
|
||
|
|
this.RegisterProtocal(23232, this.handle23232.bind(this));
|
||
|
|
this.RegisterProtocal(23231, this.handle23231.bind(this));
|
||
|
|
this.RegisterProtocal(23233, this.handle23233.bind(this));
|
||
|
|
this.RegisterProtocal(23244, this.handle23244.bind(this));
|
||
|
|
},
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
||
|
|
var _this = this;
|
||
|
|
// 配置加载
|
||
|
|
var cfgs = ["recruit_holiday_lucky_data" // 5选一精英召唤
|
||
|
|
];
|
||
|
|
|
||
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
||
|
|
_this.fetchData(_cb);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 基本信息
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 信息请求
|
||
|
|
fetchData: function fetchData(_cb) {
|
||
|
|
this.SendProtocal(23230, {}, _cb);
|
||
|
|
},
|
||
|
|
// 数据整理
|
||
|
|
updateData: function updateData(_data, _reset) {
|
||
|
|
if (_reset === void 0) {
|
||
|
|
_reset = false;
|
||
|
|
}
|
||
|
|
if (nx.dt.objEmpty(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 基础数据更新
|
||
|
|
var old = this.vget("eliteBase");
|
||
|
|
if (_reset || old.lucky_bid != _data.lucky_bid) {
|
||
|
|
this.vset("eliteBase", {
|
||
|
|
camp_id: _data.camp_id,
|
||
|
|
end_time: _data.end_time,
|
||
|
|
item_id: _data.item_id,
|
||
|
|
item_num: _data.item_num,
|
||
|
|
lucky_bid: _data.lucky_bid,
|
||
|
|
reward_list: _data.reward_list || [],
|
||
|
|
start_time: _data.start_time
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// 次数数据更新
|
||
|
|
this.vset("eliteTimes", {
|
||
|
|
free_time: _data.free_time,
|
||
|
|
gold_time: _data.gold_time,
|
||
|
|
must_count: _data.must_count,
|
||
|
|
times: _data.times
|
||
|
|
});
|
||
|
|
this.freshTips();
|
||
|
|
},
|
||
|
|
// 信息请求返回
|
||
|
|
handle23230: function handle23230(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.updateData(_data, true);
|
||
|
|
},
|
||
|
|
// 更新推送
|
||
|
|
handle23232: function handle23232(_data) {
|
||
|
|
this.updateData(_data, false);
|
||
|
|
},
|
||
|
|
// 请求更换许愿目标
|
||
|
|
reqTarget: function reqTarget(_bid, _cb) {
|
||
|
|
this.SendProtocal(23233, {
|
||
|
|
lucky_bid: _bid
|
||
|
|
}, _cb);
|
||
|
|
},
|
||
|
|
// 更换许愿目标回复
|
||
|
|
handle23233: function handle23233(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 召唤操作
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 召唤请求
|
||
|
|
reqSummon: function reqSummon(_times, _type, _cb) {
|
||
|
|
this.SendProtocal(23231, {
|
||
|
|
times: _times,
|
||
|
|
recruit_type: _type
|
||
|
|
}, _cb);
|
||
|
|
},
|
||
|
|
// 精英召唤返回
|
||
|
|
handle23231: function handle23231(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 排行榜
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 排行榜请求
|
||
|
|
reqRankList: function reqRankList(_today, _cb) {
|
||
|
|
this.SendProtocal(23244, {
|
||
|
|
type: _today ? 57 : 58
|
||
|
|
}, _cb);
|
||
|
|
},
|
||
|
|
// 排行榜
|
||
|
|
handle23244: function handle23244(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 活动红点提示
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 活动用到的提示KEY
|
||
|
|
tipKeys: function tipKeys() {
|
||
|
|
return ["free"];
|
||
|
|
},
|
||
|
|
// 红点提示更新
|
||
|
|
freshTips: function freshTips() {
|
||
|
|
var base = this.vget("eliteBase");
|
||
|
|
var times = this.vget("eliteTimes");
|
||
|
|
|
||
|
|
// 奖励关闭
|
||
|
|
this.openTip("reward", false);
|
||
|
|
|
||
|
|
// 免费
|
||
|
|
var tip = base.camp_id != 0 && times.free_time == 0;
|
||
|
|
this.openTip("free", tip);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
module.exports = ActEliteSummon;
|
||
|
|
|
||
|
|
cc._RF.pop();
|