From b5a9f6f53076316becaaa5802c74dd69a6bcc6bd Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Thu, 11 Jan 2024 19:14:56 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=AE=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_cross/hbzb/ApiGetUser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api_cross/hbzb/ApiGetUser.ts b/src/api_cross/hbzb/ApiGetUser.ts index 8360c0d..2e4e6ac 100644 --- a/src/api_cross/hbzb/ApiGetUser.ts +++ b/src/api_cross/hbzb/ApiGetUser.ts @@ -17,7 +17,7 @@ export default async function (call: ApiCall) { arr.map(i=>{ res[i.uid] = { data: i.data, - jifen:i.jifen, + jifen:i?.jifen||0, }; }); From 00804b9b49cf62ca857a8f71f5d3b5ce99b5df14 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Thu, 11 Jan 2024 20:23:08 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E7=9F=BF=E6=B4=9E=E7=BB=93=E7=AE=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/kuangdong/ApiYanShi.ts | 2 +- src/public/kuangdong.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api_s2c/kuangdong/ApiYanShi.ts b/src/api_s2c/kuangdong/ApiYanShi.ts index 4ab56b8..62efd2f 100644 --- a/src/api_s2c/kuangdong/ApiYanShi.ts +++ b/src/api_s2c/kuangdong/ApiYanShi.ts @@ -5,7 +5,7 @@ import {ReqYanShi, ResYanShi} from "../../shared/protocols/kuangdong/PtlYanShi"; export default async function (call: ApiCall) { - return call.errorCode(1) + //return call.errorCode(1) let hdid = call.req.hdid let con = await KuangDongfun.getCon(hdid) diff --git a/src/public/kuangdong.ts b/src/public/kuangdong.ts index 942759d..597556e 100644 --- a/src/public/kuangdong.ts +++ b/src/public/kuangdong.ts @@ -179,14 +179,14 @@ export class KuangDongfun { } if (!kdInfo) return [] let _con = await this.getCon(hdid) - let _kcTime = G.time + kdInfo.yanshi - kdInfo.ctime + let _kcTime = G.time - kdInfo.ctime //let _gud = await G.mongodb.collection('user').findOne({uid: kdInfo.uid}) let _gud = await getGud(kdInfo.uid) let gamer_lv = _gud.lv // @ts-ignore let prize: prizeType[] = _con.reward // let prize: prizeType[] = [{ a: 'attr', t: 'rmbmoney', n: 50 }] // todo 待接入配置 - if (_kcTime > 8 * 3600) _kcTime = 8 * 3600 + kdInfo.yanshi // 设置最大时长 + if (_kcTime > 8 * 3600 + kdInfo.yanshi) _kcTime = 8 * 3600 + kdInfo.yanshi // 设置最大时长 prize[0]["n"] = Math.floor(eval(_con.formula) * _kcTime) if (_con.public_map == 1){ From 69945c396471ff2134ebb7435b90b689a9f727db Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Thu, 11 Jan 2024 21:01:00 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E5=9B=9E=E9=80=80=E5=B1=82=E6=95=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/dxlt.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/public/dxlt.ts b/src/public/dxlt.ts index 008e62f..e1d36b0 100644 --- a/src/public/dxlt.ts +++ b/src/public/dxlt.ts @@ -19,7 +19,8 @@ export class DxltFun { } /**回退层数 */ static backLayer(data: ResOpen) { - let num = data.curLayer - G.gc.dxlt_com.dayResetBackLayer; + //let num = data.curLayer - G.gc.dxlt_com.dayResetBackLayer; + let num = (data.curLayer-30) - (data.curLayer-30)%5+1 data.curLayer = num < 1 ? 1 : num; data.over = G.gc.dxlt_layer[data.curLayer].type == 2; } From b23d311dbd2958a9165f838b7a66f99c5f69736a Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Thu, 11 Jan 2024 21:19:48 +0800 Subject: [PATCH 04/10] =?UTF-8?q?slzd=E4=B8=8D=E9=9C=80=E8=A6=81=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/slzd/ApiOpen.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/api_s2c/slzd/ApiOpen.ts b/src/api_s2c/slzd/ApiOpen.ts index 85903be..2ac2ccc 100644 --- a/src/api_s2c/slzd/ApiOpen.ts +++ b/src/api_s2c/slzd/ApiOpen.ts @@ -41,13 +41,16 @@ export default async function (call: ApiCall) { }, { upsert: true } ); - } else if (data.fightNum < G.gc.slzd.maxFightNum && G.time - data.replyCd > G.gc.slzd.replyCd) { - let addNum = Math.floor((G.time - data.replyCd) / G.gc.slzd.replyCd); - let maxAddNum = G.gc.slzd.maxFightNum - data.fightNum; - data.fightNum += addNum > maxAddNum ? maxAddNum : addNum; - data.replyCd = G.time; - G.mongodb.collection('slzdUser').updateOne({ uid: call.uid }, { $set: { 'data.fightNum': data.fightNum, 'data.replyCd': data.replyCd } }); } + + //不需要回复次数 + // else if (data.fightNum < G.gc.slzd.maxFightNum && G.time - data.replyCd > G.gc.slzd.replyCd) { + // let addNum = Math.floor((G.time - data.replyCd) / G.gc.slzd.replyCd); + // let maxAddNum = G.gc.slzd.maxFightNum - data.fightNum; + // data.fightNum += addNum > maxAddNum ? maxAddNum : addNum; + // data.replyCd = G.time; + // G.mongodb.collection('slzdUser').updateOne({ uid: call.uid }, { $set: { 'data.fightNum': data.fightNum, 'data.replyCd': data.replyCd } }); + // } let { refreshTime, ...ops } = data; call.succ({ From 08a9dd335a040e3c4c36ea8da7fae87ffc423241 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Thu, 11 Jan 2024 22:52:24 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=8F=91=E5=A5=96=E5=8F=91=E9=94=99?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler_wzry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/scheduler/scheduler_wzry.ts b/src/public/scheduler/scheduler_wzry.ts index a3f276c..4aca35f 100644 --- a/src/public/scheduler/scheduler_wzry.ts +++ b/src/public/scheduler/scheduler_wzry.ts @@ -299,7 +299,7 @@ export class SchedulerWzryZuanshiSendPrize extends SchedulerWzryAutoBaoMing { await this.record() return } - let _prizeCon = this.typeprzie=='zhuanshi'?G.gc.wangzherongyao.wangzhe.jiangli.zuanshi:G.gc.wangzherongyao.wangzhe.jiangli.wangzhe; + let _prizeCon = this.typeprzie=='zuanshi'?G.gc.wangzherongyao.wangzhe.jiangli.zuanshi:G.gc.wangzherongyao.wangzhe.jiangli.wangzhe; let _u = [] for (let index = 0; index < _user.length; index++) { const element = _user[index]; From 8780716d44fb1b0622378bf6eba16143d2827483 Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Fri, 12 Jan 2024 15:44:56 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fix_patch/patch_20240111.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/fix_patch/patch_20240111.ts b/src/fix_patch/patch_20240111.ts index ea06ce0..159aadd 100644 --- a/src/fix_patch/patch_20240111.ts +++ b/src/fix_patch/patch_20240111.ts @@ -1,23 +1,24 @@ -import { ReqEmail } from "../monopoly/protocols/PtlEmail"; -import { patchInit } from "../patch"; -import { MsgEmail } from "../shared/protocols/msg_s2c/MsgEmail"; -import { PublicShared } from "../shared/public/public"; +import {ReqEmail} from "../monopoly/protocols/PtlEmail"; +import {patchInit} from "../patch"; +import {MsgEmail} from "../shared/protocols/msg_s2c/MsgEmail"; +import {PublicShared} from "../shared/public/public"; class Path { - async fun1(a: any) { let taskType = 2; - // let users = await G.mongodb.collection('user').find({}).toArray(); - let users = await G.mongodb.collection('user').find({ loginTime: { $gte: 1704643200 } }).toArray(); + let users = await G.mongodb.collection('user').find({}, { + projection: {uid: 1} + }).toArray(); + // let users = await G.mongodb.collection('user').find({ loginTime: { $gte: 1704643200 } }).toArray(); for (let i = 0; i < users.length; i++) { let user = users[i]; console.log(`处理玩家${user.uid}数据`); let task = Object.assign({}, ...(await G.mongodb.collection('task').find({ uid: user.uid, type: taskType - }, { projection: { taskid: 1, finish: 1 } }).toArray()).map(i => { - return { [i.taskid]: i.finish } + }, {projection: {taskid: 1, finish: 1}}).toArray()).map(i => { + return {[i.taskid]: i.finish} })) let deltask = []; @@ -34,7 +35,7 @@ class Path { if (deltask.length > 0) { await G.mongodb.collection("task").deleteMany( - { uid: user.uid, taskid: { $in: deltask } } + {uid: user.uid, taskid: {$in: deltask}} ) console.log(`删除玩家${user.uid}任务:${deltask}`) } @@ -56,4 +57,5 @@ async function main() { process.exit(); }, 3000); } + main(); From af03f2f6c530f9c705affcaa6aefda2b38d59120 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Fri, 12 Jan 2024 16:08:30 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=A4=96=E7=BD=91insertMany=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/pay.ts | 3 ++- src/public/xstask.ts | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/public/pay.ts b/src/public/pay.ts index 6052922..7fe7252 100644 --- a/src/public/pay.ts +++ b/src/public/pay.ts @@ -66,7 +66,8 @@ export class PayFun { ); }) - G.mongodb.collection('payLogNew').insertMany(args.map(i => ({key: i.payId, uid: uid, values: i.val}))); + let colls = args.map(i => ({key: i.payId, uid: uid, values: i.val})) + if(colls.length>0)G.mongodb.collection('payLogNew').insertMany(colls); G.server.sendMsgByUid(uid, 'msg_s2c/PayChange', Object.fromEntries(args.map(a => [a.payId, a.val]))); } diff --git a/src/public/xstask.ts b/src/public/xstask.ts index cfdce3d..2b0de09 100644 --- a/src/public/xstask.ts +++ b/src/public/xstask.ts @@ -78,16 +78,17 @@ export class XstaskFun { uid: uid, }; }); - let result = await G.mongodb.collection('xstask').insertMany(taskList); - this.uidTask[uid] = this.uidTask[uid] || []; - taskList.forEach((task, index) => { - this.uidTask[uid].push(G.mongodb.conversionIdObj({ - _id: result.insertedIds[index], - ...task - })); - }); + if(taskList.length > 0){ + let result = await G.mongodb.collection('xstask').insertMany(taskList); + taskList.forEach((task, index) => { + this.uidTask[uid].push(G.mongodb.conversionIdObj({ + _id: result.insertedIds[index], + ...task + })); + }); + } return this.uidTask[uid]; } From a46b8f671c831280db7e952944ec6966b36bd591 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Fri, 12 Jan 2024 16:32:09 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=85=88=E4=B8=8D=E6=B8=85=E7=A9=BA?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E6=97=B6=E5=8F=AF=E8=83=BD=E4=BC=9A=E6=9C=89=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/setRedis.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setRedis.ts b/src/setRedis.ts index 6e6b155..a966efc 100644 --- a/src/setRedis.ts +++ b/src/setRedis.ts @@ -78,8 +78,8 @@ async function clearRedis() { G.redis.fromatKey('equip'), G.redis.fromatKey('shiwu'), G.redis.fromatKey('tanxian'), - G.redis.fromatKey('gbtx'), - G.redis.fromatKey('dxlt'), + //G.redis.fromatKey('gbtx'), + //G.redis.fromatKey('dxlt'), ]) } From e9fba7ed05d1871d871a7d0b7c854d6e6b760034 Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Fri, 12 Jan 2024 17:50:10 +0800 Subject: [PATCH 09/10] =?UTF-8?q?fix:=201=EF=BC=9A=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E6=A1=86=E8=84=9A=E6=9C=AC=202=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fix_patch/patch_20240112-1.ts | 68 +++++++++++++++++++++++++++++++ src/oss/watchdog.json | 19 ++++++++- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/fix_patch/patch_20240112-1.ts diff --git a/src/fix_patch/patch_20240112-1.ts b/src/fix_patch/patch_20240112-1.ts new file mode 100644 index 0000000..a77c559 --- /dev/null +++ b/src/fix_patch/patch_20240112-1.ts @@ -0,0 +1,68 @@ +import { ReqEmail } from "../monopoly/protocols/PtlEmail"; +import { patchInit } from "../patch"; +import { MsgEmail } from "../shared/protocols/msg_s2c/MsgEmail"; +import { PublicShared } from "../shared/public/public"; + + +class Path { + async fun1(a: any) { + let uids = [ + "4_6571ab682b3f80154e724f2a", + "16_6575e1625685671e63fe001f", + "13_6574ad08e7cc32b4bd1334e8", + "13_65749bc319cab1affec349fb", + ]; + + // 删除玩家背包中的头像框 + let items = await G.mongodb.collection("item").find({ uid: { $nin: uids }, itemId: { $in: ["47", "48"] } }).toArray(); + for (let item of items) { + console.log(`删除玩家${item.uid}的头像框道具${item.itemId}`); + await G.mongodb.collection("item").updateOne({ _id: item._id }, { $set: { uid: `patch_del_${item.uid}` } }); + } + + // 删除玩家存在的头像框 + let users = await G.mongodb.collection("user").find({ + uid: { $nin: uids }, $or: [ + { ["headFrame.id"]: "8" }, + { ["headFrame.id"]: "14" }, + { ["headFrames.8"]: { $exists: true } }, + { ["headFrames.14"]: { $exists: true } }, + ] + }).toArray(); + for (let user of users) { + let change = { $set: {}, $unset: {} }; + if (user.headFrame?.id == "8" || user.headFrame?.id == "14") { + change.$set = { headFrame: { id: "1", time: -1 } }; + } + + if (user.headFrames["8"] != undefined) { + change.$unset["headFrames.8"] = 1; + } + + if (user.headFrames["14"] != undefined) { + change.$unset["headFrames.14"] = 1; + } + if (Object.keys(change.$set).length > 0 || Object.keys(change.$unset).length > 0) { + console.log(`处理玩家${user.uid}数据:${JSON.stringify(change)}`); + await G.mongodb.collection("user").updateOne({ _id: user._id }, change); + } + } + } + + async run() { + await this.fun1(1); + } +} + +async function main() { + await patchInit() + let patch = new Path(); + await patch.run(); + console.log("逻辑执行完成,等待退出"); + setTimeout(function () { + console.log('结束程序'); + process.exit(); + }, 3000); +} + +main(); diff --git a/src/oss/watchdog.json b/src/oss/watchdog.json index 6a8027b..1cd80d8 100644 --- a/src/oss/watchdog.json +++ b/src/oss/watchdog.json @@ -11,14 +11,29 @@ }, { "key":"got_rmbmoney", - "limit":50000, - "tips":"钻石获取达到5万" + "limit":100000, + "tips":"钻石获取达到10万" }, { "key":"use_attr_rmbmoney", "limit":100000, "tips":"钻石消耗达到10万" }, + { + "key":"got_huangqijinbi", + "limit":5000, + "tips":"单日获取黄旗金币达到5000" + }, + { + "key":"got_huangqiduihuan", + "limit":10000, + "tips":"单日获取黄旗兑换达到10000" + }, + { + "key": "event/huangqijiuguan/ZhaoMu", + "limit": 1000, + "tips": "单日获取黄旗招募超过1000抽" + }, { "key":"tanxian/FastGuaJi", "limit":30, From 1060c5ccc78d83a1c131173a35738403359a2d04 Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Fri, 12 Jan 2024 18:18:08 +0800 Subject: [PATCH 10/10] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E9=BB=84=E6=97=97?= =?UTF-8?q?=E9=87=91=E5=B8=81=E5=92=8C=E9=BB=84=E6=97=97=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E5=B8=81=E7=9A=84=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/oss/watchdog.json | 2 +- src/public/player.ts | 151 ++++++++++++++++++++++-------------------- 2 files changed, 79 insertions(+), 74 deletions(-) diff --git a/src/oss/watchdog.json b/src/oss/watchdog.json index 1cd80d8..1e97ac3 100644 --- a/src/oss/watchdog.json +++ b/src/oss/watchdog.json @@ -30,7 +30,7 @@ "tips":"单日获取黄旗兑换达到10000" }, { - "key": "event/huangqijiuguan/ZhaoMu", + "key": "huangqijiuguan/ZhaoMu", "limit": 1000, "tips": "单日获取黄旗招募超过1000抽" }, diff --git a/src/public/player.ts b/src/public/player.ts index 1cf7ef2..bc903cf 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -1,23 +1,23 @@ -import {ObjectId, OptionalId} from 'mongodb'; -import {ApiCall, BaseConnection, TsrpcError} from 'tsrpc'; -import {checkPlayerGift} from '../api_s2c/event/xianshilibao/fun'; -import {md_redPoint_check} from '../api_s2c/gongyu/mingdao/ApiOpen'; -import {CollectionPeiJian} from '../module/collection_peijian'; -import {Wjjl} from '../module/collection_wjjl'; -import {MongodbCollections} from '../module/mongodb'; -import {G123} from '../sdk/G123'; -import {ResGetList} from '../shared/protocols/item/PtlGetList'; -import {ResLogin} from '../shared/protocols/user/PtlLogin'; -import {player} from '../shared/protocols/user/type'; -import {HeroShared, otherBuff} from '../shared/public/hero'; -import {PublicShared} from '../shared/public/public'; -import {HeroFun} from './hero'; -import {ShiwuFun} from './shiwu'; -import {UserFun} from './user'; -import {getItemByItemId, getItemNum} from './item'; -import {getGud, setGud} from './gud'; -import {addGameLog} from "../gameLog"; -import {PushGiftFun} from "./pushgift"; +import { ObjectId, OptionalId } from 'mongodb'; +import { ApiCall, BaseConnection, TsrpcError } from 'tsrpc'; +import { checkPlayerGift } from '../api_s2c/event/xianshilibao/fun'; +import { md_redPoint_check } from '../api_s2c/gongyu/mingdao/ApiOpen'; +import { CollectionPeiJian } from '../module/collection_peijian'; +import { Wjjl } from '../module/collection_wjjl'; +import { MongodbCollections } from '../module/mongodb'; +import { G123 } from '../sdk/G123'; +import { ResGetList } from '../shared/protocols/item/PtlGetList'; +import { ResLogin } from '../shared/protocols/user/PtlLogin'; +import { player } from '../shared/protocols/user/type'; +import { HeroShared, otherBuff } from '../shared/public/hero'; +import { PublicShared } from '../shared/public/public'; +import { HeroFun } from './hero'; +import { ShiwuFun } from './shiwu'; +import { UserFun } from './user'; +import { getItemByItemId, getItemNum } from './item'; +import { getGud, setGud } from './gud'; +import { addGameLog } from "../gameLog"; +import { PushGiftFun } from "./pushgift"; import { ActionLog } from './actionLog/actionLog'; import { roleDataType } from '../shared/fightControl/fightType'; import { PlayerShared } from '../shared/public/player'; @@ -48,21 +48,21 @@ export class PlayerFun { * @param uid * @returns */ - static async getDefaultFightDataByUid(uid:string){ + static async getDefaultFightDataByUid(uid: string) { let gud = await getGud(uid); let posObj = gud.heroPos; let roles: k_v = {}; if (gud.selectMatrix && gud.matrixPos) { posObj = gud.matrixPos[gud.selectMatrix]; } - let heros = await HeroFun.getHeros({uid:uid}, Object.values(posObj).filter(_id => _id != '') as string[]); + let heros = await HeroFun.getHeros({ uid: uid }, Object.values(posObj).filter(_id => _id != '') as string[]); let otherBuff = UserFun.getOtherBuff(gud) Object.entries(posObj).forEach(obj => { let pos = obj[0]; let _id = obj[1]; let hero = heros.filter(h => h._id == _id)[0]; - + if (hero) { roles[pos] = { ...hero, @@ -72,7 +72,7 @@ export class PlayerFun { }; } }); - + return { player: { ...gud, buff: PlayerShared.getBuff(gud) }, roles: roles @@ -107,13 +107,13 @@ export class PlayerFun { if (err) { // 消耗不足 触发推送礼包 PushGiftFun.chkItemGift(call.uid, atn) - throw new TsrpcError('', {code: -104, atn: atn}); + throw new TsrpcError('', { code: -104, atn: atn }); } else { - return {isOk: false, atn: atn}; + return { isOk: false, atn: atn }; } } } - return {isOk: true, atn: null}; + return { isOk: true, atn: null }; } /** @@ -131,7 +131,7 @@ export class PlayerFun { atn: need }; if (args.length < 1) { - throw new TsrpcError('', {code: -104, atn: meet.atn}); + throw new TsrpcError('', { code: -104, atn: meet.atn }); } return await this.checkNeedByArgs(call, ...args); } @@ -154,10 +154,10 @@ export class PlayerFun { all.push(this.addItem(call, item)); } // 记录消耗 - addGameLog(call.uid, call.service.name, call.req, {need: val}) + addGameLog(call.uid, call.service.name, call.req, { need: val }) await Promise.all(all); G.emit('USE_ITEM', call.conn.gud, needArr.map(need => { - return {...need, n: Math.abs(need.n)}; + return { ...need, n: Math.abs(need.n) }; })); } @@ -175,7 +175,7 @@ export class PlayerFun { let peijian = prizeList.filter(atn => atn.a == 'peijian' && atn.n != 0); // 记录获得 - addGameLog(call.uid, call.service.name, call.req, {prize: prizeList}) + addGameLog(call.uid, call.service.name, call.req, { prize: prizeList }) await Promise.all([ attr.length > 0 && this.addAttr(call, attr), item.length > 0 && this.addItem(call, item), @@ -217,9 +217,14 @@ export class PlayerFun { } } - if( (atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0 ){ + if ((atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0) { //统计今日获取的金币和钻石 - ActionLog.addDayLog(call.conn.uid, { key: 'got_'+atn.t, val: atn.n }); + ActionLog.addDayLog(call.conn.uid, { key: 'got_' + atn.t, val: atn.n }); + } + + if (["huangqijinbi", "huangqiduihuan"].includes(atn.t) && atn.n > 0) { + //统计今日获取的黄旗金币和黄旗对换币 + ActionLog.addDayLog(call.conn.uid, { key: 'got_' + atn.t, val: atn.n }); } // 增加vip经验的任务监听 @@ -227,7 +232,7 @@ export class PlayerFun { G.emit("Class_task_157", 'Class_task_157', call, atn.n, 0); } all.push(this.changeAttr(call.conn.uid, change)); - all.push(this.upAttr(call, {...atn, n: change[atn.t]})); + all.push(this.upAttr(call, { ...atn, n: change[atn.t] })); //await this.changeAttr(call.conn.uid, change); //await this.upAttr(call, {...atn, n: change[atn.t]}); } @@ -270,17 +275,17 @@ export class PlayerFun { G.mongodb.collection('rmbuse').insertOne(data); // 消费竞赛开启时写入跨服数据库 if (G.huodong.xfjs && !data.isAdd && typeof data.change == 'number') { - G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid, type: `xfjs_${G.huodong.xfjsId}`}, { - $set: {time: G.time}, - $inc: {change: data.change} - }, {upsert: true}); + G.crossmongodb.collection('rmbuse').updateOne({ uid: data.uid, type: `xfjs_${G.huodong.xfjsId}` }, { + $set: { time: G.time }, + $inc: { change: data.change } + }, { upsert: true }); } } static async changeAttr(uid: string, change: Partial) { setGud(uid, change); - G.mongodb.collection('user').updateOne({uid: uid}, {$set: change}); + G.mongodb.collection('user').updateOne({ uid: uid }, { $set: change }); if (G.server.uid_connections[uid]) { checkPlayerGift(G.server.uid_connections[uid].gud, change); @@ -302,9 +307,9 @@ export class PlayerFun { const curLv = call.conn.gud.lv; while (conf[curLv + addLv + 1] && atn.n >= conf[curLv + addLv + 1].need) { addLv++; - G123.sendUserLevelUp({...call.conn.gud, lv: curLv + addLv, nexp: atn.n}); + G123.sendUserLevelUp({ ...call.conn.gud, lv: curLv + addLv, nexp: atn.n }); } - addLv && await this.addAttr(call, {lv: curLv + addLv}); + addLv && await this.addAttr(call, { lv: curLv + addLv }); break; case 'payExp': let addVip = 0; @@ -313,7 +318,7 @@ export class PlayerFun { while (vipConf[curVip + addVip + 1] && atn.n >= vipConf[curVip + addVip + 1].exp) { addVip++; } - addVip && await this.addAttr(call, {vip: curVip + addVip}); + addVip && await this.addAttr(call, { vip: curVip + addVip }); break; } } @@ -324,7 +329,7 @@ export class PlayerFun { static async addItem(call: call, val: atn[]) { for (let atn of val) { let upObj = { - filter: {uid: call.uid, itemId: atn.t}, + filter: { uid: call.uid, itemId: atn.t }, update: { $setOnInsert: { firstTime: G.time, @@ -356,7 +361,7 @@ export class PlayerFun { }; G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options); call.addEventMsg('msg_s2c/ItemChange', atn.t, data); - addGameLog(call.uid, "_itemChange", {"additem": 1}, { + addGameLog(call.uid, "_itemChange", { "additem": 1 }, { "filter": upObj.filter, "update": upObj.update, "options": upObj.options @@ -364,10 +369,10 @@ export class PlayerFun { } else { if (item.num + atn.n <= 0) { await Promise.all([ - G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t}) + G.mongodb.collection('item').deleteOne({ uid: call.uid, itemId: atn.t }) ]); - call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0}); - addGameLog(call.uid, "_itemChange", {"delitem": 1}, {"itemId": atn.t}) + call.addEventMsg('msg_s2c/ItemChange', atn.t, { num: 0 }); + addGameLog(call.uid, "_itemChange", { "delitem": 1 }, { "itemId": atn.t }) } else { await Promise.all([ G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options) @@ -376,7 +381,7 @@ export class PlayerFun { num: item.num + atn.n, lastTime: upObj.update.$set.lastTime }); - addGameLog(call.uid, "_itemChange", {"attritem": 1}, { + addGameLog(call.uid, "_itemChange", { "attritem": 1 }, { "filter": upObj.filter, "update": upObj.update, "options": upObj.options, @@ -411,7 +416,7 @@ export class PlayerFun { insertData.forEach((v, key) => { let id = result.insertedIds[key].toHexString(); - let {_id, ...ops} = v; + let { _id, ...ops } = v; Wjjl.setVal(call.uid, `has_equip_color_${G.gc.equip[ops.equipId].colour}`, 1, false); @@ -445,10 +450,10 @@ export class PlayerFun { */ static async cutEquip(call: call, _idArr: string[]) { for (let _id of _idArr) { - G.mongodb.collection('equip').deleteOne({uid: call.uid, _id: new ObjectId(_id)}); - call.addEventMsg('msg_s2c/EquipChange', _id, {num: 0}); + G.mongodb.collection('equip').deleteOne({ uid: call.uid, _id: new ObjectId(_id) }); + call.addEventMsg('msg_s2c/EquipChange', _id, { num: 0 }); - addGameLog(call.uid, "_cutEquip", {}, {_id: _id}) + addGameLog(call.uid, "_cutEquip", {}, { _id: _id }) } } @@ -482,7 +487,7 @@ export class PlayerFun { let v = insertData[key] let id = result.insertedIds[key].toHexString(); - let {_id, ...ops} = v; + let { _id, ...ops } = v; call.addEventMsg('msg_s2c/HeroChange', id, { _id: id, @@ -515,9 +520,9 @@ export class PlayerFun { static async cutHero(call: call, _idArr: string[]) { for (let _id of _idArr) { await HeroFun.delHero(call, _id); - G.mongodb.collection('hero').deleteOne({uid: call.uid, _id: new ObjectId(_id)}); - call.addEventMsg('msg_s2c/HeroChange', _id, {num: 0}); - addGameLog(call.uid, "_cutHero", {}, {_id: _id}) + G.mongodb.collection('hero').deleteOne({ uid: call.uid, _id: new ObjectId(_id) }); + call.addEventMsg('msg_s2c/HeroChange', _id, { num: 0 }); + addGameLog(call.uid, "_cutHero", {}, { _id: _id }) } } @@ -532,7 +537,7 @@ export class PlayerFun { colour: v.colour, wearId: '', shiwuId: v.t, - jichu: ShiwuFun.randomJichu({colour: v.colour, shiwuId: v.t}), + jichu: ShiwuFun.randomJichu({ colour: v.colour, shiwuId: v.t }), fujia: [] }; if (v.shiwuBuff) { @@ -552,7 +557,7 @@ export class PlayerFun { insertData.forEach((v, key) => { let id = result.insertedIds[key].toHexString(); - let {_id, ...ops} = v; + let { _id, ...ops } = v; call.addEventMsg('msg_s2c/ShiwuChange', id, { _id: id, ...ops @@ -571,9 +576,9 @@ export class PlayerFun { */ static async cutShiwu(call: call, _idArr: string[]) { for (let _id of _idArr) { - G.mongodb.collection('shiwu').deleteOne({uid: call.uid, _id: new ObjectId(_id)}); - call.addEventMsg('msg_s2c/ShiwuChange', _id, {num: 0}); - addGameLog(call.uid, "_cutShiwu", {}, {_id: _id}) + G.mongodb.collection('shiwu').deleteOne({ uid: call.uid, _id: new ObjectId(_id) }); + call.addEventMsg('msg_s2c/ShiwuChange', _id, { num: 0 }); + addGameLog(call.uid, "_cutShiwu", {}, { _id: _id }) } } @@ -598,7 +603,7 @@ export class PlayerFun { addGameLog(call.uid, "_addPeiJian", {}, insertData) insertData.forEach((v, key) => { - let {_id, uid, ...ops} = v; + let { _id, uid, ...ops } = v; let id = _id.toHexString(); if (G.gc.peijian[v.peijianId].colour != 5) { @@ -606,8 +611,8 @@ export class PlayerFun { lshd[v.peijianId]++; } - G.redis.set('peijian', call.uid, id, {_id: id, ...ops}); - call.addEventMsg('msg_s2c/PeijianChange', id, {_id: id, ...ops}); + G.redis.set('peijian', call.uid, id, { _id: id, ...ops }); + call.addEventMsg('msg_s2c/PeijianChange', id, { _id: id, ...ops }); }); G.mongodb.collection('playerInfo', 'lshd_peijian').updateOne( @@ -634,9 +639,9 @@ export class PlayerFun { static async cutPeijian(call: call, _idArr: string[]) { for (let _id of _idArr) { G.redis.del('peijian', call.uid, _id); - G.mongodb.collection('peijian').deleteOne({uid: call.uid, _id: new ObjectId(_id)}); - call.addEventMsg('msg_s2c/PeijianChange', _id, {num: 0}); - addGameLog(call.uid, "_cutPeijian", {}, {_id: _id}) + G.mongodb.collection('peijian').deleteOne({ uid: call.uid, _id: new ObjectId(_id) }); + call.addEventMsg('msg_s2c/PeijianChange', _id, { num: 0 }); + addGameLog(call.uid, "_cutPeijian", {}, { _id: _id }) } } @@ -645,7 +650,7 @@ export class PlayerFun { */ static async getAttr(uid: string, where: { ctype: string; }) { let _w = where; - Object.assign(_w, {uid: uid}); + Object.assign(_w, { uid: uid }); const _res = await G.mongodb.collection('playattr').find(_w).toArray(); _res.forEach(v => { if (v._id) { @@ -660,7 +665,7 @@ export class PlayerFun { */ static async getAttrOne(uid: string, where: { ctype: string; }) { let _w = where; - Object.assign(_w, {uid: uid}); + Object.assign(_w, { uid: uid }); const _res = await G.mongodb.collection('playattr').findOne(_w); if (_res) { delete _res['_id']; @@ -676,10 +681,10 @@ export class PlayerFun { time = G.time; } let _zeroTime = PublicShared.getToDayZeroTime(time); - let _tmp = {lasttime: {$gte: _zeroTime, $lte: _zeroTime + 24 * 60 * 60 - 1}}; + let _tmp = { lasttime: { $gte: _zeroTime, $lte: _zeroTime + 24 * 60 * 60 - 1 } }; let _w = where; - Object.assign(_w, {uid: uid, ..._tmp}); + Object.assign(_w, { uid: uid, ..._tmp }); const _res = await G.mongodb.collection('playattr').find(_w).toArray(); _res.forEach(v => { if (v._id) { @@ -694,7 +699,7 @@ export class PlayerFun { */ static async setAttr(uid: string, where: { ctype: string; }, data: {}, islasttime = 1) { let _w = where; - Object.assign(_w, {uid: uid}); + Object.assign(_w, { uid: uid }); if (islasttime == 1) { data["lasttime"] = G.time; @@ -705,7 +710,7 @@ export class PlayerFun { // 加入创建数据时间 data["ctime"] = G.time; } - let _res = await G.mongodb.collection('playattr').updateMany(_w, {$set: data}, {upsert: true}); + let _res = await G.mongodb.collection('playattr').updateMany(_w, { $set: data }, { upsert: true }); return _res; } } \ No newline at end of file