758 lines
27 KiB
JavaScript
758 lines
27 KiB
JavaScript
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 这里填写详细说明,主要填写该模块的功能简要
|
|
// <br/>Create: 2019-01-09 11:26:10
|
|
// --------------------------------------------------------------------
|
|
const BridgeClass = require( "bridge.class" );
|
|
var TaskConst = require( "task_const" );
|
|
var RoleController = require( "role_controller" );
|
|
var TaskEvent = require( "task_event" );
|
|
var TaskVo = require( "task_vo" );
|
|
const FID = require( "bridge.function.ids" );
|
|
|
|
|
|
var TaskModel = cc.Class( {
|
|
extends: BridgeClass,
|
|
ctor: function() {
|
|
this.ctrl = arguments[ 0 ];
|
|
},
|
|
|
|
properties: {
|
|
},
|
|
|
|
initConfig: function() {
|
|
this.task_list = []; //当前所有任务数据
|
|
this.task_status_list = []; //任务icon的红点状态
|
|
this.update_feat_status_list = []; //待更新成就状态,延迟更新的
|
|
this.dic_task_exp_data = {};
|
|
this.showDaily = 0;
|
|
|
|
this.main_task_data = []; // 類型 1 的成就任務
|
|
this.achieve_task_data = []; // 類型 11 的成長引導任務
|
|
this.battle_task_data = []; // 類型 10 的其他副本戰鬥任務
|
|
this.branch_task_data = []; // 類型 2 的親密度培養任務
|
|
this.tasks = [];
|
|
// 成就相关
|
|
this.achievement_score = 0;
|
|
this.achievement_score_tar = 0;
|
|
this.achievement_dicts = [];
|
|
this.achievement_list = {};
|
|
this.finish_achievement_list = [];
|
|
|
|
},
|
|
|
|
// @desc:需要检测的红点状态,分活跃度,任务或者成就3中
|
|
// author:{author}
|
|
// time:2018-05-22 15:50:49
|
|
// --@type:
|
|
// return
|
|
checkQuestAndFeatStatus: function( type ) {
|
|
var red_status = false;
|
|
if( type == TaskConst.update_type.activity ) {
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
|
if( role_vo != null && this.activity_data != null ) {
|
|
for( var i in game.configs.activity_data.data_get ) {
|
|
var v = game.configs.activity_data.data_get[ i ];
|
|
if( role_vo.activity >= v.activity && !this.activity_data[ v.activity ] ) {
|
|
red_status = true;
|
|
break
|
|
}
|
|
}
|
|
}
|
|
} else if( type == TaskConst.update_type.quest ) {
|
|
if( this.task_list != null ) {
|
|
for( var k in this.task_list ) {
|
|
var v = this.task_list[ k ];
|
|
if( v.finish == TaskConst.task_status.finish ) {
|
|
red_status = true;
|
|
break
|
|
}
|
|
}
|
|
}
|
|
} else if( type == TaskConst.update_type.feat ) {
|
|
if( this.achievement_list != null ) {
|
|
for( var k in this.achievement_list ) {
|
|
var v = this.achievement_list[ k ];
|
|
if( v.finish == TaskConst.task_status.finish ) {
|
|
red_status = true;
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// if( this.red_status_list == null ) {
|
|
// this.red_status_list = [];
|
|
// }
|
|
|
|
// if( this.red_status_list[ type ] == null || ( this.red_status_list[ type ] != null && this.red_status_list[ type ] != red_status ) ) {
|
|
// this.red_status_list[ type ] = red_status;
|
|
// //抛出事件更新红点
|
|
// gcore.GlobalEvent.fire( TaskEvent.UpdateUIRedStatus, type, red_status );
|
|
// }
|
|
|
|
// //红点状态
|
|
// var num = 0;
|
|
// if( red_status == true )
|
|
// num = 1;
|
|
},
|
|
|
|
// @desc:用于日常面板上的红点接口判断
|
|
// author:{author}
|
|
// time:2018-05-28 14:41:18
|
|
// --@type:
|
|
// return
|
|
getRedStatus: function( type ) {
|
|
if( this.red_status_list == null )
|
|
return false
|
|
return this.red_status_list[ type ]
|
|
},
|
|
|
|
// @desc:更新整个活跃度数据,只有在上线或者断线重连的时候更新
|
|
// author:{author}
|
|
// time:2018-05-22 16:14:11
|
|
// --@data:
|
|
// return
|
|
updateActivityData: function( data_list ) {
|
|
this.activity_data = {};
|
|
for( var k in data_list ) {
|
|
var v = data_list[ k ];
|
|
this.activity_data[ v.activity ] = true;
|
|
}
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.activity );
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateActivityInfo, this.activity_data );
|
|
},
|
|
|
|
// @desc:领取某个活跃度宝箱之后的更新,更新单个的
|
|
// author:{author}
|
|
// time:2018-05-22 16:14:40
|
|
// --@activity:
|
|
// return
|
|
updateSingleActivityData: function( activity ) {
|
|
if( this.activity_data == null )
|
|
return
|
|
this.activity_data[ activity ] = true;
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.activity );
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateActivityInfo, this.activity_data );
|
|
},
|
|
|
|
getActivityData: function() {
|
|
return this.activity_data
|
|
},
|
|
|
|
//desc:增加或者更新任务
|
|
//time:2018-07-19 05:58:51
|
|
//@task_list:
|
|
//@is_update:
|
|
//@return
|
|
addTaskList: function( task_list, is_update, is_init ) {
|
|
|
|
// this.setMainTaskData( { quest_list :task_list } );
|
|
if( !game.configs.quest_data ) {
|
|
return;
|
|
}
|
|
let showDaily = 0;
|
|
this.new_task = task_list;
|
|
var taskVo, config = null;
|
|
var is_new = false;
|
|
var finish_list = [];
|
|
if( nx.dt.objNEmpty( this.allTask_data ) ){
|
|
for (let o in this.allTask_data ) {
|
|
let task = this.allTask_data[o];
|
|
for (let p in task ) {
|
|
let taskl = task[p];
|
|
let tc = [];
|
|
taskl.forEach( _task =>{
|
|
tc.push( tc );
|
|
} )
|
|
for (let i = 0; i < taskl.length; i++) {
|
|
let taskc = taskl[i];
|
|
|
|
for (let c = 0; c < task_list.length; c++) {
|
|
let taskn = task_list[c];
|
|
if( taskn.id == taskc.id ){
|
|
taskc.finish = taskn.finish;
|
|
taskc.canshow = true;
|
|
taskc.show = 1;
|
|
}
|
|
if( taskn.type == TaskConst.task_type.daily ){
|
|
showDaily++;
|
|
}
|
|
// if( taskn.type == taskc.type ){
|
|
// if( !nx.dt.arrMember( tc, taskn.id ) ){
|
|
// taskl.push( taskn );
|
|
// // break;
|
|
// }else{
|
|
// if( taskn.id == taskc.id ){
|
|
// taskc.finish = taskn.finish;
|
|
// taskc.canshow = true;
|
|
// taskc.show = 1;
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
for (let c = 0; c < task_list.length; c++) {
|
|
let taskn = task_list[c];
|
|
|
|
if( taskn.type == TaskConst.task_type.daily ){
|
|
showDaily++;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if( showDaily > 0 ){
|
|
let count = 0;
|
|
if( is_init == true )
|
|
this.task_list = [];
|
|
this.showDaily = 0;
|
|
for( var i in task_list ) {
|
|
var v = task_list[ i ];
|
|
|
|
config = game.configs.quest_data.data_get[ v.id ];
|
|
if( config != null ) {
|
|
if( config.type == TaskConst.task_type.daily ){
|
|
if( this.task_list[ v.id ] == null ) {
|
|
this.task_list[ v.id ] = new TaskVo( v.id, TaskConst.type.quest );
|
|
is_new = true;
|
|
} else {
|
|
if( v.finish == 1 && is_update == true )
|
|
finish_list.push( v.id );
|
|
}
|
|
taskVo = this.task_list[ v.id ];
|
|
taskVo.updateData( v );
|
|
if( v.finish == 1 ){
|
|
count ++;
|
|
this.showDaily = count;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
nx.mTip.openTip( "daily.tip", this.showDaily > 0 );
|
|
}
|
|
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.quest );
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateTaskList,{ new: is_new, task: task_list } );
|
|
},
|
|
|
|
// @desc:设置一个任务为提交完成状态
|
|
// author:{author}
|
|
// time:2018-05-22 16:27:46
|
|
// --@id:
|
|
// return
|
|
setTaskCompleted: function( id ) {
|
|
var taskVo = this.task_list[ id ];
|
|
|
|
[ {"type":"1","deep":1,"elements": [
|
|
{"type":"第1章","deep":2,"elements":[
|
|
{"id":10001,"name":"指挥官在梦境中遇到了神秘女子,增长了见闻","lev":1,"type":1,"group":0,"group_desc":"第1章","desc":"角色升到10级","progress":[{"cli_label":"evt_levup","target":0,"target_val":10,"param":[],"value":10,"finish":1}],"extra":[],"commit_rewards":[],"res":"","finish":1,"show":1}]},
|
|
{"type":"第2章","deep":2,"elements":[{"id":10002,"name":"指挥官教训了小喽喽","lev":1,"type":1,"group":0,"group_desc":"第2章","desc":"角色升到20级","progress":[{"cli_label":"evt_levup","target":0,"target_val":20,"param":[],"value":0,"finish":0}],"extra":[],"commit_rewards":[],"res":"","finish":0,"show":0}]}
|
|
]
|
|
}
|
|
]
|
|
if( this.allTask_data ){
|
|
for (let o in this.allTask_data ) {
|
|
let task = this.allTask_data[o];
|
|
for (let p in task ) {
|
|
let taskl = task[p];
|
|
for (let i = 0; i < taskl.length; i++) {
|
|
let item = taskl[i];
|
|
if( item.id == id ){
|
|
item.finish = 2;
|
|
if( item.type != 2 ){
|
|
item.canshow = false;
|
|
taskl.splice( item, 1 );
|
|
}else{
|
|
item.canshow = true;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < this.main_task_data.length; i++) {
|
|
let item = this.main_task_data[i];
|
|
if( item.type == TaskConst.task_type.main ){
|
|
let moreInfo = item.elements;
|
|
for (let j = 0; j < moreInfo.length; j++) {
|
|
let qitems = moreInfo[j];
|
|
let qs = qitems.elements;
|
|
for (let o = 0; o < qs.length; o++) {
|
|
let litem = qs[o];
|
|
if( litem.id == id ){
|
|
litem.finish = 2;
|
|
qs.splice( item, 1 );
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// console.log( "当前的主线任务的相关数据model3333333" + JSON.stringify( this.allTask_data ) );
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateTaskList,false );
|
|
if( taskVo != null ) {
|
|
taskVo.setCompletedStatus( TaskConst.task_status.completed );
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.quest );
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateTaskList, false );
|
|
}
|
|
|
|
let count = 0;
|
|
for (let d in this.task_list ) {
|
|
let daily = this.task_list[d];
|
|
if( daily.finish == 1 ){
|
|
count ++;
|
|
}
|
|
// if( daily.id == id ){
|
|
|
|
|
|
// }
|
|
}
|
|
nx.mTip.openTip( "daily.tip", count > 0 );
|
|
},
|
|
|
|
// @desc:获取全部任务列表,这个根据 finish_sort 做了排序的
|
|
// author:{author}
|
|
// time:2018-05-22 19:23:23
|
|
// return
|
|
getTaskList: function() {
|
|
var task_list = [];
|
|
for( var k in this.task_list ) {
|
|
task_list.push( this.task_list[ k ] );
|
|
}
|
|
if( Utils.next( task_list ) ) {
|
|
task_list.sort( Utils.tableLowerSorter( [ "finish_sort", "id" ] ) );
|
|
}
|
|
return task_list
|
|
},
|
|
|
|
getTaskById: function( id ) {
|
|
return this.task_list[ id ];
|
|
},
|
|
|
|
//存贮主线任务数据 11 10
|
|
setMainTaskData: function( _data ) {
|
|
|
|
let _msgData = _data.quest_list;
|
|
// 任务的类型, 具体的类型下所包含的任务信息
|
|
let tfg = nx.dt.objClone( game.configs.quest_data.data_get );
|
|
// let tfgl = game.configs.quest_data.data_get_length;
|
|
// 返回缓存
|
|
// if( !this.allTask_data ){
|
|
// this.allTask_data = {};
|
|
// }else{
|
|
// return this.allTask_data;
|
|
// }
|
|
// // [
|
|
// {"id":10001,"type":1,"finish":0,"accept_time":0,"progress":[{"id":0,"finish":0,"target":10060,"target_val":1,"value":0,"ext_data":[]}]},
|
|
// {"id":10002,"type":1,"finish":0,"accept_time":0,"progress":[{"id":0,"finish":0,"target":10080,"target_val":1,"value":0,"ext_data":[]}]},
|
|
// {"id":10003,"type":1,"finish":0,"accept_time":0,"progress":[{"id":0,"finish":0,"target":10100,"target_val":1,"value":0,"ext_data":[]}]}
|
|
// ]}
|
|
|
|
|
|
|
|
let data = {};
|
|
for( let id in tfg ) {
|
|
|
|
|
|
let temp = nx.dt.objClone( tfg[ id ] ) ;
|
|
temp.value = 0;
|
|
// nx.dt.arrNEmpty( temp.progress ) ? temp.progress[0].value = 0 : temp.progress.value = 0 ;
|
|
// nx.dt.arrNEmpty( temp.progress ) ? temp.progress[0].finish = 0 : temp.progress.finish = 0 ;
|
|
temp.finish = 0;
|
|
temp.show = 0;
|
|
// temp.progress[0].finish = 0;
|
|
temp.canshow = false;
|
|
let key1 = temp.type;
|
|
if( this.new_task ){
|
|
if( !nx.dt.arrEmpty( this.new_task ) ){
|
|
for (let l = 0; l < this.new_task.length; l++) {
|
|
let _msg = this.new_task[l];
|
|
if( _msg ){
|
|
if( temp.id == _msg.id ){
|
|
temp.finish = _msg.finish;
|
|
temp.show = temp.finish && temp.finish != 2 ? 1 : 0;
|
|
// if( !nx.dt.arrEmpty( _msg.progress ) && !nx.dt.arrEmpty( temp.progress ) ){
|
|
// temp.progress[0].finish = _msg.progress[0].finish || 0;
|
|
// temp.progress[0].value = _msg.progress[0].value || 0;
|
|
|
|
// }else{
|
|
// // temp.value = 0;
|
|
// }
|
|
temp.canshow = temp.finish != 2;
|
|
}
|
|
}
|
|
|
|
}
|
|
}else{
|
|
|
|
}
|
|
|
|
}
|
|
for (let i = 0; i < _msgData.length; i++) {
|
|
let msg = _msgData[i];
|
|
if( msg ){
|
|
if( temp.id == msg.id ){
|
|
|
|
temp.finish = msg.finish;
|
|
temp.show = temp.finish != 2 ? 1 : 0;
|
|
// if( !nx.dt.arrEmpty( msg.progress ) && !nx.dt.arrEmpty( temp.progress ) ){
|
|
// temp.progress[0].finish = msg.progress[0].finish || 0;
|
|
// temp.progress[0].value = msg.progress[0].value || 0;
|
|
|
|
// }else{
|
|
// // temp.value = 0;
|
|
// }
|
|
if( temp.type != 2 ){
|
|
temp.canshow = temp.finish != 2;
|
|
}else{
|
|
temp.canshow = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
// console.log( "当前的任务刷新ssss" + JSON.stringify( temp ) );
|
|
if( temp.type != 3 && temp.finish != 2 ){
|
|
let key2 = temp.group_desc;
|
|
data[ key1 ] = data[ key1 ] || {};
|
|
data[ key1 ][ key2 ] = data[ key1 ][ key2 ] || [];
|
|
data[ key1 ][ key2 ].push( nx.dt.objClone( temp ) );
|
|
}
|
|
|
|
}
|
|
// console.log( "所有的任務信息" + JSON.stringify( data ) );
|
|
this.allTask_data = nx.dt.objClone(data);
|
|
|
|
// // { type: 1/2/3, stype: "类型", lst: [] }
|
|
if( !nx.dt.arrNEmpty( this.main_task_data ) || !nx.dt.arrNEmpty( this.branch_task_data ) ) {
|
|
for( let k1 in data ) {
|
|
// k1任务类型
|
|
let tree = { type: k1, deep: 1, elements: [] };
|
|
let temp = data[ k1 ];
|
|
// console.log( "当前的数据格式任务相关" + JSON.stringify( temp ) );
|
|
if( k1 == 1 ){
|
|
for( let k2 in temp ) {
|
|
tree.elements.push( {
|
|
type: k2,
|
|
deep: 2,
|
|
elements: temp[ k2 ],
|
|
} );
|
|
}
|
|
this.main_task_data.push( tree );
|
|
}
|
|
if( k1 == 2 ){
|
|
for( let k2 in temp ) {
|
|
tree.elements.push( {
|
|
type: k2,
|
|
deep: 2,
|
|
elements: temp[ k2 ],
|
|
} );
|
|
}
|
|
this.branch_task_data.push( tree );
|
|
}
|
|
if( k1 == 10 ){
|
|
for( let k2 in temp ) {
|
|
tree.elements.push( {
|
|
type: k2,
|
|
deep: 2,
|
|
elements: temp[ k2 ],
|
|
} );
|
|
}
|
|
this.branch_task_data.push( tree );
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this.main_task_data = data;
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateTaskList, data );
|
|
// return this.achievement_dicts;
|
|
},
|
|
|
|
getMainTaskData: function() {
|
|
|
|
return this.main_task_data;
|
|
},
|
|
|
|
getAllTaskInfo: function(){
|
|
|
|
return this.allTask_data;
|
|
},
|
|
|
|
getBranchTaskInfo: function(){
|
|
return this.branch_task_data;
|
|
},
|
|
|
|
updateTaskExpList: function( scdata, is_check_notice ) {
|
|
|
|
if( !scdata ) {
|
|
return;
|
|
}
|
|
|
|
let role_vo = RoleController.getInstance().getRoleVo();
|
|
if( !role_vo ) {
|
|
return;
|
|
}
|
|
|
|
if( !is_check_notice ) {
|
|
this.dic_task_exp_data = {};
|
|
}
|
|
|
|
if( scdata.achievement_list ) {
|
|
|
|
let finish_id_list = [];
|
|
let hide_finish_id_list = [];
|
|
|
|
for( let i in scdata.achievement_list ) {
|
|
|
|
let v = scdata.achievement_list[ i ];
|
|
if( this.dic_task_exp_data[ v.id ] ) {
|
|
for( let k in v ) {
|
|
this.dic_task_exp_data[ v.id ][ k ] = v[ k ];
|
|
}
|
|
}
|
|
// else {
|
|
// let config = game.configs.room_feat_data.data_exp_info[ v.id ];
|
|
// if( config ) {
|
|
// this.dic_task_exp_data[ v.id ] = new TaskVo( v.id, TaskConst.type.exp );
|
|
// for( let k in v ) {
|
|
// this.dic_task_exp_data[ v.id ][ k ] = v[ k ];
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
if( is_check_notice && this.dic_task_exp_data[ v.id ] &&
|
|
v.finish == TaskConst.task_status.finish &&
|
|
this.dic_task_exp_data[ v.id ].config ) {
|
|
let lev = this.dic_task_exp_data[ v.id ].config.lev || 0;
|
|
if( role_vo.lev >= lev ) {
|
|
if( this.dic_task_exp_data[ v.id ].config.hide == 1 ) {
|
|
hide_finish_id_list.push( v.id );
|
|
}
|
|
else {
|
|
finish_id_list.push( v.id );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 提示相关处理
|
|
if( is_check_notice ) {
|
|
|
|
// let config_limit = game.configs.room_feat_data.data_const.experience_open_limit;
|
|
// if( config_limit ) {
|
|
if( role_vo.lev >= 55 ) {
|
|
// 任务完成
|
|
if( finish_id_list.length == 0 ) {
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateExpTaskFinishTips, finish_id_list );
|
|
}
|
|
}
|
|
else {
|
|
// 任务完成
|
|
if( finish_id_list.length == 0 ) {
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateExpTaskFinishTips, finish_id_list );
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if( scdata.finish_list ) {
|
|
|
|
for( let i in scdata.finish_list ) {
|
|
let v = scdata.finish_list[ i ];
|
|
this.dic_task_exp_data[ v.id ].finish = TaskConst.task_status.completed;
|
|
for( let k in v ) {
|
|
this.dic_task_exp_data[ v.id ][ k ] = v[ k ];
|
|
}
|
|
// let config = game.configs.room_feat_data.data_exp_info[ v.id ];
|
|
// if( config ) {
|
|
// this.dic_task_exp_data[ v.id ] = new TaskVo( v.id, TaskConst.type.exp );
|
|
|
|
// }
|
|
}
|
|
}
|
|
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.exp );
|
|
},
|
|
|
|
updateTaskExpDataByID: function( id, time ) {
|
|
|
|
if( this.dic_task_exp_data[ id ] ) {
|
|
this.dic_task_exp_data[ id ].finish_time = time;
|
|
this.dic_task_exp_data[ id ].finish = TaskConst.task_status.completed;
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.exp );
|
|
}
|
|
},
|
|
|
|
getTaskExpList: function() {
|
|
return this.dic_task_exp_data || {};
|
|
},
|
|
|
|
getTaskExpListById: function( id ) {
|
|
if( this.dic_task_exp_data ) {
|
|
return this.dic_task_exp_data[ id ];
|
|
}
|
|
},
|
|
|
|
// =================================================================
|
|
// 成就相关
|
|
// =================================================================
|
|
|
|
// 获取成就字典
|
|
getAchievementDict: function() {
|
|
|
|
// 返回缓存
|
|
if( nx.dt.arrNEmpty( this.achievement_dicts ) ) {
|
|
return this.achievement_dicts;
|
|
}
|
|
|
|
let data = {};
|
|
const DATA = game.configs.feat_data.data_get;
|
|
for( let id in DATA ) {
|
|
let temp = DATA[ id ];
|
|
let key1 = temp.first_label;
|
|
let key2 = temp.name;
|
|
data[ key1 ] = data[ key1 ] || {};
|
|
data[ key1 ][ key2 ] = data[ key1 ][ key2 ] || [];
|
|
data[ key1 ][ key2 ].push( nx.dt.objClone( temp ) );
|
|
}
|
|
|
|
this.achievement_dicts = [];
|
|
for( let k1 in data ) {
|
|
let tree = { name: k1, deep: 1, elements: [] };
|
|
let temp = data[ k1 ];
|
|
for( let k2 in temp ) {
|
|
tree.elements.push( {
|
|
name: k2,
|
|
deep: 2,
|
|
elements: temp[ k2 ],
|
|
} );
|
|
}
|
|
this.achievement_dicts.push( tree );
|
|
}
|
|
|
|
return this.achievement_dicts;
|
|
},
|
|
|
|
// 获取成就任务项
|
|
getAchievementById: function( id ) {
|
|
return this.achievement_list[ id ];
|
|
},
|
|
|
|
// 设置成就积分
|
|
setAchievementScore: function( _cur, _tar ) {
|
|
this.achievement_score = _cur;
|
|
this.achievement_score_tar = _tar;
|
|
},
|
|
|
|
//desc:增加或者更新任务
|
|
//time:2018-07-19 05:59:30
|
|
//@achievement_list:
|
|
//@is_update:
|
|
//@return
|
|
addAchievements: function( achievement_list, is_update, is_init ) {
|
|
|
|
// 初始化重置
|
|
if( is_init == true ) {
|
|
this.achievement_list = {};
|
|
}
|
|
|
|
let is_new = false;
|
|
let finish_list = [];
|
|
let taskVo, config = null;
|
|
if( game.configs.feat_data ){
|
|
for( let i in achievement_list ) {
|
|
|
|
let v = achievement_list[ i ];
|
|
config = gdata( "feat_data", "data_get", [ v.id ] );
|
|
if( !config ) {
|
|
continue;
|
|
}
|
|
|
|
if( this.achievement_list[ v.id ] == null ) {
|
|
this.achievement_list[ v.id ] = new TaskVo( v.id, TaskConst.type.feat );
|
|
is_new = true;
|
|
} else {
|
|
if( v.finish == 1 && is_update == true ){
|
|
finish_list.push( v.id );
|
|
}
|
|
if( v.finish == 2 ){
|
|
this.setAchievementComplete( v.id );
|
|
}
|
|
}
|
|
taskVo = this.achievement_list[ v.id ];
|
|
taskVo.updateData( v );
|
|
}
|
|
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.feat );
|
|
this.notifyUpdateAchievements( is_new, finish_list );
|
|
}
|
|
|
|
|
|
},
|
|
|
|
setAchievementComplete: function( id ) {
|
|
var taskVo = this.achievement_list[ id ];
|
|
if( taskVo != null ) {
|
|
taskVo.setCompletedStatus( TaskConst.task_status.completed );
|
|
this.checkQuestAndFeatStatus( TaskConst.update_type.feat );
|
|
this.notifyUpdateAchievements( false );
|
|
}
|
|
},
|
|
|
|
// @desc:是否需要抛出更新成就的事件,因为提交一个成就可能触发新增成就,所以如果都抛事件的话,会触发多次更新,做延迟抛出更新,避免次更新
|
|
// author:{author}
|
|
// time:2018-05-23 11:56:08
|
|
// --@status:
|
|
// return
|
|
notifyUpdateAchievements: function( status, finish_list ) {
|
|
gcore.GlobalEvent.fire( TaskEvent.UpdateFeatList, finish_list );
|
|
},
|
|
|
|
getAchievements: function() {
|
|
|
|
let achievement_list = [];
|
|
|
|
for( let k in this.achievement_list ) {
|
|
let v = this.achievement_list[ k ];
|
|
if( v.finish != TaskConst.task_status.completed )
|
|
achievement_list.push( v );
|
|
}
|
|
if( Utils.next( achievement_list ) ) {
|
|
achievement_list.sort( Utils.tableLowerSorter( [ "finish_sort", "id" ] ) );
|
|
}
|
|
|
|
return achievement_list
|
|
},
|
|
|
|
} ); |