Merge branch 'bugfix' into release
This commit is contained in:
commit
5d3508aa40
@ -1,9 +1,10 @@
|
|||||||
import {ApiCall, ApiReturn} from "tsrpc";
|
import { ApiCall, ApiReturn } from "tsrpc";
|
||||||
import {HongDianChange} from "../api_s2c/hongdian/fun";
|
import { HongDianChange } from "../api_s2c/hongdian/fun";
|
||||||
import {taskType} from "../shared/protocols/task/type";
|
import { taskType } from "../shared/protocols/task/type";
|
||||||
import {PublicShared} from "../shared/public/public";
|
import { PublicShared } from "../shared/public/public";
|
||||||
import {PeijianFun} from "./peijian";
|
import { PeijianFun } from "./peijian";
|
||||||
import {manager} from "./taskclass";
|
import { manager } from "./taskclass";
|
||||||
|
import ApiRecTask from "../api_s2c/event/zhanling/ApiRecTask";
|
||||||
|
|
||||||
let taskDict = {};
|
let taskDict = {};
|
||||||
const SHUJUKU = "task";
|
const SHUJUKU = "task";
|
||||||
@ -114,7 +115,7 @@ export class TaskFun {
|
|||||||
let _taskCon = await this.getTaskConByType(_task["type"], _task["taskid"]);
|
let _taskCon = await this.getTaskConByType(_task["type"], _task["taskid"]);
|
||||||
if (!_taskCon || Object.keys(_taskCon).length == 0) {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,12 +143,12 @@ export class TaskFun {
|
|||||||
// 任务值上限检测
|
// 任务值上限检测
|
||||||
_resVal = _resVal > _pval ? _pval : _resVal;
|
_resVal = _resVal > _pval ? _pval : _resVal;
|
||||||
// 设置任务
|
// 设置任务
|
||||||
let _setData = {nval: _resVal};
|
let _setData = { nval: _resVal };
|
||||||
let _where = {taskid: _task["taskid"]};
|
let _where = { taskid: _task["taskid"] };
|
||||||
await this.setTask(uid, _where, _setData);
|
await this.setTask(uid, _where, _setData);
|
||||||
|
|
||||||
if (_resVal == _pval) {
|
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) {
|
if (ttype == 1 || ttype == 4) {
|
||||||
let _zero = PublicShared.getToDayZeroTime(G.time);
|
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);
|
let _tmp = await this.getUserTaksList(call.uid, _where);
|
||||||
if (_tmp.length == 0) await this.resetDailyTask(call, ttype);
|
if (_tmp.length == 0) await this.resetDailyTask(call, ttype);
|
||||||
}
|
}
|
||||||
@ -197,7 +198,7 @@ export class TaskFun {
|
|||||||
* 重置每日任务
|
* 重置每日任务
|
||||||
*/
|
*/
|
||||||
static async resetDailyTask(call: ApiCall, type: number = 1) {
|
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;
|
// if (PublicShared.chkSameDate(call.conn.gud.cTime, G.time)) return;
|
||||||
let _taskCons = await this.getTaskConsByType(type);
|
let _taskCons = await this.getTaskConsByType(type);
|
||||||
@ -236,7 +237,7 @@ export class TaskFun {
|
|||||||
static async getFinishByStype(call: ApiCall, stype: number, where: {}) {
|
static async getFinishByStype(call: ApiCall, stype: number, where: {}) {
|
||||||
// 任务刷新
|
// 任务刷新
|
||||||
await this.refreshTask(call);
|
await this.refreshTask(call);
|
||||||
Object.assign(where, {stype: stype});
|
Object.assign(where, { stype: stype });
|
||||||
let _r = await this.getUserTaksList(call.uid, where);
|
let _r = await this.getUserTaksList(call.uid, where);
|
||||||
return _r;
|
return _r;
|
||||||
}
|
}
|
||||||
@ -255,11 +256,33 @@ export class TaskFun {
|
|||||||
// Object.assign(where, { type: { $in: ttype } })
|
// Object.assign(where, { type: { $in: ttype } })
|
||||||
for (let index = 0; index < ttype.length; index++) {
|
for (let index = 0; index < ttype.length; index++) {
|
||||||
const _type = ttype[index];
|
const _type = ttype[index];
|
||||||
Object.assign(_w, {type: _type, ...where});
|
Object.assign(_w, { type: _type, ...where });
|
||||||
if (_finishType.indexOf(_type) != -1) {
|
if (_finishType.indexOf(_type) != -1) {
|
||||||
delete _w["finish"];
|
delete _w["finish"];
|
||||||
}
|
}
|
||||||
let _tmp = await this.getUserTaksList(call.uid, _w);
|
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;
|
_r[_type] = _tmp;
|
||||||
}
|
}
|
||||||
return _r;
|
return _r;
|
||||||
@ -313,7 +336,7 @@ export class TaskFun {
|
|||||||
* @param call
|
* @param call
|
||||||
*/
|
*/
|
||||||
static async updateMainTask(call: ApiCall) {
|
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);
|
let _ftaskCon = await TaskFun.getTaskConByType(2, data.taskid);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -324,14 +347,14 @@ export class TaskFun {
|
|||||||
type: 2,
|
type: 2,
|
||||||
finish: 0,
|
finish: 0,
|
||||||
taskid: data.taskid
|
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) {
|
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;
|
if (_r > 0) return;
|
||||||
let _taskInfo = [];
|
let _taskInfo = [];
|
||||||
let _con = G.gc.task;
|
let _con = G.gc.task;
|
||||||
@ -352,7 +375,7 @@ export class TaskFun {
|
|||||||
/**生成指定类型任务-初始化 */
|
/**生成指定类型任务-初始化 */
|
||||||
static async reInitTask(call: ApiCall, type: string) {
|
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 = [];
|
let _taskInfo = [];
|
||||||
if (_r == 0) {
|
if (_r == 0) {
|
||||||
let _con = G.gc.task;
|
let _con = G.gc.task;
|
||||||
@ -374,7 +397,7 @@ export class TaskFun {
|
|||||||
*/
|
*/
|
||||||
static async getUserTaksList(uid: string, where: {}) {
|
static async getUserTaksList(uid: string, where: {}) {
|
||||||
// type : 1 主线 2 成就 3 每日
|
// type : 1 主线 2 成就 3 每日
|
||||||
Object.assign(where, {uid: uid});
|
Object.assign(where, { uid: uid });
|
||||||
let _taskInfo = await G.mongodb.collection(SHUJUKU).find(where).toArray();
|
let _taskInfo = await G.mongodb.collection(SHUJUKU).find(where).toArray();
|
||||||
_taskInfo.forEach(e => {
|
_taskInfo.forEach(e => {
|
||||||
if (e._id) delete e._id;
|
if (e._id) delete e._id;
|
||||||
@ -386,7 +409,7 @@ export class TaskFun {
|
|||||||
* 删除相关任务
|
* 删除相关任务
|
||||||
*/
|
*/
|
||||||
static async delTasks(uid: string, where: { type: number; }) {
|
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);
|
await G.mongodb.collection(SHUJUKU).deleteMany(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,8 +443,8 @@ export class TaskFun {
|
|||||||
if (Object.keys(setData).length == 0) {
|
if (Object.keys(setData).length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Object.assign(where, {uid});
|
Object.assign(where, { uid });
|
||||||
setData = {$set: setData};
|
setData = { $set: setData };
|
||||||
await G.mongodb.collection(SHUJUKU).updateOne(where, 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;
|
if ((element == "1" || element == "3") && call.conn.gud.lv < 7) continue;
|
||||||
let _values: number[] = _ttype[element];
|
let _values: number[] = _ttype[element];
|
||||||
let _where: {} = {
|
let _where: {} = {
|
||||||
uid: call.uid, type: {$in: _values}, finish: 0, '$expr': {
|
uid: call.uid, type: { $in: _values }, finish: 0, '$expr': {
|
||||||
$lte: ["$pval", "$nval"]
|
$lte: ["$pval", "$nval"]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -534,10 +557,10 @@ export class TaskAllEmitFun {
|
|||||||
});
|
});
|
||||||
if (_val > (usertasklog?.maxherolv | 0)) {
|
if (_val > (usertasklog?.maxherolv | 0)) {
|
||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
},
|
},
|
||||||
{$set: {maxherolv: _val}});
|
{ $set: { maxherolv: _val } });
|
||||||
}
|
}
|
||||||
// 干部等级达到 n 级
|
// 干部等级达到 n 级
|
||||||
G.emit("Class_task_106", 'Class_task_106', node.call, _val, 0);
|
G.emit("Class_task_106", 'Class_task_106', node.call, _val, 0);
|
||||||
@ -580,10 +603,10 @@ export class TaskAllEmitFun {
|
|||||||
});
|
});
|
||||||
if (_val > (usertasklog?.maxequiplv | 0)) {
|
if (_val > (usertasklog?.maxequiplv | 0)) {
|
||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
},
|
},
|
||||||
{$set: {maxequiplv: _val}});
|
{ $set: { maxequiplv: _val } });
|
||||||
}
|
}
|
||||||
G.emit("Class_task_112", 'Class_task_112', node.call, _val, 0);
|
G.emit("Class_task_112", 'Class_task_112', node.call, _val, 0);
|
||||||
// 有 n 件强化 配置 等级装备 后面复写正确值
|
// 有 n 件强化 配置 等级装备 后面复写正确值
|
||||||
@ -604,10 +627,10 @@ export class TaskAllEmitFun {
|
|||||||
});
|
});
|
||||||
if (_val > (usertasklog?.maxequiplv | 0)) {
|
if (_val > (usertasklog?.maxequiplv | 0)) {
|
||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
},
|
},
|
||||||
{$set: {maxequiplv: _val}});
|
{ $set: { maxequiplv: _val } });
|
||||||
}
|
}
|
||||||
// 有 n 件强化 配置 等级装备 后面复写正确值
|
// 有 n 件强化 配置 等级装备 后面复写正确值
|
||||||
G.emit("Class_task_113", 'Class_task_113', node.call, 0, 0);
|
G.emit("Class_task_113", 'Class_task_113', node.call, 0, 0);
|
||||||
@ -622,10 +645,10 @@ export class TaskAllEmitFun {
|
|||||||
let _color = G.gc.hero[element.heroId].colour;
|
let _color = G.gc.hero[element.heroId].colour;
|
||||||
G.emit("Class_task_114", 'Class_task_114', node.call, 1, _color);
|
G.emit("Class_task_114", 'Class_task_114', node.call, 1, _color);
|
||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
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({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.uid,
|
uid: node.call.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
}, {$set: {equipcolor: usertasklog.equipcolor}})
|
}, { $set: { equipcolor: usertasklog.equipcolor } })
|
||||||
}
|
}
|
||||||
// if (node.call.service.name == 'chongzhi/Open' && node.return.isSucc) {
|
// if (node.call.service.name == 'chongzhi/Open' && node.return.isSucc) {
|
||||||
// // 累计充值 n 钻石 数量后面复写
|
// // 累计充值 n 钻石 数量后面复写
|
||||||
@ -690,10 +713,10 @@ export class TaskAllEmitFun {
|
|||||||
}
|
}
|
||||||
_val = _val + usertasklog.friendAsk + usertasklog.sendGift
|
_val = _val + usertasklog.friendAsk + usertasklog.sendGift
|
||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
},
|
},
|
||||||
{$set: {friendAsk: _val}});
|
{ $set: { friendAsk: _val } });
|
||||||
G.emit("Class_task_144", 'Class_task_144', node.call, 1, 0);
|
G.emit("Class_task_144", 'Class_task_144', node.call, 1, 0);
|
||||||
}
|
}
|
||||||
if (node.call.service.name == 'tanxian/FastGuaJi' && node.return.isSucc) {
|
if (node.call.service.name == 'tanxian/FastGuaJi' && node.return.isSucc) {
|
||||||
@ -852,7 +875,7 @@ export class TaskAllEmitFun {
|
|||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
});
|
});
|
||||||
let _setData = {$set: {}}; // 更新配件记录
|
let _setData = { $set: {} }; // 更新配件记录
|
||||||
|
|
||||||
let peijianCon = G.gc.peijian;
|
let peijianCon = G.gc.peijian;
|
||||||
let _lv = 0;
|
let _lv = 0;
|
||||||
@ -881,9 +904,9 @@ export class TaskAllEmitFun {
|
|||||||
// 配件升级到 xx 级
|
// 配件升级到 xx 级
|
||||||
if (_setData["$set"]["maxpeijianlv"]) G.emit("Class_task_139", 'Class_task_139', node.call, _lv, 0);
|
if (_setData["$set"]["maxpeijianlv"]) G.emit("Class_task_139", 'Class_task_139', node.call, _lv, 0);
|
||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
|
||||||
uid: node.call.conn.uid,
|
uid: node.call.conn.uid,
|
||||||
type: 'usertasklog'
|
type: 'usertasklog'
|
||||||
},
|
},
|
||||||
_setData);
|
_setData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user