diff --git a/src/api_s2c/user/ApiChangeInfo.ts b/src/api_s2c/user/ApiChangeInfo.ts index 4d221d3..012bb9f 100644 --- a/src/api_s2c/user/ApiChangeInfo.ts +++ b/src/api_s2c/user/ApiChangeInfo.ts @@ -1,16 +1,25 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../public/player'; -import { ReqChangeInfo, ResChangeInfo } from "../../shared/protocols/user/PtlChangeInfo"; -import { ResLogin } from '../../shared/protocols/user/PtlLogin'; -import { UserShared } from '../../shared/public/user'; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../public/player'; +import {ReqChangeInfo, ResChangeInfo} from "../../shared/protocols/user/PtlChangeInfo"; +import {ResLogin} from '../../shared/protocols/user/PtlLogin'; +import {UserShared} from '../../shared/public/user'; export default async function (call: ApiCall) { 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); diff --git a/src/shared/public/user.ts b/src/shared/public/user.ts index 086fed9..55361c3 100644 --- a/src/shared/public/user.ts +++ b/src/shared/public/user.ts @@ -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, active: k_v; }>) { + static chechIsActive(fmtId: string, collection: Partial<{ lv: number, vip: number, lsyx: k_v, model: k_v, active: k_v; }>) { 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; } } \ No newline at end of file