Merge branch 'feature/huangqijiuguan' into release
# Conflicts: # src/public/task.ts
This commit is contained in:
commit
de40641464
@ -32,6 +32,7 @@ export default async function (call: ApiCall<ReqDuiHuan, ResDuiHuan>) {
|
|||||||
|
|
||||||
// 检查消耗
|
// 检查消耗
|
||||||
await PlayerFun.checkNeedIsMeet(call, need);
|
await PlayerFun.checkNeedIsMeet(call, need);
|
||||||
|
await PlayerFun.cutNeed(call, need);
|
||||||
// 发送奖励
|
// 发送奖励
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
// 记录兑换次数
|
// 记录兑换次数
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import { ReqGiftRec, ResGiftRec } from "../../../shared/protocols/event/huangqijiuguan/PtlGiftRec";
|
import { ReqGiftRec, ResGiftRec } from "../../../shared/protocols/event/huangqijiuguan/PtlGiftRec";
|
||||||
import HQJGFun from "./fun";
|
import HQJGFun from "./fun";
|
||||||
|
import { PlayerFun } from "../../../public/player";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGiftRec, ResGiftRec>) {
|
export default async function (call: ApiCall<ReqGiftRec, ResGiftRec>) {
|
||||||
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
|
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
|
||||||
@ -38,7 +39,7 @@ export default async function (call: ApiCall<ReqGiftRec, ResGiftRec>) {
|
|||||||
mydata.giftbuy[call.req.giftid].num++;
|
mydata.giftbuy[call.req.giftid].num++;
|
||||||
await HQJGFun.setMyData(call.uid, call.req.hdid, { giftbuy: mydata.giftbuy });
|
await HQJGFun.setMyData(call.uid, call.req.hdid, { giftbuy: mydata.giftbuy });
|
||||||
|
|
||||||
|
await PlayerFun.sendPrize(call, prize);
|
||||||
call.succ({ data: mydata, prize: prize })
|
call.succ({ data: mydata, prize: prize })
|
||||||
|
|
||||||
G.server.sendMsgByUid(call.uid, "msg_s2c/HongDianChange", ["huodonghd"])
|
G.server.sendMsgByUid(call.uid, "msg_s2c/HongDianChange", ["huodonghd"])
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { PublicShared } from "../../../shared/public/public"
|
|||||||
import { EmailFun } from "../../../public/email"
|
import { EmailFun } from "../../../public/email"
|
||||||
import { playerInfo } from "../../../shared/protocols/user/PtlLogin"
|
import { playerInfo } from "../../../shared/protocols/user/PtlLogin"
|
||||||
import { PlayerFun } from "../../../public/player"
|
import { PlayerFun } from "../../../public/player"
|
||||||
import { Player } from "../../../shared/fightControl/Player"
|
import { TaskFun } from "../../../public/task"
|
||||||
|
|
||||||
// hddata.data
|
// hddata.data
|
||||||
export interface Data {
|
export interface Data {
|
||||||
@ -372,15 +372,15 @@ export default class HQJGFun {
|
|||||||
|
|
||||||
let mydata = await this.getMydata(call, hd.hdid);
|
let mydata = await this.getMydata(call, hd.hdid);
|
||||||
|
|
||||||
if (!mydata.task.val[`day${today}`]) {
|
|
||||||
mydata.task.val[`day${today}`] = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let isset = 0;
|
let isset = 0;
|
||||||
let setData = {
|
if (!mydata.task.val[`day${today}`]) {
|
||||||
$inc: {},
|
isset = 1;
|
||||||
$set: {}
|
mydata.task.val[`day${today}`] = {}
|
||||||
};
|
for (let taskid in tasks) {
|
||||||
|
let taskcon = tasks[taskid];
|
||||||
|
mydata.task.val[`day${today}`][taskid] = await TaskFun.getTaskNval(call, taskcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (let taskid of Object.keys(tasks)) {
|
for (let taskid of Object.keys(tasks)) {
|
||||||
let taskCon = tasks[taskid];
|
let taskCon = tasks[taskid];
|
||||||
@ -393,18 +393,20 @@ export default class HQJGFun {
|
|||||||
val = await alchangeVal(call, taskCon, val, arg)
|
val = await alchangeVal(call, taskCon, val, arg)
|
||||||
|
|
||||||
isset = 1
|
isset = 1
|
||||||
if (isinc == 1) { // 累加
|
if (isinc != 1) { // 累加
|
||||||
mydata.task.val[`day${today}`][taskid] = (mydata.task.val[`day${today}`][taskid] || 0) + val
|
mydata.task.val[`day${today}`][taskid] = val;
|
||||||
setData["$inc"][`task.val.day${today}.${taskid}`] = val
|
|
||||||
} else {
|
} else {
|
||||||
mydata.task.val[`day${today}`][taskid] = val
|
mydata.task.val[`day${today}`][taskid] = (mydata.task.val[`day${today}`][taskid] || 0) + val;
|
||||||
setData["$set"][`task.val.day${today}.${taskid}`] = val
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置任务
|
// 设置任务
|
||||||
if (isset == 1) {
|
if (isset == 1) {
|
||||||
await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, setData)
|
await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, {
|
||||||
|
$set: {
|
||||||
|
[`task.val.day${today}`]: mydata.task.val[`day${today}`]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if ((await this.getHongDian(call, hd, mydata)).show) {
|
if ((await this.getHongDian(call, hd, mydata)).show) {
|
||||||
G.server.sendMsgByUid(call.uid, "msg_s2c/HongDianChange", ["huodonghd"])
|
G.server.sendMsgByUid(call.uid, "msg_s2c/HongDianChange", ["huodonghd"])
|
||||||
|
@ -115,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,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})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,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);
|
||||||
}
|
}
|
||||||
@ -198,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);
|
||||||
@ -237,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;
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ 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"];
|
||||||
}
|
}
|
||||||
@ -336,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
|
||||||
@ -347,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;
|
||||||
@ -375,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;
|
||||||
@ -397,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;
|
||||||
@ -409,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,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"]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -603,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 件强化 配置 等级装备 后面复写正确值
|
||||||
@ -627,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);
|
||||||
@ -645,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})});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,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 钻石 数量后面复写
|
||||||
@ -713,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) {
|
||||||
@ -875,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;
|
||||||
@ -904,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