186 lines
5.0 KiB
JavaScript
186 lines
5.0 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '2f9b6p1b4FPM7hzGqRhytYr', 'act.seven.mod');
|
|
// Scripts/mod/acts/sevengoal/act.seven.mod.js
|
|
|
|
"use strict";
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* 活动: 升星有禮活動
|
|
*
|
|
*
|
|
******************************************************************************/
|
|
|
|
var ActBase = require("act.base");
|
|
var SevenGoal = cc.Class({
|
|
"extends": ActBase,
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
// 视图附着
|
|
nx.plugin.add(this, ["view"]);
|
|
this.vattach("Acts");
|
|
},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(13604, this.handle13604); // 任务信息
|
|
this.RegisterProtocal(13605, this.handle13605); // 任务信息更新
|
|
this.RegisterProtocal(13606, this.handle13606); // 提交任务
|
|
this.RegisterProtocal(13607, this.handle13607); // 等级奖励展示
|
|
this.RegisterProtocal(13608, this.handle13608); // 领取等级礼包,推送13607
|
|
this.RegisterProtocal(13609, this.handle13609); // 等级变更,服务端主动推
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
var cfgs = [this.data.config];
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.reqBaseData(_cb);
|
|
});
|
|
},
|
|
// 请求剧情信息
|
|
reqBaseData: function reqBaseData(_cb) {
|
|
this.reqSevenData(_cb);
|
|
},
|
|
reqSevenData: function reqSevenData(_cb) {
|
|
this.send13604(_cb);
|
|
},
|
|
// ============================================================
|
|
// 周期七日目标操作
|
|
// ============================================================
|
|
//任務信息
|
|
send13604: function send13604(_cb) {
|
|
this.SendProtocal(13604, {}, _cb);
|
|
},
|
|
handle13604: function handle13604(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
this.vset("sevenGoalData", {});
|
|
return;
|
|
}
|
|
this.setLev(_data.lev);
|
|
this.setExp(_data.exp);
|
|
this.setEndTime(_data.end_time);
|
|
this.vset("sevenGoalData", _data);
|
|
// 提示刷新
|
|
this.freshTips();
|
|
},
|
|
handle13605: function handle13605(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
var base_data = this.vget("sevenGoalData");
|
|
//检查任务完成度
|
|
var list = base_data.list;
|
|
for (var i = 0; i < list.length; i++) {
|
|
for (var j = 0; j < _data.list.length; j++) {
|
|
if (list[i].id == _data.list[j].id) {
|
|
list[i] = _data.list[j];
|
|
}
|
|
}
|
|
}
|
|
base_data.list = list;
|
|
this.vset("sevenGoalData", base_data);
|
|
// 提示刷新
|
|
this.freshTips();
|
|
},
|
|
//提交任务
|
|
send13606: function send13606(_id, _cb) {
|
|
this.SendProtocal(13606, {
|
|
id: _id
|
|
}, _cb);
|
|
},
|
|
handle13606: function handle13606(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
//等级奖励展示
|
|
send13607: function send13607(_cb) {
|
|
this.SendProtocal(13607, {}, _cb);
|
|
},
|
|
handle13607: function handle13607(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
this.vset("sevenGoalRewards", []);
|
|
return;
|
|
}
|
|
this.vset("sevenGoalRewards", _data.reward_list);
|
|
this.setLev(_data.lev);
|
|
},
|
|
//领取等级奖励
|
|
send13608: function send13608(_id, _cb) {
|
|
this.SendProtocal(13608, {
|
|
id: _id
|
|
}, _cb);
|
|
},
|
|
handle13608: function handle13608(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
},
|
|
handle13609: function handle13609(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
this.setLev(_data.lev);
|
|
this.setExp(_data.exp);
|
|
},
|
|
// ============================================================
|
|
// 活动红点提示
|
|
// ============================================================
|
|
|
|
// 活动用到的提示KEY
|
|
tipKeys: function tipKeys() {
|
|
return ["dayTask", "tagTask"];
|
|
},
|
|
// 红点提示更新
|
|
freshTips: function freshTips() {
|
|
var data = this.vget("sevenGoalData");
|
|
var tasks = data.list;
|
|
var group_list = game.configs.day_goals_new_data.data_group_list[data.period];
|
|
var charge_list = game.configs.day_goals_new_data.data_charge_list[data.period];
|
|
var is_group = false;
|
|
var is_charge = false;
|
|
for (var i = 0; i < tasks.length; i++) {
|
|
if (group_list[tasks[i].id] && tasks[i].finish == 1) {
|
|
is_group = true;
|
|
}
|
|
if (charge_list[tasks[i].id] && tasks[i].finish == 1) {
|
|
is_charge = true;
|
|
}
|
|
}
|
|
this.openTip("dayTask", is_group);
|
|
this.openTip("tagTask", is_charge);
|
|
},
|
|
setEndTime: function setEndTime(time) {
|
|
this.end_time = time;
|
|
},
|
|
getEndTime: function getEndTime() {
|
|
if (this.end_time) {
|
|
return this.end_time;
|
|
}
|
|
return 0;
|
|
},
|
|
setLev: function setLev(lev) {
|
|
this.task_lev = lev;
|
|
},
|
|
getLev: function getLev() {
|
|
if (this.task_lev) {
|
|
return this.task_lev;
|
|
}
|
|
return 1;
|
|
},
|
|
setExp: function setExp(exp) {
|
|
this.task_exp = exp;
|
|
},
|
|
getExp: function getExp() {
|
|
if (this.task_exp) {
|
|
return this.task_exp;
|
|
}
|
|
return 0;
|
|
}
|
|
});
|
|
|
|
// 模块导出
|
|
module.exports = SevenGoal;
|
|
|
|
cc._RF.pop(); |