95 lines
3.0 KiB
JavaScript
95 lines
3.0 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '56374yq0MVOq5n5TehZh9Lc', 'task_vo');
|
|
// Scripts/mod/task/task_vo.js
|
|
|
|
"use strict";
|
|
|
|
/*-----------------------------------------------------+
|
|
* 任务的真实数据
|
|
* @author zys
|
|
+-----------------------------------------------------*/
|
|
var TaskConst = require("task_const");
|
|
var TaskEvent = require("task_event");
|
|
var TaskController = require("task_controller");
|
|
|
|
// 任务状态
|
|
var TST = TaskConst.task_status;
|
|
var TaskVo = cc.Class({
|
|
"extends": gcore.BaseEvent,
|
|
ctor: function ctor() {
|
|
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 _delete() {},
|
|
//根据任务完成状态获取任务的描述
|
|
getTaskContent: function getTaskContent() {
|
|
return this.config.desc;
|
|
// return splitDataStr(this.config.desc);
|
|
},
|
|
|
|
//获取任务的名
|
|
getTaskName: function getTaskName() {
|
|
if (this.config) return this.config.name || "";else return "";
|
|
},
|
|
//设置这个任务是否处于完成提交状态
|
|
setCompletedStatus: function setCompletedStatus(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 updateData(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 dispatchUpdate() {
|
|
this.fire(TaskEvent.UpdateSingleQuest, this.id);
|
|
},
|
|
setFinishSort: function setFinishSort() {
|
|
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;
|
|
|
|
cc._RF.pop(); |