Merge branch 'bugfix' into release
This commit is contained in:
commit
5d3508aa40
@ -1,9 +1,10 @@
|
||||
import {ApiCall, ApiReturn} from "tsrpc";
|
||||
import {HongDianChange} from "../api_s2c/hongdian/fun";
|
||||
import {taskType} from "../shared/protocols/task/type";
|
||||
import {PublicShared} from "../shared/public/public";
|
||||
import {PeijianFun} from "./peijian";
|
||||
import {manager} from "./taskclass";
|
||||
import { ApiCall, ApiReturn } from "tsrpc";
|
||||
import { HongDianChange } from "../api_s2c/hongdian/fun";
|
||||
import { taskType } from "../shared/protocols/task/type";
|
||||
import { PublicShared } from "../shared/public/public";
|
||||
import { PeijianFun } from "./peijian";
|
||||
import { manager } from "./taskclass";
|
||||
import ApiRecTask from "../api_s2c/event/zhanling/ApiRecTask";
|
||||
|
||||
let taskDict = {};
|
||||
const SHUJUKU = "task";
|
||||
@ -114,7 +115,7 @@ export class TaskFun {
|
||||
let _taskCon = await this.getTaskConByType(_task["type"], _task["taskid"]);
|
||||
if (!_taskCon || Object.keys(_taskCon).length == 0) {
|
||||
// 策划改了任务 找不到 自动删除任务
|
||||
await G.mongodb.collection(SHUJUKU).deleteMany({uid: call.uid, taskid: _task["taskid"]});
|
||||
await G.mongodb.collection(SHUJUKU).deleteMany({ uid: call.uid, taskid: _task["taskid"] });
|
||||
continue
|
||||
}
|
||||
|
||||
@ -142,12 +143,12 @@ export class TaskFun {
|
||||
// 任务值上限检测
|
||||
_resVal = _resVal > _pval ? _pval : _resVal;
|
||||
// 设置任务
|
||||
let _setData = {nval: _resVal};
|
||||
let _where = {taskid: _task["taskid"]};
|
||||
let _setData = { nval: _resVal };
|
||||
let _where = { taskid: _task["taskid"] };
|
||||
await this.setTask(uid, _where, _setData);
|
||||
|
||||
if (_resVal == _pval) {
|
||||
G.server.sendMsgByUid(call.uid, 'msg_s2c/TaskChange', {..._task, nval: _resVal})
|
||||
G.server.sendMsgByUid(call.uid, 'msg_s2c/TaskChange', { ..._task, nval: _resVal })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,7 +188,7 @@ export class TaskFun {
|
||||
// 重置每日任务
|
||||
if (ttype == 1 || ttype == 4) {
|
||||
let _zero = PublicShared.getToDayZeroTime(G.time);
|
||||
let _where = {retime: {$gte: _zero, $lte: _zero + 24 * 60 * 60 - 1}, type: ttype};
|
||||
let _where = { retime: { $gte: _zero, $lte: _zero + 24 * 60 * 60 - 1 }, type: ttype };
|
||||
let _tmp = await this.getUserTaksList(call.uid, _where);
|
||||
if (_tmp.length == 0) await this.resetDailyTask(call, ttype);
|
||||
}
|
||||
@ -197,7 +198,7 @@ export class TaskFun {
|
||||
* 重置每日任务
|
||||
*/
|
||||
static async resetDailyTask(call: ApiCall, type: number = 1) {
|
||||
await this.delTasks(call.uid, {type: type});
|
||||
await this.delTasks(call.uid, { type: type });
|
||||
// 该限制改到红点检测判断,避免此处注释后,红点检测与账号创建初始化任务并发。
|
||||
// if (PublicShared.chkSameDate(call.conn.gud.cTime, G.time)) return;
|
||||
let _taskCons = await this.getTaskConsByType(type);
|
||||
@ -236,7 +237,7 @@ export class TaskFun {
|
||||
static async getFinishByStype(call: ApiCall, stype: number, where: {}) {
|
||||
// 任务刷新
|
||||
await this.refreshTask(call);
|
||||
Object.assign(where, {stype: stype});
|
||||
Object.assign(where, { stype: stype });
|
||||
let _r = await this.getUserTaksList(call.uid, where);
|
||||
return _r;
|
||||
}
|
||||
@ -255,11 +256,33 @@ export class TaskFun {
|
||||
// Object.assign(where, { type: { $in: ttype } })
|
||||
for (let index = 0; index < ttype.length; index++) {
|
||||
const _type = ttype[index];
|
||||
Object.assign(_w, {type: _type, ...where});
|
||||
Object.assign(_w, { type: _type, ...where });
|
||||
if (_finishType.indexOf(_type) != -1) {
|
||||
delete _w["finish"];
|
||||
}
|
||||
let _tmp = await this.getUserTaksList(call.uid, _w);
|
||||
// 没有未完成任务
|
||||
// 检测是否有新加任务
|
||||
if (_tmp.length == 0) {
|
||||
let rectask = (await G.mongodb.collection('task').find(
|
||||
{ uid: call.uid, type: _type }, { projection: { taskid: 1, _id: 0 } }
|
||||
).toArray()).map(e => e.taskid);
|
||||
|
||||
for (let taskid of rectask) {
|
||||
let conf = G.gc.task[_type][taskid];
|
||||
// 配置不存在
|
||||
// 没有后续任务
|
||||
// 后续任务已完成
|
||||
if (!conf || !conf.followtask || rectask.includes(conf.followtask)) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 生成后续任务
|
||||
await this.setTaskInfo(call, conf.followtask, { type: _type });
|
||||
break;
|
||||
}
|
||||
_tmp = await this.getUserTaksList(call.uid, _w);
|
||||
}
|
||||
_r[_type] = _tmp;
|
||||
}
|
||||
return _r;
|
||||
@ -313,7 +336,7 @@ export class TaskFun {
|
||||
* @param call
|
||||
*/
|
||||
static async updateMainTask(call: ApiCall) {
|
||||
let data = await G.mongodb.collection(SHUJUKU).findOne({uid: call.uid, type: 2, finish: 0});
|
||||
let data = await G.mongodb.collection(SHUJUKU).findOne({ uid: call.uid, type: 2, finish: 0 });
|
||||
|
||||
let _ftaskCon = await TaskFun.getTaskConByType(2, data.taskid);
|
||||
// @ts-ignore
|
||||
@ -324,14 +347,14 @@ export class TaskFun {
|
||||
type: 2,
|
||||
finish: 0,
|
||||
taskid: data.taskid
|
||||
}, {$set: {...newTask, nval: data.nval || newTask.nval, retime: data.retime,}}, {upsert: true})
|
||||
}, { $set: { ...newTask, nval: data.nval || newTask.nval, retime: data.retime, } }, { upsert: true })
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成所有任务
|
||||
*/
|
||||
static async generateAllTask(call: ApiCall) {
|
||||
let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid});
|
||||
let _r = await G.mongodb.collection(SHUJUKU).count({ uid: call.uid });
|
||||
if (_r > 0) return;
|
||||
let _taskInfo = [];
|
||||
let _con = G.gc.task;
|
||||
@ -352,7 +375,7 @@ export class TaskFun {
|
||||
/**生成指定类型任务-初始化 */
|
||||
static async reInitTask(call: ApiCall, type: string) {
|
||||
// 查询类型任务是否存在
|
||||
let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid, type: ~~type});
|
||||
let _r = await G.mongodb.collection(SHUJUKU).count({ uid: call.uid, type: ~~type });
|
||||
let _taskInfo = [];
|
||||
if (_r == 0) {
|
||||
let _con = G.gc.task;
|
||||
@ -374,7 +397,7 @@ export class TaskFun {
|
||||
*/
|
||||
static async getUserTaksList(uid: string, where: {}) {
|
||||
// type : 1 主线 2 成就 3 每日
|
||||
Object.assign(where, {uid: uid});
|
||||
Object.assign(where, { uid: uid });
|
||||
let _taskInfo = await G.mongodb.collection(SHUJUKU).find(where).toArray();
|
||||
_taskInfo.forEach(e => {
|
||||
if (e._id) delete e._id;
|
||||
@ -386,7 +409,7 @@ export class TaskFun {
|
||||
* 删除相关任务
|
||||
*/
|
||||
static async delTasks(uid: string, where: { type: number; }) {
|
||||
Object.assign(where, {uid: uid});
|
||||
Object.assign(where, { uid: uid });
|
||||
await G.mongodb.collection(SHUJUKU).deleteMany(where);
|
||||
}
|
||||
|
||||
@ -420,8 +443,8 @@ export class TaskFun {
|
||||
if (Object.keys(setData).length == 0) {
|
||||
return;
|
||||
}
|
||||
Object.assign(where, {uid});
|
||||
setData = {$set: setData};
|
||||
Object.assign(where, { uid });
|
||||
setData = { $set: setData };
|
||||
await G.mongodb.collection(SHUJUKU).updateOne(where, setData);
|
||||
}
|
||||
|
||||
@ -445,7 +468,7 @@ export class TaskFun {
|
||||
if ((element == "1" || element == "3") && call.conn.gud.lv < 7) continue;
|
||||
let _values: number[] = _ttype[element];
|
||||
let _where: {} = {
|
||||
uid: call.uid, type: {$in: _values}, finish: 0, '$expr': {
|
||||
uid: call.uid, type: { $in: _values }, finish: 0, '$expr': {
|
||||
$lte: ["$pval", "$nval"]
|
||||
}
|
||||
};
|
||||
@ -537,7 +560,7 @@ export class TaskAllEmitFun {
|
||||
uid: node.call.conn.uid,
|
||||
type: 'usertasklog'
|
||||
},
|
||||
{$set: {maxherolv: _val}});
|
||||
{ $set: { maxherolv: _val } });
|
||||
}
|
||||
// 干部等级达到 n 级
|
||||
G.emit("Class_task_106", 'Class_task_106', node.call, _val, 0);
|
||||
@ -583,7 +606,7 @@ export class TaskAllEmitFun {
|
||||
uid: node.call.conn.uid,
|
||||
type: 'usertasklog'
|
||||
},
|
||||
{$set: {maxequiplv: _val}});
|
||||
{ $set: { maxequiplv: _val } });
|
||||
}
|
||||
G.emit("Class_task_112", 'Class_task_112', node.call, _val, 0);
|
||||
// 有 n 件强化 配置 等级装备 后面复写正确值
|
||||
@ -607,7 +630,7 @@ export class TaskAllEmitFun {
|
||||
uid: node.call.conn.uid,
|
||||
type: 'usertasklog'
|
||||
},
|
||||
{$set: {maxequiplv: _val}});
|
||||
{ $set: { maxequiplv: _val } });
|
||||
}
|
||||
// 有 n 件强化 配置 等级装备 后面复写正确值
|
||||
G.emit("Class_task_113", 'Class_task_113', node.call, 0, 0);
|
||||
@ -625,7 +648,7 @@ export class TaskAllEmitFun {
|
||||
uid: node.call.conn.uid,
|
||||
type: 'usertasklog'
|
||||
},
|
||||
{$inc: G.mongodb.createTreeObj({key: `herocolor.${_color}`, val: 1})});
|
||||
{ $inc: G.mongodb.createTreeObj({ key: `herocolor.${_color}`, val: 1 }) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -651,7 +674,7 @@ export class TaskAllEmitFun {
|
||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||
uid: node.call.uid,
|
||||
type: 'usertasklog'
|
||||
}, {$set: {equipcolor: usertasklog.equipcolor}})
|
||||
}, { $set: { equipcolor: usertasklog.equipcolor } })
|
||||
}
|
||||
// if (node.call.service.name == 'chongzhi/Open' && node.return.isSucc) {
|
||||
// // 累计充值 n 钻石 数量后面复写
|
||||
@ -693,7 +716,7 @@ export class TaskAllEmitFun {
|
||||
uid: node.call.conn.uid,
|
||||
type: 'usertasklog'
|
||||
},
|
||||
{$set: {friendAsk: _val}});
|
||||
{ $set: { friendAsk: _val } });
|
||||
G.emit("Class_task_144", 'Class_task_144', node.call, 1, 0);
|
||||
}
|
||||
if (node.call.service.name == 'tanxian/FastGuaJi' && node.return.isSucc) {
|
||||
@ -852,7 +875,7 @@ export class TaskAllEmitFun {
|
||||
uid: node.call.conn.uid,
|
||||
type: 'usertasklog'
|
||||
});
|
||||
let _setData = {$set: {}}; // 更新配件记录
|
||||
let _setData = { $set: {} }; // 更新配件记录
|
||||
|
||||
let peijianCon = G.gc.peijian;
|
||||
let _lv = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user