推送礼包新加威望等级推送礼包
This commit is contained in:
xichaoyin 2024-01-06 11:49:13 +08:00
parent 7c3b5e985c
commit bb3cea2f02
2 changed files with 34 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqUpLv, ResUpLv } from "../../shared/protocols/weiwang/PtlUpLv";
import { PlayerFun } from "../../public/player";
import { PushGiftFun } from "../../public/pushgift";
export default async function (call: ApiCall<ReqUpLv, ResUpLv>) {
@ -52,6 +53,10 @@ export default async function (call: ApiCall<ReqUpLv, ResUpLv>) {
$inc: { [call.req.type]: call.req.lv },
});
// 检测触发推送礼包
PushGiftFun.chkRenownGift(
call.uid, { atk: data.atk, def: data.def, hp: data.hp }
);
call.succ({ lv: { hp: data.hp, atk: data.atk, def: data.def } });
}

View File

@ -6,6 +6,7 @@ const PushGiftType = {
LoseGift: 3, // 战败推送
RecruitGift: 4, // 十连推送
LvGift: 5, // 等级推送
RenownGift: 6, // 影响力等级
}
export class PushGiftFun {
@ -95,6 +96,24 @@ export class PushGiftFun {
}
}
static async chkRenownGift(uid: string, data: { atk: number, def: number, hp: number }) {
let min_lv = Math.min(data.atk, data.def, data.hp);
let gift_ids = [];
for (let id in G.gc.tuisonglibao) {
let conf = G.gc.tuisonglibao[id];
if (conf.type == PushGiftType.RenownGift && conf.num[0] == min_lv) {
gift_ids.push(id);
}
}
if (gift_ids.length <= 0) {
return
} else {
this.pushGift(uid, gift_ids)
}
}
static async pushGift(uid: string, gift_ids: string[]) {
let gifts = {};
(await this.getGift(uid)).forEach(i => gifts[i.id] = i)