Merge branch 'feature/playerhead' into dev
This commit is contained in:
commit
5f0d645c08
@ -8,9 +8,18 @@ export default async function (call: ApiCall<ReqChangeInfo, ResChangeInfo>) {
|
||||
|
||||
if (call.req.type == 'model' && !call.req.pos) return call.error(globalThis.lng.shiwu_6);
|
||||
|
||||
const active = (await G.mongodb.collection('playerInfo', 'playerInfo').findOne({ uid: call.uid, type: 'playerInfo' }))?.active || {};
|
||||
const active = (await G.mongodb.collection('playerInfo', 'playerInfo').findOne({
|
||||
uid: call.uid,
|
||||
type: 'playerInfo'
|
||||
}))?.active || {};
|
||||
const fmtId = UserShared.getInfoId(call.req.type, call.req.id, call.req.pos || '');
|
||||
const isMeet = UserShared.chechIsActive(fmtId, { lv: call.conn.gud.lv, vip: call.conn.gud.vip, lsyx: call.conn.lshd.hero, active: active });
|
||||
const isMeet = UserShared.chechIsActive(fmtId, {
|
||||
lv: call.conn.gud.lv,
|
||||
vip: call.conn.gud.vip,
|
||||
lsyx: call.conn.lshd.hero,
|
||||
model: call.conn.gud.model,
|
||||
active: active
|
||||
});
|
||||
|
||||
if (!isMeet && call.req.type != 'headFrame' && call.req.type != 'chatFrame') return call.error(globalThis.lng.user_1);
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
|
||||
export class UserShared {
|
||||
/**获取头像之类id */
|
||||
static getInfoId(type: 'head' | 'headFrame' | 'chatFrame' | 'model', id: string, pos?: string) {
|
||||
return Array.from(arguments).filter(s => s != '').join('_');
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断头像之类是否激活
|
||||
* @param id 请使用 UserShared.getInfo 转化后的id
|
||||
*/
|
||||
static chechIsActive(fmtId: string, collection: Partial<{ lv: number, vip: number, lsyx: k_v<number>, active: k_v<number>; }>) {
|
||||
static chechIsActive(fmtId: string, collection: Partial<{ lv: number, vip: number, lsyx: k_v<number>, model: k_v<any>, active: k_v<number>; }>) {
|
||||
|
||||
const [type, id, pos] = fmtId.split('_');
|
||||
const jsonName = 'player' + type.slice(0, 1).toLocaleUpperCase() + type.slice(1);
|
||||
@ -20,6 +19,7 @@ export class UserShared {
|
||||
else if (conf.cond[0] == 'vip') return collection.vip >= conf.cond[1];
|
||||
else if (conf.cond[0] == 'hero') return collection.lsyx[conf.cond[1]] > 0;
|
||||
else if (conf.cond[0] == 'time') return collection.active[fmtId] == -1 || collection.active[fmtId] > G.time;
|
||||
else if (conf.cond[0] == 'model') return Object.values(collection.model).find(i=>i.id==conf.cond[1]);
|
||||
else return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user