Files
2026-05-23 22:10:14 +08:00

104 lines
3.2 KiB
JavaScript

/*-----------------------------------------------------+
* 任务的真实数据
* @author zys
+-----------------------------------------------------*/
var TaskConst = require( "task_const" );
var TaskEvent = require( "task_event" );
const TaskController = require( "task_controller" );
// 任务状态
const TST = TaskConst.task_status;
var TaskVo = cc.Class( {
extends: gcore.BaseEvent,
ctor: function() {
this.id = arguments[ 0 ];
this.type = arguments[ 1 ] || TaskConst.type.quest;
if( this.type == TaskConst.type.quest ) {
this.config = gdata( "quest_data", "data_get", [ this.id ] );
} else if( this.type == TaskConst.type.feat ) {
this.config = gdata( "feat_data", "data_get", [ this.id ] );
} else if( this.type == TaskConst.type.exp ) {
this.config = gdata( "room_feat_data", "data_exp_info", [ this.id ] );
}
this.finish = TaskConst.task_status.un_finish;
this.finish_sort = 0;
},
_delete: function() {
},
//根据任务完成状态获取任务的描述
getTaskContent: function() {
return this.config.desc;
// return splitDataStr(this.config.desc);
},
//获取任务的名
getTaskName: function() {
if( this.config )
return this.config.name || ""
else
return ""
},
//设置这个任务是否处于完成提交状态
setCompletedStatus: function( status ) {
this.finish = status;
// let tasks = TaskController.getInstance().getModel().getTaskList();
// let count = 0;
// tasks.forEach( _task =>{
// if( _task.finish == 1 ){
// count++;
// }
// } )
// nx.mTip.openTip( "daily.tip", count > 0 );
this.setFinishSort();
this.dispatchUpdate();
},
//更新任务数据
updateData: function( data ) {
this.finish = data.finish;
this.task_type = data.type ? data.type : 0;
// let count = 0;
// if( this.finish == TST.finish && data.type == TaskConst.task_type.daily ){
// count ++;
// }
// if( ( this.finish == TST.completed && data.type == TaskConst.task_type.daily ) || ( this.finish == TST.completed && data.type == TaskConst.type.quest ) ){
// // nx.mTip.openTip( "daily.tip", false );
// }
// console.log( "當前的所有日常任務" + JSON.stringify( tasks ) );
// nx.mTip.openTip( "daily.tip", true );
this.progress = data.progress;
this.setFinishSort();
this.dispatchUpdate();
},
dispatchUpdate: function() {
this.fire( TaskEvent.UpdateSingleQuest, this.id );
},
setFinishSort: function() {
if( this.finish == TaskConst.task_status.un_finish ) {
this.finish_sort = 1;
} else if( this.finish == TaskConst.task_status.finish ) {
this.finish_sort = 0;
} else if( this.finish == TaskConst.task_status.completed ) {
this.finish_sort = 2;
} else {
this.finish_sort = 3;
}
}
} );
module.exports = TaskVo;