feat:
推送礼包新加威望等级推送礼包
This commit is contained in:
parent
7c3b5e985c
commit
bb3cea2f02
@ -1,6 +1,7 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import { ReqUpLv, ResUpLv } from "../../shared/protocols/weiwang/PtlUpLv";
|
import { ReqUpLv, ResUpLv } from "../../shared/protocols/weiwang/PtlUpLv";
|
||||||
import { PlayerFun } from "../../public/player";
|
import { PlayerFun } from "../../public/player";
|
||||||
|
import { PushGiftFun } from "../../public/pushgift";
|
||||||
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqUpLv, ResUpLv>) {
|
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 },
|
$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 } });
|
call.succ({ lv: { hp: data.hp, atk: data.atk, def: data.def } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ const PushGiftType = {
|
|||||||
LoseGift: 3, // 战败推送
|
LoseGift: 3, // 战败推送
|
||||||
RecruitGift: 4, // 十连推送
|
RecruitGift: 4, // 十连推送
|
||||||
LvGift: 5, // 等级推送
|
LvGift: 5, // 等级推送
|
||||||
|
RenownGift: 6, // 影响力等级
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PushGiftFun {
|
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[]) {
|
static async pushGift(uid: string, gift_ids: string[]) {
|
||||||
let gifts = {};
|
let gifts = {};
|
||||||
(await this.getGift(uid)).forEach(i => gifts[i.id] = i)
|
(await this.getGift(uid)).forEach(i => gifts[i.id] = i)
|
||||||
|
Loading…
Reference in New Issue
Block a user