Merge branch 'feature/huangqijiuguan' into release

# Conflicts:
#	src/public/task.ts
This commit is contained in:
xichaoyin 2024-01-12 02:07:10 +08:00
commit de40641464
4 changed files with 58 additions and 54 deletions

View File

@ -32,6 +32,7 @@ export default async function (call: ApiCall<ReqDuiHuan, ResDuiHuan>) {
// 检查消耗
await PlayerFun.checkNeedIsMeet(call, need);
await PlayerFun.cutNeed(call, need);
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 记录兑换次数

View File

@ -1,6 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqGiftRec, ResGiftRec } from "../../../shared/protocols/event/huangqijiuguan/PtlGiftRec";
import HQJGFun from "./fun";
import { PlayerFun } from "../../../public/player";
export default async function (call: ApiCall<ReqGiftRec, ResGiftRec>) {
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++;
await HQJGFun.setMyData(call.uid, call.req.hdid, { giftbuy: mydata.giftbuy });
await PlayerFun.sendPrize(call, prize);
call.succ({ data: mydata, prize: prize })
G.server.sendMsgByUid(call.uid, "msg_s2c/HongDianChange", ["huodonghd"])
}

View File

@ -5,7 +5,7 @@ import { PublicShared } from "../../../shared/public/public"
import { EmailFun } from "../../../public/email"
import { playerInfo } from "../../../shared/protocols/user/PtlLogin"
import { PlayerFun } from "../../../public/player"
import { Player } from "../../../shared/fightControl/Player"
import { TaskFun } from "../../../public/task"
// hddata.data
export interface Data {
@ -372,15 +372,15 @@ export default class HQJGFun {
let mydata = await this.getMydata(call, hd.hdid);
if (!mydata.task.val[`day${today}`]) {
mydata.task.val[`day${today}`] = {}
}
let isset = 0;
let setData = {
$inc: {},
$set: {}
};
if (!mydata.task.val[`day${today}`]) {
isset = 1;
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)) {
let taskCon = tasks[taskid];
@ -393,18 +393,20 @@ export default class HQJGFun {
val = await alchangeVal(call, taskCon, val, arg)
isset = 1
if (isinc == 1) { // 累加
mydata.task.val[`day${today}`][taskid] = (mydata.task.val[`day${today}`][taskid] || 0) + val
setData["$inc"][`task.val.day${today}.${taskid}`] = val
if (isinc != 1) { // 累加
mydata.task.val[`day${today}`][taskid] = val;
} else {
mydata.task.val[`day${today}`][taskid] = val
setData["$set"][`task.val.day${today}.${taskid}`] = val
mydata.task.val[`day${today}`][taskid] = (mydata.task.val[`day${today}`][taskid] || 0) + val;
}
}
// 设置任务
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) {
G.server.sendMsgByUid(call.uid, "msg_s2c/HongDianChange", ["huodonghd"])

View File

@ -115,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
}
@ -143,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})
}
}
}
@ -188,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);
}
@ -198,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);
@ -237,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;
}
@ -256,7 +256,7 @@ 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"];
}
@ -336,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
@ -347,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;
@ -375,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;
@ -397,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;
@ -409,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);
}
@ -443,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);
}
@ -468,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"]
}
};
@ -603,10 +603,10 @@ export class TaskAllEmitFun {
});
if (_val > (usertasklog?.maxequiplv | 0)) {
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { maxequiplv: _val } });
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$set: {maxequiplv: _val}});
}
G.emit("Class_task_112", 'Class_task_112', node.call, _val, 0);
// 有 n 件强化 配置 等级装备 后面复写正确值
@ -627,10 +627,10 @@ export class TaskAllEmitFun {
});
if (_val > (usertasklog?.maxequiplv | 0)) {
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { maxequiplv: _val } });
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$set: {maxequiplv: _val}});
}
// 有 n 件强化 配置 等级装备 后面复写正确值
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;
G.emit("Class_task_114", 'Class_task_114', node.call, 1, _color);
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $inc: G.mongodb.createTreeObj({ key: `herocolor.${_color}`, val: 1 }) });
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$inc: G.mongodb.createTreeObj({key: `herocolor.${_color}`, val: 1})});
}
}
}
@ -674,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 钻石 数量后面复写
@ -713,10 +713,10 @@ export class TaskAllEmitFun {
}
_val = _val + usertasklog.friendAsk + usertasklog.sendGift
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { friendAsk: _val } });
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$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) {
@ -875,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;
@ -904,9 +904,9 @@ export class TaskAllEmitFun {
// 配件升级到 xx 级
if (_setData["$set"]["maxpeijianlv"]) G.emit("Class_task_139", 'Class_task_139', node.call, _lv, 0);
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
uid: node.call.conn.uid,
type: 'usertasklog'
},
_setData);
}
}