From 791dbc547298944bdc84f235b703ad0941dd556e Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 22 Dec 2023 16:00:23 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20=E5=BC=82=E6=AD=A5=E6=9F=A5=E5=BA=93?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=90=8C=E6=AD=A5=E6=8F=92=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/pushgift.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/pushgift.ts b/src/public/pushgift.ts index 72fcfde..964b980 100644 --- a/src/public/pushgift.ts +++ b/src/public/pushgift.ts @@ -134,7 +134,7 @@ export class PushGiftFun { static async addGift(uid: string, giftid: string, ext_data: { [key: string]: any }) { let conf = G.gc.tuisonglibao[giftid]; // 更新礼包 - G.mongodb.collection("pushgift").updateOne({ + await G.mongodb.collection("pushgift").updateOne({ uid: uid, id: giftid }, { $set: { From 753dd8decb63204f9ca592e0f6e70aaa2c355274 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 22 Dec 2023 16:06:57 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20=E5=BC=82=E6=AD=A5=E6=9F=A5=E5=BA=93?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=90=8C=E6=AD=A5=E6=8F=92=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/pushgift/ApiOpen.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api_s2c/pushgift/ApiOpen.ts b/src/api_s2c/pushgift/ApiOpen.ts index 58d85b2..399fb72 100644 --- a/src/api_s2c/pushgift/ApiOpen.ts +++ b/src/api_s2c/pushgift/ApiOpen.ts @@ -20,6 +20,7 @@ function chkBuyNum(gift_id: string, gift_info: Gift) { let conf = G.gc.tuisonglibao[gift_id]; for (let i = 0; i < conf.payId.length; i++) { let pay = G.gc.pay[conf.payId[i]]; + let buy = gift_info.buy.map(i => i != 0); if (pay.buys > 0 && gift_info.buy[i] < pay.buys) { return true } From 4c9ad23bc1ff961fe3a96f40c960547cb1144445 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 22 Dec 2023 18:04:56 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/pushgift/ApiItemNoEnough.ts | 9 + .../protocols/pushgift/PtlItemNoEnough.ts | 7 + src/shared/protocols/serviceProto.ts | 197 +++++++++++------- 3 files changed, 135 insertions(+), 78 deletions(-) create mode 100644 src/api_s2c/pushgift/ApiItemNoEnough.ts create mode 100644 src/shared/protocols/pushgift/PtlItemNoEnough.ts diff --git a/src/api_s2c/pushgift/ApiItemNoEnough.ts b/src/api_s2c/pushgift/ApiItemNoEnough.ts new file mode 100644 index 0000000..7f7087a --- /dev/null +++ b/src/api_s2c/pushgift/ApiItemNoEnough.ts @@ -0,0 +1,9 @@ +import {ApiCall} from "tsrpc"; +import {ReqItemNoEnough, ResItemNoEnough} from "../../shared/protocols/pushgift/PtlItemNoEnough"; +import {PushGiftFun} from "../../public/pushgift"; + +export default async function (call: ApiCall) { + // 物品不足 前端拦截的 通知后端 检测推送礼包 + PushGiftFun.chkItemGift(call.uid, {a: call.req.need.a, t: call.req.need.t, n: 0}) + call.succ({}) +} \ No newline at end of file diff --git a/src/shared/protocols/pushgift/PtlItemNoEnough.ts b/src/shared/protocols/pushgift/PtlItemNoEnough.ts new file mode 100644 index 0000000..7ab7ec4 --- /dev/null +++ b/src/shared/protocols/pushgift/PtlItemNoEnough.ts @@ -0,0 +1,7 @@ +import {Gift} from "../../../module/collection_pushgift"; + +export type ReqItemNoEnough = { + need: { a: string, t: string } +} + +export type ResItemNoEnough = {} diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 218afc9..e114348 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -265,6 +265,7 @@ import { ReqBingo, ResBingo } from './PtlBingo'; import { ReqFightTest, ResFightTest } from './PtlFightTest'; import { ReqSyncBtn, ResSyncBtn } from './PtlSyncBtn'; import { ReqTest, ResTest } from './PtlTest'; +import { ReqItemNoEnough, ResItemNoEnough } from './pushgift/PtlItemNoEnough'; import { ReqOpen as ReqOpen_48, ResOpen as ResOpen_48 } from './pushgift/PtlOpen'; import { ReqFight as ReqFight_9, ResFight as ResFight_9 } from './qjzzd/PtlFight'; import { ReqOpen as ReqOpen_49, ResOpen as ResOpen_49 } from './qjzzd/PtlOpen'; @@ -1295,6 +1296,10 @@ export interface ServiceType { req: ReqTest, res: ResTest }, + "pushgift/ItemNoEnough": { + req: ReqItemNoEnough, + res: ResItemNoEnough + }, "pushgift/Open": { req: ReqOpen_48, res: ResOpen_48 @@ -3085,126 +3090,131 @@ export const serviceProto: ServiceProto = { }, { "id": 266, - "name": "pushgift/Open", + "name": "pushgift/ItemNoEnough", "type": "api" }, { "id": 267, - "name": "qjzzd/Fight", + "name": "pushgift/Open", "type": "api" }, { "id": 268, - "name": "qjzzd/Open", + "name": "qjzzd/Fight", "type": "api" }, { "id": 269, - "name": "rank/Open", + "name": "qjzzd/Open", "type": "api" }, { "id": 270, - "name": "shiwu/Concise", + "name": "rank/Open", "type": "api" }, { "id": 271, - "name": "shiwu/Extract", + "name": "shiwu/Concise", "type": "api" }, { "id": 272, - "name": "shiwu/GetList", + "name": "shiwu/Extract", "type": "api" }, { "id": 273, - "name": "shiwu/LvUp", + "name": "shiwu/GetList", "type": "api" }, { "id": 274, - "name": "shiwu/Recast", + "name": "shiwu/LvUp", "type": "api" }, { "id": 275, - "name": "shiwu/TakeOff", + "name": "shiwu/Recast", "type": "api" }, { "id": 276, - "name": "shiwu/Wear", + "name": "shiwu/TakeOff", "type": "api" }, { "id": 277, - "name": "shootGame/Open", + "name": "shiwu/Wear", "type": "api" }, { "id": 278, - "name": "shootGame/Rec", + "name": "shootGame/Open", "type": "api" }, { "id": 279, - "name": "shop/Buy", + "name": "shootGame/Rec", "type": "api" }, { "id": 280, - "name": "shop/Open", + "name": "shop/Buy", "type": "api" }, { "id": 281, - "name": "shop/Refresh", + "name": "shop/Open", "type": "api" }, { "id": 282, - "name": "sign/GetBoxPrize", + "name": "shop/Refresh", "type": "api" }, { "id": 283, - "name": "sign/GetPrize", + "name": "sign/GetBoxPrize", "type": "api" }, { "id": 284, - "name": "sign/Open", + "name": "sign/GetPrize", "type": "api" }, { "id": 285, - "name": "slzd/Aim", + "name": "sign/Open", "type": "api" }, { "id": 286, - "name": "slzd/BuyNum", + "name": "slzd/Aim", "type": "api" }, { "id": 287, - "name": "slzd/Fight", + "name": "slzd/BuyNum", "type": "api" }, { "id": 288, - "name": "slzd/FightLog", + "name": "slzd/Fight", "type": "api" }, { "id": 289, - "name": "slzd/MyRank", + "name": "slzd/FightLog", "type": "api" }, { "id": 290, + "name": "slzd/MyRank", + "type": "api" + }, + { + "id": 291, "name": "slzd/Open", "type": "api", "conf": { @@ -3214,77 +3224,77 @@ export const serviceProto: ServiceProto = { } }, { - "id": 291, + "id": 292, "name": "slzd/OpenFort", "type": "api" }, { - "id": 292, + "id": 293, "name": "slzd/Rec", "type": "api" }, { - "id": 293, + "id": 294, "name": "slzd/Refresh", "type": "api" }, { - "id": 294, + "id": 295, "name": "slzd/Slot", "type": "api" }, { - "id": 295, + "id": 296, "name": "tanxian/Event", "type": "api" }, { - "id": 296, + "id": 297, "name": "tanxian/FastGuaJi", "type": "api" }, { - "id": 297, + "id": 298, "name": "tanxian/Fight", "type": "api" }, { - "id": 298, + "id": 299, "name": "tanxian/GuaJi", "type": "api" }, { - "id": 299, + "id": 300, "name": "tanxian/Open", "type": "api" }, { - "id": 300, + "id": 301, "name": "tanxian/Receive", "type": "api" }, { - "id": 301, + "id": 302, "name": "task/AllFinsh", "type": "api" }, { - "id": 302, + "id": 303, "name": "task/Finsh", "type": "api" }, { - "id": 303, + "id": 304, "name": "task/Open", "type": "api" }, { - "id": 304, + "id": 305, "name": "user/CDKEY", "type": "api" }, { - "id": 305, + "id": 306, "name": "user/ChangeInfo", "type": "api", "conf": { @@ -3292,197 +3302,197 @@ export const serviceProto: ServiceProto = { } }, { - "id": 306, + "id": 307, "name": "user/ChangeName", "type": "api" }, { - "id": 307, + "id": 308, "name": "user/Fight", "type": "api" }, { - "id": 308, + "id": 309, "name": "user/GetInfo", "type": "api" }, { - "id": 309, + "id": 310, "name": "user/InfoOpen", "type": "api" }, { - "id": 310, + "id": 311, "name": "user/Login", "type": "api" }, { - "id": 311, + "id": 312, "name": "user/Ping", "type": "api" }, { - "id": 312, + "id": 313, "name": "user/Renown", "type": "api" }, { - "id": 313, + "id": 314, "name": "user/RenownBuy", "type": "api" }, { - "id": 314, + "id": 315, "name": "user/RenownGetPrize", "type": "api" }, { - "id": 315, + "id": 316, "name": "user/RenownOpen", "type": "api" }, { - "id": 316, + "id": 317, "name": "user/Tujian", "type": "api" }, { - "id": 317, + "id": 318, "name": "weixiuchang/Decompose", "type": "api" }, { - "id": 318, + "id": 319, "name": "weixiuchang/Exchange", "type": "api" }, { - "id": 319, + "id": 320, "name": "weixiuchang/Open", "type": "api" }, { - "id": 320, + "id": 321, "name": "weixiuchang/UpLv", "type": "api" }, { - "id": 321, + "id": 322, "name": "weixiuchang/UpStar", "type": "api" }, { - "id": 322, + "id": 323, "name": "wzry/AutoBaoMing", "type": "api" }, { - "id": 323, + "id": 324, "name": "wzry/BaoMing", "type": "api" }, { - "id": 324, + "id": 325, "name": "wzry/catFightLog", "type": "api" }, { - "id": 325, + "id": 326, "name": "wzry/CatGroup", "type": "api" }, { - "id": 326, + "id": 327, "name": "wzry/DldFight", "type": "api" }, { - "id": 327, + "id": 328, "name": "wzry/DldRefre", "type": "api" }, { - "id": 328, + "id": 329, "name": "wzry/JingCai", "type": "api" }, { - "id": 329, + "id": 330, "name": "wzry/JingCaiOpen", "type": "api" }, { - "id": 330, + "id": 331, "name": "wzry/Open", "type": "api" }, { - "id": 331, + "id": 332, "name": "wzry/UpdateFight", "type": "api" }, { - "id": 332, + "id": 333, "name": "wzry/Wzzd", "type": "api" }, { - "id": 333, + "id": 334, "name": "wzry/ZuanShiOpen", "type": "api" }, { - "id": 334, + "id": 335, "name": "xstask/AllGet", "type": "api" }, { - "id": 335, + "id": 336, "name": "xstask/Get", "type": "api" }, { - "id": 336, + "id": 337, "name": "xstask/LvUp", "type": "api" }, { - "id": 337, + "id": 338, "name": "xstask/OnekeyReceive", "type": "api" }, { - "id": 338, + "id": 339, "name": "xstask/Open", "type": "api" }, { - "id": 339, + "id": 340, "name": "xstask/Receive", "type": "api" }, { - "id": 340, + "id": 341, "name": "xstask/Refresh", "type": "api" }, { - "id": 341, + "id": 342, "name": "yongbingzhuzhan/Handle", "type": "api" }, { - "id": 342, + "id": 343, "name": "zhanqianbushu/ChangePos", "type": "api" }, { - "id": 343, + "id": 344, "name": "zhanqianbushu/Select", "type": "api" }, { - "id": 344, + "id": 345, "name": "zhanqianbushu/Up", "type": "api" } @@ -19029,6 +19039,37 @@ export const serviceProto: ServiceProto = { "PtlTest/ResTest": { "type": "Any" }, + "pushgift/PtlItemNoEnough/ReqItemNoEnough": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "need", + "type": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "a", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "t", + "type": { + "type": "String" + } + } + ] + } + } + ] + }, + "pushgift/PtlItemNoEnough/ResItemNoEnough": { + "type": "Interface" + }, "pushgift/PtlOpen/ReqOpen": { "type": "Interface" }, From df641aa69fc4bb4caddacb22064084332f0377bb Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Thu, 14 Dec 2023 20:57:15 +0800 Subject: [PATCH 4/7] =?UTF-8?q?feat:=201.=E6=8E=A8=E9=80=81=E7=A4=BC?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit ef90c131f344f05b780a2d6835453cdef7581539) --- src/globalListener.ts | 2 ++ src/public/pushgift.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/globalListener.ts b/src/globalListener.ts index 9300f46..bd10c64 100644 --- a/src/globalListener.ts +++ b/src/globalListener.ts @@ -17,6 +17,7 @@ import { PublicShared } from './shared/public/public'; import { setGud } from './public/gud'; import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen"; import {Christmasfun} from "./api_s2c/event/christmas/fun"; +import {PushGiftFun} from "./public/pushgift"; export type gEventType = { /**玩家断开连接 */ @@ -194,6 +195,7 @@ export function addListener() { { $inc: { payNum: conf.money } }, { upsert: true } ); + PushGiftFun.buy(player.uid, payId) // 推送礼包 }); G.on("FIRST_LOGIN_EVERY_DAY", (gud, lastTime, curTime) => { diff --git a/src/public/pushgift.ts b/src/public/pushgift.ts index 964b980..c9a7779 100644 --- a/src/public/pushgift.ts +++ b/src/public/pushgift.ts @@ -152,4 +152,22 @@ export class PushGiftFun { // 推送客户端消息 G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", 1); } + + static async buy(uid: string, payId: string) { + // 购买礼包 + let gift; + for (let gift_id in G.gc.tuisonglibao) { + gift = G.gc.tuisonglibao[gift_id]; + if (gift.payId.includes(payId)) break; + } + let index = gift.payId.indexOf(payId); + let info = await G.mongodb.collection("pushgift").findOne({ + uid: uid, id: gift.id.toString() + }) + if (info.passTime >= G.time) { + G.mongodb.collection("pushgift").updateOne({ + uid: uid, id: gift.id.toString() + }, {$inc: {[`buy.${index}`]: 1}}) + } + } } \ No newline at end of file From 58ba7b489d7340b190567057a9977f6ed4bd386f Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 15 Dec 2023 10:30:37 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat:=201.=E6=8E=A8=E9=80=81=E7=A4=BC?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit e99b5dad155cd87e3c2c0c5acb1522a2aa4a7695) --- src/public/fight.ts | 2 +- src/public/pushgift.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/public/fight.ts b/src/public/fight.ts index c13c029..c2388b5 100644 --- a/src/public/fight.ts +++ b/src/public/fight.ts @@ -118,7 +118,7 @@ export class FightFun { // 主线 爬塔 战败触发推送礼包 if (result.winSide != 0 && ["tanxian", "pata"].includes(type)) { - PushGiftFun.chkLoseGift(data[0].player.uid) + PushGiftFun.chkLoseGift(call.uid) } return result } diff --git a/src/public/pushgift.ts b/src/public/pushgift.ts index c9a7779..63edb43 100644 --- a/src/public/pushgift.ts +++ b/src/public/pushgift.ts @@ -54,7 +54,7 @@ export class PushGiftFun { let gift_ids = []; for (let id in G.gc.tuisonglibao) { let conf = G.gc.tuisonglibao[id]; - if (conf.type == PushGiftType.LevelGift && conf.num[0] == lv) { + if (conf.type == PushGiftType.LvGift && conf.num[0] == lv) { gift_ids.push(id); } } @@ -157,17 +157,23 @@ export class PushGiftFun { // 购买礼包 let gift; for (let gift_id in G.gc.tuisonglibao) { - gift = G.gc.tuisonglibao[gift_id]; - if (gift.payId.includes(payId)) break; + let temp = G.gc.tuisonglibao[gift_id]; + if (temp.payId.includes(payId)) { + gift = temp; + break + } } + if (!gift) return; let index = gift.payId.indexOf(payId); let info = await G.mongodb.collection("pushgift").findOne({ uid: uid, id: gift.id.toString() }) if (info.passTime >= G.time) { - G.mongodb.collection("pushgift").updateOne({ + await G.mongodb.collection("pushgift").updateOne({ uid: uid, id: gift.id.toString() }, {$inc: {[`buy.${index}`]: 1}}) + // 推送客户端消息 + G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", 1); } } } \ No newline at end of file From ae8da996aedebfbd1828fa060d6dd990f5532ca2 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 22 Dec 2023 16:00:23 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E6=8E=A8=E9=80=81=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/pushgift.ts | 4 ++-- src/shared/protocols/msg_s2c/MsgPushGiftChange.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/public/pushgift.ts b/src/public/pushgift.ts index 63edb43..0e50409 100644 --- a/src/public/pushgift.ts +++ b/src/public/pushgift.ts @@ -150,7 +150,7 @@ export class PushGiftFun { return {payId: i, val: []} })) // 推送客户端消息 - G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", 1); + G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", conf.id); } static async buy(uid: string, payId: string) { @@ -173,7 +173,7 @@ export class PushGiftFun { uid: uid, id: gift.id.toString() }, {$inc: {[`buy.${index}`]: 1}}) // 推送客户端消息 - G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", 1); + G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", gift.id); } } } \ No newline at end of file diff --git a/src/shared/protocols/msg_s2c/MsgPushGiftChange.ts b/src/shared/protocols/msg_s2c/MsgPushGiftChange.ts index 4c04b9b..ccd1837 100644 --- a/src/shared/protocols/msg_s2c/MsgPushGiftChange.ts +++ b/src/shared/protocols/msg_s2c/MsgPushGiftChange.ts @@ -1 +1 @@ -export type MsgPushGiftChange = 1; +export type MsgPushGiftChange = number; From 5a7c645e0f96afaceb7001717dd1a7a75d438e0a Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 22 Dec 2023 20:39:14 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E6=8E=A8=E9=80=81=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/protocols/serviceProto.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index e114348..466dad2 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -17962,8 +17962,7 @@ export const serviceProto: ServiceProto = { } }, "msg_s2c/MsgPushGiftChange/MsgPushGiftChange": { - "type": "Literal", - "literal": 1 + "type": "Number" }, "msg_s2c/MsgSendGift/MsgSendGift": { "type": "Interface",