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 e003088..22fb397 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