209 lines
5.1 KiB
JavaScript
209 lines
5.1 KiB
JavaScript
|
|
/*******************************************************************************
|
||
|
|
*
|
||
|
|
* 活动: 升星有禮活動
|
||
|
|
*
|
||
|
|
*
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
const ActBase = require( "act.base" );
|
||
|
|
|
||
|
|
const SevenGoal = cc.Class( {
|
||
|
|
|
||
|
|
extends: ActBase,
|
||
|
|
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function() {
|
||
|
|
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add( this, [ "view" ] );
|
||
|
|
this.vattach( "Acts" );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function() {
|
||
|
|
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( _cb ) {
|
||
|
|
let cfgs = [
|
||
|
|
this.data.config,
|
||
|
|
]
|
||
|
|
this.loadConfigs( cfgs, ( _ret, _data ) =>{
|
||
|
|
this.reqBaseData(_cb);
|
||
|
|
} )
|
||
|
|
},
|
||
|
|
|
||
|
|
// 请求剧情信息
|
||
|
|
reqBaseData: function( _cb ) {
|
||
|
|
this.reqSevenData(_cb);
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
reqSevenData( _cb ){
|
||
|
|
this.send13604(_cb);
|
||
|
|
},
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// 周期七日目标操作
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
//任務信息
|
||
|
|
send13604(_cb){
|
||
|
|
this.SendProtocal(13604, {},_cb)
|
||
|
|
},
|
||
|
|
|
||
|
|
handle13604: function( _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( _data ) {
|
||
|
|
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let base_data = this.vget("sevenGoalData");
|
||
|
|
//检查任务完成度
|
||
|
|
let list = base_data.list;
|
||
|
|
for(let i=0;i<list.length;i++){
|
||
|
|
for(let 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(_id,_cb){
|
||
|
|
this.SendProtocal(13606, {
|
||
|
|
id:_id
|
||
|
|
},_cb)
|
||
|
|
},
|
||
|
|
|
||
|
|
handle13606: function( _data ) {
|
||
|
|
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//等级奖励展示
|
||
|
|
send13607(_cb){
|
||
|
|
this.SendProtocal(13607,{},_cb)
|
||
|
|
},
|
||
|
|
|
||
|
|
handle13607: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
this.vset("sevenGoalRewards",[]);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.vset("sevenGoalRewards",_data.reward_list);
|
||
|
|
this.setLev(_data.lev);
|
||
|
|
},
|
||
|
|
|
||
|
|
//领取等级奖励
|
||
|
|
send13608(_id,_cb){
|
||
|
|
this.SendProtocal(13608,{
|
||
|
|
id:_id
|
||
|
|
},_cb)
|
||
|
|
},
|
||
|
|
|
||
|
|
handle13608: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
handle13609: function( _data ) {
|
||
|
|
if( !this.isGoodData( _data ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setLev(_data.lev);
|
||
|
|
this.setExp(_data.exp);
|
||
|
|
},
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// 活动红点提示
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 活动用到的提示KEY
|
||
|
|
tipKeys: function() {
|
||
|
|
return ["dayTask","tagTask"];
|
||
|
|
},
|
||
|
|
|
||
|
|
// 红点提示更新
|
||
|
|
freshTips: function() {
|
||
|
|
let data = this.vget("sevenGoalData");
|
||
|
|
let tasks = data.list;
|
||
|
|
let group_list = game.configs.day_goals_new_data.data_group_list[data.period];
|
||
|
|
let charge_list = game.configs.day_goals_new_data.data_charge_list[data.period];
|
||
|
|
let is_group = false;
|
||
|
|
let is_charge = false;
|
||
|
|
for(let 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(time){
|
||
|
|
this.end_time = time;
|
||
|
|
},
|
||
|
|
|
||
|
|
getEndTime(){
|
||
|
|
if(this.end_time){
|
||
|
|
return this.end_time;
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
},
|
||
|
|
|
||
|
|
setLev(lev){
|
||
|
|
this.task_lev = lev;
|
||
|
|
},
|
||
|
|
|
||
|
|
getLev(){
|
||
|
|
if(this.task_lev){
|
||
|
|
return this.task_lev;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
|
||
|
|
setExp(exp){
|
||
|
|
this.task_exp = exp;
|
||
|
|
},
|
||
|
|
|
||
|
|
getExp(){
|
||
|
|
if(this.task_exp){
|
||
|
|
return this.task_exp;
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
},
|
||
|
|
} );
|
||
|
|
|
||
|
|
// 模块导出
|
||
|
|
module.exports = SevenGoal;
|