From 3274911772a18bf185182112274d21b18db0204f Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 25 Dec 2023 17:40:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=93=81=E7=AC=BC=E6=AD=BB=E6=96=97?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extends.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/extends.ts b/src/extends.ts index 6264fc8..db0d2c1 100644 --- a/src/extends.ts +++ b/src/extends.ts @@ -1,4 +1,3 @@ - import 'tsrpc'; import { ApiCall, BaseConnection, ConnectionStatus, WsServer } from 'tsrpc'; import { Wjjl } from './module/collection_wjjl'; @@ -133,7 +132,7 @@ BaseConnection.prototype.getDefaultFightData = async function (this: BaseConnect posObj = this.gud.matrixPos[this.gud.selectMatrix]; } - let heros = await HeroFun.getHeros(this, Object.values(posObj).filter(_id => _id != '')); + let heros = await HeroFun.getHeros(this, Object.values(posObj).filter(_id => _id != '') as string[]); Object.entries(posObj).forEach(obj => { let pos = obj[0]; From 080665f24eb3317231b1d7b3540e53a7a0665f09 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 25 Dec 2023 17:43:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=BB=91=E5=B8=AE=E4=BA=89=E9=9C=B8?= =?UTF-8?q?=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/wzry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/wzry.ts b/src/public/wzry.ts index ac87051..02e848b 100644 --- a/src/public/wzry.ts +++ b/src/public/wzry.ts @@ -179,7 +179,7 @@ export class WangZheRongYaofun { } } if (win_num > 1) { - return _score + win_num - 1 + return _score + win_num } return _score } From bb7495379e44fe8bf1d3abec847a8a495558fe08 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Mon, 25 Dec 2023 20:21:46 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BA=86=E7=9A=84G.redis=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E4=B8=BA=E5=85=A8=E9=9D=A2=E5=BC=83=E7=94=A8?= =?UTF-8?q?=E8=AF=A5redisJson=E5=81=9A=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_o2s/user/Apidisable.ts | 1 - src/api_s2c/ApiBingo.ts | 1 - src/api_s2c/equip/ApiGetList.ts | 1 - src/api_s2c/friend/ApiList.ts | 3 -- src/api_s2c/gonghui/ApiApplyList.ts | 1 - src/api_s2c/gonghui/ApiFbOpen.ts | 2 -- src/api_s2c/gongyu/mingdao/fun.ts | 4 --- src/api_s2c/hero/ApiGetList.ts | 2 -- src/api_s2c/hero/ApiLvUp.ts | 20 ----------- src/api_s2c/hongdian/fun.ts | 21 ------------ src/api_s2c/item/ApiGetList.ts | 15 --------- src/api_s2c/jjc/ApiOpen.ts | 3 -- src/api_s2c/shiwu/ApiGetList.ts | 2 -- src/api_s2c/user/ApiLogin.ts | 2 -- src/extends.ts | 2 -- src/globalListener.ts | 3 -- src/public/email.ts | 32 ------------------ src/public/equip.ts | 3 -- src/public/fight.ts | 7 ---- src/public/gonghui/gh.ts | 3 -- src/public/gonghui/manage.ts | 1 - src/public/hero.ts | 15 +++------ src/public/pay.ts | 1 - src/public/player.ts | 43 ------------------------ src/public/scheduler/scheduler_newDay.ts | 3 -- src/public/scheduler/scheduler_wzry.ts | 35 ------------------- src/public/shiwu.ts | 4 --- src/public/shop.ts | 21 ------------ src/public/user.ts | 20 ----------- src/setStartAfther.ts | 7 ---- src/setWs.ts | 12 ------- src/test.ts | 9 ----- 32 files changed, 4 insertions(+), 295 deletions(-) diff --git a/src/api_o2s/user/Apidisable.ts b/src/api_o2s/user/Apidisable.ts index e07c69d..2ea1ecd 100644 --- a/src/api_o2s/user/Apidisable.ts +++ b/src/api_o2s/user/Apidisable.ts @@ -24,7 +24,6 @@ export default async function (call: ApiCall) { break; } let res = await G.mongodb.collection('user').updateOne({uid}, {$set: data}); - //G.redis.set('user', uid, typeStr, value); setGud(uid, data); let result = res.modifiedCount > 0 ? 0 : 1; //3. 返回结果 diff --git a/src/api_s2c/ApiBingo.ts b/src/api_s2c/ApiBingo.ts index 9ec8155..70a8a14 100644 --- a/src/api_s2c/ApiBingo.ts +++ b/src/api_s2c/ApiBingo.ts @@ -120,7 +120,6 @@ export default async function (call: ApiCall) { } } else if (shell[0] == 'heroMaxLv') { - //let heros = await G.redis.get('hero', call.uid); let s = await G.mongodb.collection('hero').find({ uid: call.uid diff --git a/src/api_s2c/equip/ApiGetList.ts b/src/api_s2c/equip/ApiGetList.ts index 06208e1..f4fede2 100644 --- a/src/api_s2c/equip/ApiGetList.ts +++ b/src/api_s2c/equip/ApiGetList.ts @@ -24,7 +24,6 @@ export default async function (call: ApiCall) { await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({ uid: call.conn.uid, type: 'usertasklog' }, { $set: { maxequiplv: maxequiplv, equipcolor: color } }, { upsert: true }) - //G.redis.set('equip', call.uid, kvList); let recLshd = await G.mongodb.collection('playerInfo', 'lshd_equip').findOne({ uid: call.conn.uid, type: 'lshd_equip' }); let { uid, _id, type, ...equips } = (recLshd || {}); diff --git a/src/api_s2c/friend/ApiList.ts b/src/api_s2c/friend/ApiList.ts index bb1045c..16fbbc5 100644 --- a/src/api_s2c/friend/ApiList.ts +++ b/src/api_s2c/friend/ApiList.ts @@ -15,16 +15,13 @@ export default async function (call: ApiCall) { ]).toArray(); break; case 'friend': - //res = await G.redis.gets('user', ...my.data.friendList.map(uid => [uid] as [string])) res = (await G.mongodb.find('user',{uid:{$in:my.data.friendList}})) as any; break; case 'apply': // 预防申请列表出现脏数据(过滤已添加好友) - //res = await G.redis.gets('user', ...); res = (await G.mongodb.find('user',{uid:{$in: my.data.applyList.filter(uid => my.data.friendList.indexOf(uid) == -1) }})) as any break; case 'black': - //res = await G.redis.gets('user', ...my.data.blacklist.map(uid => [uid] as [string])) res = (await G.mongodb.find('user',{uid:{$in: my.data.blacklist}})) as any; break; diff --git a/src/api_s2c/gonghui/ApiApplyList.ts b/src/api_s2c/gonghui/ApiApplyList.ts index 3478522..d3ec67d 100644 --- a/src/api_s2c/gonghui/ApiApplyList.ts +++ b/src/api_s2c/gonghui/ApiApplyList.ts @@ -5,7 +5,6 @@ export default async function (call: ApiCall) { let GHdata = await call.conn.gonghui if (GHdata.data.applyList?.length > 0) { - //let players = await G.redis.gets('user', ...GHdata.data.applyList.map(a => [a.uid] as [string])); let uids = GHdata.data.applyList.map((i)=>i.uid); let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any; diff --git a/src/api_s2c/gonghui/ApiFbOpen.ts b/src/api_s2c/gonghui/ApiFbOpen.ts index b8c2bf5..7a9caa0 100644 --- a/src/api_s2c/gonghui/ApiFbOpen.ts +++ b/src/api_s2c/gonghui/ApiFbOpen.ts @@ -12,7 +12,6 @@ export default async function (call: ApiCall) { if (call.req.fbId != gh.data.fuben.id) { let md = await G.mongodb.collection('gonghuiFb').findOne({ ghId: gh.data._id, fbId: call.req.fbId }); let uids = Object.keys(md.rankList); - //let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string])); let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any; res.rankList = players.map(p => { return { @@ -22,7 +21,6 @@ export default async function (call: ApiCall) { }); } else { let uids = Object.keys(gh.data.fuben.dps); - //let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string])); let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any; res.rankList = players.map(p => { return { diff --git a/src/api_s2c/gongyu/mingdao/fun.ts b/src/api_s2c/gongyu/mingdao/fun.ts index a91472c..138014e 100644 --- a/src/api_s2c/gongyu/mingdao/fun.ts +++ b/src/api_s2c/gongyu/mingdao/fun.ts @@ -29,12 +29,8 @@ export async function getFinished(conn: BaseConnection, types: string[]) { else if (type == 'use_attr_rmbmoney') obj[type] = await ActionLog.getRetainLog(conn.uid, 'use_attr_rmbmoney'); else if (type == 'zccg') obj[type] = (await G.mongodb.collection('pata').findOne({ uid: conn.uid }))?.lv || 0; else if (type == 'equip_star_5') { - //let equips = await G.redis.get('equip', conn.uid); - //obj[type] = Object.values(equips).filter(e => e.star >= 5).length; obj[type] = await G.mongodb.collection('equip').count({ uid: conn.uid, star: { $gte: 5 } }); } else if (type == 'peijian_colour_5') { - //let peijians = await G.redis.get('peijian', conn.uid); - //obj[type] = Object.values(peijians).filter(p => G.gc.peijian[p.peijianId].colour >= 5).length; obj[type] = await G.mongodb.collection('peijian').count({ uid: conn.uid, peijianId: { $in: peijianGteColor5ID } }); } } diff --git a/src/api_s2c/hero/ApiGetList.ts b/src/api_s2c/hero/ApiGetList.ts index 5cc5a8f..db43836 100644 --- a/src/api_s2c/hero/ApiGetList.ts +++ b/src/api_s2c/hero/ApiGetList.ts @@ -54,8 +54,6 @@ export default async function (call: ApiCall) { await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'}, {$set: {maxherolv: maxherolv, herocolor: color}}, {upsert: true}); - //G.redis.set('hero', call.uid, kvList); - let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({ uid: call.conn.uid, type: 'lshd_hero' diff --git a/src/api_s2c/hero/ApiLvUp.ts b/src/api_s2c/hero/ApiLvUp.ts index 6e52ad4..a631751 100644 --- a/src/api_s2c/hero/ApiLvUp.ts +++ b/src/api_s2c/hero/ApiLvUp.ts @@ -36,23 +36,3 @@ export default async function (call: ApiCall) { kfjsFun.setHeroLvCount(call) } - - - -// export default async function (call: ApiCall) { -// let hero = await G.redis.get('hero', call.uid, call.req.id); -// if (!hero) return call.errorCode(-1); -// if (hero.lv >= call.conn.gud.lv * 3) return call.errorCode(-2); -// -// let need = HeroShared.getHeroLvUpNeed(hero.heroId, hero.lv); -// await PlayerFun.checkNeedIsMeet(call, need); -// await PlayerFun.cutNeed(call, need); -// await HeroFun.changeHeroAttr(call, hero, { -// lv: hero.lv + 1 -// }); -// event_cszl_record(call.conn.gud, hero.heroId, hero.lv, 'lv') -// -// HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']); -// -// call.succ({ lv: hero.lv }); -// } \ No newline at end of file diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index 215f1f0..b00ce8b 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -221,27 +221,6 @@ export class HongDianFun { let prize = G.gc.pata[_myData.lv - 1]?.sdprize; _res.val.saodang.show = max - (_myData.saodangNum || 0) > 0 && !!prize _res.show = _res.show || _res.val.saodang.show - // 商店判断 - // 个人爬塔商店购买情况 - // let shopData = await G.redis.get('shop', call.uid, '7'); // 商店编号7,未理清商店id存放的数据表,后续该出尽量改为数据库读取 - - // 12.12策划确定爬塔id7的商店移除,此处商店不再需要红点 - // let shopData = await ShopFun.getShopData(call.uid, "7") - // if (shopData) { - // let {buyNum, shopItems} = shopData - // // 获取爬塔商店商品 - // for (let index in shopItems) { - // let x = shopItems[index] - // if (x.needZCCG > 0 && x.needZCCG < _myData.lv && (buyNum && !buyNum[index])) { - // // 验证是否达到购买条件 - // let isOk = await (await PlayerFun.checkNeedIsMeet(call, x.buyNeed, false)).isOk - // if (isOk) { - // _res.show = true - // _res.val.shopItems.show = true - // } - // } - // } - // } return _res; } diff --git a/src/api_s2c/item/ApiGetList.ts b/src/api_s2c/item/ApiGetList.ts index 14c8c50..cf155ca 100644 --- a/src/api_s2c/item/ApiGetList.ts +++ b/src/api_s2c/item/ApiGetList.ts @@ -4,21 +4,6 @@ import { ReqGetList, ResGetList } from "../../shared/protocols/item/PtlGetList"; import { getItemList } from "../../public/item"; export default async function (call: ApiCall) { - // let list: ResGetList['list'] = {}; - // let kvList: k_v = {}; - // let arrList = await G.mongodb.collection('item').find({ uid: call.uid,num:{$ne:0}}).toArray(); - - // arrList.forEach(v => { - // let d = G.mongodb.conversionIdObj(v); - // kvList[G.formatRedisKey(d.itemId)] = d; - // list[d.itemId] = d; - // }); - - //去掉item Redis相关 - //G.redis.set('item', call.uid, kvList); - - //call.conn.item = list; - let list = await getItemList(call.uid); call.succ({ list: list diff --git a/src/api_s2c/jjc/ApiOpen.ts b/src/api_s2c/jjc/ApiOpen.ts index dca944f..d9743a8 100644 --- a/src/api_s2c/jjc/ApiOpen.ts +++ b/src/api_s2c/jjc/ApiOpen.ts @@ -20,9 +20,6 @@ export default async function (call: ApiCall) { {$set: {resetTime: G.time, receivedArr: [], buyFightNum: 0, useFightNum: 0}}, ); } - - // G.redis.set('jjc', call.uid, data); - data.recordWin = data.recordWin || 0; let enemy = await JJCFun.randomEnemy(call.uid) diff --git a/src/api_s2c/shiwu/ApiGetList.ts b/src/api_s2c/shiwu/ApiGetList.ts index bcdd561..e5de801 100644 --- a/src/api_s2c/shiwu/ApiGetList.ts +++ b/src/api_s2c/shiwu/ApiGetList.ts @@ -13,8 +13,6 @@ export default async function (call: ApiCall) { list[d._id] = d; }); - // G.redis.set('shiwu', call.uid, kvList); - call.succ({ list: list }); diff --git a/src/api_s2c/user/ApiLogin.ts b/src/api_s2c/user/ApiLogin.ts index 6b54a15..560e7fb 100644 --- a/src/api_s2c/user/ApiLogin.ts +++ b/src/api_s2c/user/ApiLogin.ts @@ -128,8 +128,6 @@ async function doLogin(call: ApiCall) { return call.error(lng.user_10); } - //去掉userRedis相关 - //await G.redis.set('user', gud.uid, gud); await initGud(gud.uid, gud); // 修复公会id diff --git a/src/extends.ts b/src/extends.ts index db0d2c1..28a6730 100644 --- a/src/extends.ts +++ b/src/extends.ts @@ -241,12 +241,10 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection this.gud?.maxpower){ //记录历史最大战力 //this.gud.maxpower = power; - //G.redis.set('user', this.uid, 'maxpower', power); dbUpdate['maxpower'] = power; } //this.gud.power = power; - //G.redis.set('user', this.uid, 'power', power); setGud(this.uid,dbUpdate); G.mongodb.collection('user').updateOne({ uid: this.uid }, { $set: dbUpdate }); diff --git a/src/globalListener.ts b/src/globalListener.ts index 6a5bec8..24fd6eb 100644 --- a/src/globalListener.ts +++ b/src/globalListener.ts @@ -162,9 +162,6 @@ export function addListener() { XstaskFun.uidTask[uid] = null; delete XstaskFun.uidTask[uid]; } - - //离线时更新该玩家的登出时间 - //G.redis.set('user', uid, 'logoutTime', G.time); setGud(uid,{ logoutTime: G.time }); G.mongodb.collection('user').updateOne({ uid: uid }, { $set: { logoutTime: G.time } }); }); diff --git a/src/public/email.ts b/src/public/email.ts index b068322..a8527b1 100644 --- a/src/public/email.ts +++ b/src/public/email.ts @@ -53,22 +53,7 @@ export class EmailFun { if (email.uid == "system" && email.prizeData) _email.prizeData.isGet = _email.prizelist.includes(uid); delete _email.readlist; - // let emailRead = await G.redis.get('email', uid, _email._id, 'emailRead'); - // let emailRead = await G.redis.get('email', uid, _email._id, 'emailRead'); - - // if (email.uid != "system") { - // - // } else { - // // 全服邮件 数据操作 - // if (email?.dellist?.indexOf(uid) == -1 && gud?.cTime && gud.cTime <= email.createTime) { - // if (_email.prizeData) _email.prizeData.isGet = email?.prizelist.indexOf(uid) != -1 - // kvList[G.formatRedisKey(_email._id)] = _email; - // } - // } } - - // G.redis.set('email', uid, kvList); - let lng = await G.redis.rawGet(`user:lng:${uid}`) return Object.values(kvList).map(i => ({ @@ -76,9 +61,6 @@ export class EmailFun { title: i.lngTitle ? (i.lngTitle[lng] || i.lngTitle['ja']) : i.title, content: i.lngContent ? (i.lngContent[lng] || i.lngContent['ja']) : i.content })); - // } else { - // return Object.values(await G.redis.get('email', uid)); - // } } /**领取邮件 */ @@ -89,7 +71,6 @@ export class EmailFun { let change: k_v = {}; let oids = _ids.map(id => { change[id] = true; - // G.redis.set('email', uid, id, 'prizeData', 'isGet', true); return G.mongodb.conversionId(id); }) @@ -111,11 +92,6 @@ export class EmailFun { // 更改邮件状态为已读-仅限没有奖励的邮件 static async readEmail(uid: string, id: string) { - // G.mongodb.collection('email').updateMany({ uid: uid, id: {$in: ids}}, {$set: { emailRead: true}}) - // 查询系统邮件, - // let systemEmail = await G.mongodb.collection('email').find({ uid: "system", id: {$in: ids}}); - // console.log(systemEmail) - // G.redis.set('email', uid, id, 'emailRead', true); G.mongodb.collection('email').updateOne(G.mongodb.conversionIdObj({ uid: uid, _id: id }), {$set: {emailRead: true}}); @@ -151,11 +127,6 @@ export class EmailFun { /**增加 跨服定时器发送邮件 直接写入数据 (跨服定时器执行检测时会报错)*/ static async addEmail(email: ReqEmail & { createTime?: number; }, isCross: boolean = false) { let {prize, uid, ...e} = email; - // if (!isCross) { - // let existUid = await G.redis.hGet('player:uids', uid) - // if (!existUid) return '玩家uid不存在: ' + uid; - // } - let lng = await G.redis.rawGet(`user:lng:${uid}`) let sendEmail: MsgEmail = { @@ -218,7 +189,6 @@ export class EmailFun { if (isCross) return _id sendEmail._id = _id; - // G.redis.set('email', uid, _id, sendEmail); G.server.sendMsgByUid(uid, 'msg_s2c/Email', sendEmail); return _id; @@ -260,8 +230,6 @@ export class EmailFun { })).insertedId.toHexString(); sendEmail._id = _id; - // let conns = G.server.connections; - // G.redis.set('email', uid, _id, sendEmail); G.server.broadcastMsg('msg_s2c/Email', sendEmail); return _id; diff --git a/src/public/equip.ts b/src/public/equip.ts index 0cfba4e..534f2be 100644 --- a/src/public/equip.ts +++ b/src/public/equip.ts @@ -27,9 +27,6 @@ export class EquipFun { Object.assign(equip, change); - // for (let k in change) { - // G.redis.set('equip', call.uid, equip._id, k as keyof CollectionEquip, change[k]); - // } G.mongodb.collection('equip').updateOne({uid: call.uid, _id: new ObjectId(equip._id)}, {$set: {...change}}); call.addEventMsg('msg_s2c/EquipChange', equip._id, change); } diff --git a/src/public/fight.ts b/src/public/fight.ts index c2388b5..2e99911 100644 --- a/src/public/fight.ts +++ b/src/public/fight.ts @@ -135,16 +135,9 @@ export class FightFun { G.mongodb.collection('fightLog').insertOne({uid, type, ...result}) - // if (await G.redis.type('fightLog', type, uid) == null) await G.redis.set('fightLog', type, uid, []); - - // G.redis.arrAppend('fightLog', type, uid, result).then(len => { - // if (len > maxLen) G.redis.arrPop('fightLog', type, uid, 0); - // }); } static async readLog(uid: string, type: string, len = 20) { - // return await G.redis.get('fightLog', type, uid) || []; - return await G.mongodb.collection('fightLog').find({uid, type}).limit(len).toArray() || [] } } \ No newline at end of file diff --git a/src/public/gonghui/gh.ts b/src/public/gonghui/gh.ts index 7676982..99d1206 100644 --- a/src/public/gonghui/gh.ts +++ b/src/public/gonghui/gh.ts @@ -192,7 +192,6 @@ export class GH { * 公会申请审批 */ async apply(...p: string[]) { - //let players = await G.redis.gets('user', ...p.map(u => [u] as [string])); let players = await G.mongodb.find('user',{uid:{$in:p}}); for (let i=0;i [p.uid] as [string])); - // let players = await G.mongodb.find('user',{uid:{$in: this.data.players}}); let uids = this.data.players.map(p => p.uid); let players = await G.mongodb.collection('user').find({uid:{$in: uids}}).toArray(); diff --git a/src/public/gonghui/manage.ts b/src/public/gonghui/manage.ts index d1015c4..e7583ae 100644 --- a/src/public/gonghui/manage.ts +++ b/src/public/gonghui/manage.ts @@ -133,7 +133,6 @@ export class GHManage { } this.countInterval = 0; let list:k_v = await this.getGHList() - // let list = await G.redis.hGetAll('key') Object.entries(list).forEach(v => { let [_id, gh] = v; if (gh.data?.tanhe && G.time >= gh.data.tanhe.time) { diff --git a/src/public/hero.ts b/src/public/hero.ts index 52e104a..edcffc2 100644 --- a/src/public/hero.ts +++ b/src/public/hero.ts @@ -24,10 +24,6 @@ export class HeroFun { hero.zhanli = HeroShared.getHeroZhanLi(hero, call.otherBuff, Object.values(call.conn.gud.heroPos).indexOf(hero._id)); change.zhanli = hero.zhanli; - // for (let k in change) { - // await G.redis.set('hero', call.uid, hero._id, k as any, change[k]); - // } - await G.mongodb.collection('hero').updateOne({uid: call.uid, _id: new ObjectId(hero._id)}, { $set: { ...change @@ -41,13 +37,10 @@ export class HeroFun { /**获取英雄 */ static async getHero(call: call, oid: string) { - //let data = await G.redis.get('hero', call.uid, oid); - //if (!data) { // 如果redis中的hero数据被清理掉 直接查询数据库 - let {_id, ...info} = await G.mongodb.collection("hero").findOne({ - _id: G.mongodb.conversionId(oid) - }) - let data = Object.assign({_id: _id.toHexString()}, info) - //} + let {_id, ...info} = await G.mongodb.collection("hero").findOne({ + _id: G.mongodb.conversionId(oid) + }) + let data = Object.assign({_id: _id.toHexString()}, info) return data } diff --git a/src/public/pay.ts b/src/public/pay.ts index fcb2c5f..fb6fc57 100644 --- a/src/public/pay.ts +++ b/src/public/pay.ts @@ -189,7 +189,6 @@ export class PayFun { let conf: any = await this.getConf(payId, payArgs); let prize = [...conf.prize]; - //let player = await G.redis.get('user', uid); let player = await getGud(uid); if (conf.firstPayPrize.length > 0) { diff --git a/src/public/player.ts b/src/public/player.ts index b8f5bf5..00caf78 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -228,9 +228,6 @@ export class PlayerFun { } static async changeAttr(uid: string, change: Partial) { - //for (let k in change) { - //G.redis.set('user', uid, k as any, change[k]); - //} setGud(uid, change); G.mongodb.collection('user').updateOne({uid: uid}, {$set: change}); @@ -307,9 +304,6 @@ export class PlayerFun { firstTime: upObj.update.$setOnInsert.firstTime, lastTime: upObj.update.$setOnInsert.firstTime }; - //去掉item Redis相关 - //G.redis.set('item', call.uid, atn.t, data); - 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}, { @@ -320,26 +314,14 @@ export class PlayerFun { } else { if (item.num + atn.n <= 0) { await Promise.all([ - //去掉item Redis相关 - //G.redis.del('item', call.uid, atn.t), - G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t}) ]); - //await G.redis.del('item', call.uid, atn.t); - //await 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}) } else { await Promise.all([ - ////去掉item Redis相关 - //G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime), - //G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n), - G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options) ]); - // await G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime); - // await G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n); - // await G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options); call.addEventMsg('msg_s2c/ItemChange', atn.t, { num: item.num + atn.n, lastTime: upObj.update.$set.lastTime @@ -381,11 +363,6 @@ export class PlayerFun { let id = result.insertedIds[key].toHexString(); let {_id, ...ops} = v; - // G.redis.set('equip', call.uid, id, { - // _id: id, - // ...ops - // }); - Wjjl.setVal(call.uid, `has_equip_color_${G.gc.equip[ops.equipId].colour}`, 1, false); call.addEventMsg('msg_s2c/EquipChange', id, { @@ -458,19 +435,6 @@ export class PlayerFun { let id = result.insertedIds[key].toHexString(); let {_id, ...ops} = v; - //https://www.codenong.com/53116318/ - //新号创建时,hero下默认没有uid开头的key,这里会触发(error) ERR missing key at non-terminal path level错误 - //hero/apiGetList里会G.redis.set('hero', call.uid, kvList); - //在这之后再执行下面的代码则不会报错 - - // if (await G.redis.type('hero', call.uid) != null) { - // G.redis.set('hero', call.uid, id, { - // _id: id, - // ...ops - // }); - // } - - call.addEventMsg('msg_s2c/HeroChange', id, { _id: id, ...ops @@ -541,12 +505,6 @@ export class PlayerFun { insertData.forEach((v, key) => { let id = result.insertedIds[key].toHexString(); let {_id, ...ops} = v; - - // G.redis.set('shiwu', call.uid, id, { - // _id: id, - // ...ops - // }); - call.addEventMsg('msg_s2c/ShiwuChange', id, { _id: id, ...ops @@ -565,7 +523,6 @@ export class PlayerFun { */ static async cutShiwu(call: call, _idArr: string[]) { for (let _id of _idArr) { - // G.redis.del('shiwu', call.uid, _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}) diff --git a/src/public/scheduler/scheduler_newDay.ts b/src/public/scheduler/scheduler_newDay.ts index 9014647..59240aa 100644 --- a/src/public/scheduler/scheduler_newDay.ts +++ b/src/public/scheduler/scheduler_newDay.ts @@ -47,9 +47,6 @@ export class SchedulerNewDayLocalCtor extends Scheduler { ...add } }); - // for (let k in add) { - // G.redis.set('user', gud.uid, k as any, add[k] as any); - // } setGud(gud.uid,add); } G.server.sendMsgByUid(gud.uid, 'msg_s2c/PlayerChange', gud) diff --git a/src/public/scheduler/scheduler_wzry.ts b/src/public/scheduler/scheduler_wzry.ts index 02d3a8a..0f78bf7 100644 --- a/src/public/scheduler/scheduler_wzry.ts +++ b/src/public/scheduler/scheduler_wzry.ts @@ -545,41 +545,6 @@ export class SchedulerWzryendDel extends SchedulerWzryAutoBaoMing { } } - -// export class SchedulerWzrycrossEmail extends SchedulerWzryAutoBaoMing { -// id: schedulerType = 'crosseamil_wzry'; -// //每天晚上的20:15分,从跨服里拉取邮件数据到本地 -// time = 72900; -// name = '拉跨服邮件到本服定时器(每天20:15)'; -// type = 'day'; -// -// async start() { -// let _res = await G.clientCross.callApi('wzry/WzFightData', { uid: '', isemail: true }); -// if (_res.isSucc && Object.keys(_res.res.crossEmail).length) { -// let crossEmail = _res.res.crossEmail -// let delEmail = [] -// for (let index = 0; index < crossEmail.length; index++) { -// const element = crossEmail[index]; -// let _prize = element?.prizeData?.prize || [] -// if (element?.prizeData) delete element.prizeData -// element["prize"] = _prize -// if (element.uid == "system") { -// delEmail.push(element._id) -// delete element._id -// EmailFun.addQuanFuEmail(element) -// -// } else if ( await G.redis.hGet('player:uids', element.uid)) { -// delEmail.push(element._id) -// delete element._id -// EmailFun.addEmail(element) -// } -// } -// await G.clientCross.callApi('wzry/UpdateFight', { uid: '', isdelemail: { isdel: true, email: delEmail } }) -// } -// await this.record(); -// } -// } - // 分组 export async function wzrygroup(userList) { let _u = shuffle(userList) diff --git a/src/public/shiwu.ts b/src/public/shiwu.ts index e05018e..0e08382 100644 --- a/src/public/shiwu.ts +++ b/src/public/shiwu.ts @@ -66,10 +66,6 @@ export class ShiwuFun { } } } - - // for (let k in change) { - // G.redis.set('shiwu', call.uid, shiwu._id, k as keyof shiwuType, change[k]); - // } G.mongodb.collection('shiwu').updateOne( {uid: call.uid, _id: new ObjectId(shiwu._id)}, {$set: {...change}} ); diff --git a/src/public/shop.ts b/src/public/shop.ts index a8c8e9e..f212ce0 100644 --- a/src/public/shop.ts +++ b/src/public/shop.ts @@ -47,16 +47,6 @@ export class ShopFun { return shopItems.filter(s => s.openDay <= sDay); } - /**修改商店数据 */ - // static async changeShopData(rId: string, shopId: string, shopData: Partial, change: Partial) { - // - // Object.assign(shopData, change); - // - // for (let k in change) { - // G.redis.set('shop', rId, shopId, k as keyof CollectionShop, change[k]); - // } - // } - static async changeShopData(uid: string, shopId: string, change: Partial) { let where = {uid: uid, shopId: shopId} G.mongodb.collection("shop").updateOne(where, {$set: change}) @@ -120,17 +110,6 @@ export class ShopFun { return shopData } - - /**修改工会商店数据 */ - // static async changeGHShopData(call: ApiCall, shopId: string, shopData: Partial, change: Partial) { - // - // Object.assign(shopData, change); - // - // for (let k in change) { - // G.redis.set('shop', call.conn.gud.ghId, shopId, k as keyof CollectionShop, change[k]); - // } - // } - static async changeGHShopData(ghid: string, shopId: string, change: Partial) { this.changeShopData(ghid, shopId, change) } diff --git a/src/public/user.ts b/src/public/user.ts index 55fcd89..bc7dd6c 100644 --- a/src/public/user.ts +++ b/src/public/user.ts @@ -202,10 +202,6 @@ export class UserFun { ...add } }); - - // for (let k in add) { - // G.redis.set('user', gud.uid, k as any, add[k] as any); - // } setGud(gud.uid, add); } @@ -266,18 +262,12 @@ export class UserFun { } static async getGud(uid: string) { - //return await G.redis.get('user', uid); return await getGud(uid); } /**激活头像框 */ static async activeHeadFrame(uid: string, k: string, v: number) { let gud: player; - // if (G.server.uid_connections[uid]) { - // gud = G.server.uid_connections[uid].gud; - // } else { - // gud = await G.redis.get('user', uid); - // } gud = await getGud(uid); let change = false; @@ -325,11 +315,6 @@ export class UserFun { /**激活聊天框 */ static async activeChatFrame(uid: string, k: string, v: number) { let gud: player; - // if (G.server.uid_connections[uid]) { - // gud = G.server.uid_connections[uid].gud; - // } else { - // gud = await G.redis.get('user', uid); - // } gud = await getGud(uid); let change = false; @@ -377,11 +362,6 @@ export class UserFun { /**激活造型 */ static async activeModel(uid: string, k: string, v: number) { let gud: player; - // if (G.server.uid_connections[uid]) { - // gud = G.server.uid_connections[uid].gud; - // } else { - // gud = await G.redis.get('user', uid); - // } gud = await getGud(uid); let change = false; diff --git a/src/setStartAfther.ts b/src/setStartAfther.ts index 2497190..ba3f732 100644 --- a/src/setStartAfther.ts +++ b/src/setStartAfther.ts @@ -94,13 +94,6 @@ export async function startAfter() { arr.forEach(async u => G.redis.hSet('player:uids', u.uid, 1)) }); - // G.mongodb.collection('payLog').find({}).toArray().then(arr => { - // arr.forEach(a => { - // let { _id, uid, ...logs } = a; - // G.redis.hSet('player:payLog', uid, logs) - // }); - // }); - } else if (G.argv.serverType == 'cross') { RankKbzz.init(); diff --git a/src/setWs.ts b/src/setWs.ts index f5af54c..adc7f4b 100644 --- a/src/setWs.ts +++ b/src/setWs.ts @@ -182,18 +182,6 @@ function setWs(server: WsServer) { if (node.call.service.name == 'user/Login' && node.return.isSucc) { //玩家uid已经登陆在线 通知账号在其他地方登录 const uid = node.return.res.gud.uid; - // const loginConn = server.uid_connections[uid]; - - // let checkPid = await G.redis.hGet("uid2processId", uid); - // if (checkPid && ~~checkPid == process.pid && loginConn) { - // // 本进程踢线 - // loginConn.sendMsg('msg_s2c/OtherLogin', loginConn.ip).then(v => { - // loginConn.close('otherLogin'); - // }); - // } else if (checkPid) { - // // 跨进程踢线,注意这里是异步的 - // await G.server.sendMsgByUid(uid, 'msg_s2c/OtherLogin', '1', String(process.pid)); - // } server.uid_connections[uid] = node.call.conn; setUidProcessId(uid); } diff --git a/src/test.ts b/src/test.ts index 8a12f34..dc482ec 100644 --- a/src/test.ts +++ b/src/test.ts @@ -42,15 +42,6 @@ async function start() { // let c = await getItemNum('0_64e7024f1b2a9acc9e6900fb',['27382','12']); // console.log('c',c) - redisClient.del([ - G.redis.fromatKey('item'), - G.redis.fromatKey('equip'), - G.redis.fromatKey('hero'), - G.redis.fromatKey('shiwu'), - G.redis.fromatKey('gbtx'), - G.redis.fromatKey('dxlt'), - ]) -} //定义全局变量 ctor(); From 91c2827b332263e460651cd98c1eced233a23265 Mon Sep 17 00:00:00 2001 From: dy Date: Mon, 25 Dec 2023 20:27:39 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=20=E8=87=AA=E9=80=89=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/pay.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/pay.ts b/src/public/pay.ts index fcb2c5f..a8c75ec 100644 --- a/src/public/pay.ts +++ b/src/public/pay.ts @@ -251,7 +251,7 @@ export class PayFun { console.log("Christmasfun.payChristmas Error", e); } - if (payArgs.selectPrize) { + if (payArgs && payArgs?.selectPrize) { let selectPrize = await G.ioredis.get(`pay:${payId}:${player.uid}`); if (selectPrize) { prize.push(...JSON.parse(selectPrize)) @@ -422,7 +422,7 @@ export class PayFun { * payArgs里传相应参数,selectList选择的奖励列表 * 往后所有自选类型,走这个方法,配置格式同4、14 */ - if (payArgs.htype && payArgs.selectList) { + if (payArgs && payArgs?.htype && payArgs?.selectList) { let call = this.getCall(player) // @ts-ignore let _hdInfo = (await HuoDongFun.gethdList(call, payArgs.htype))[0]