From 48e656e65289c5f25d193cfb81ebc267fd5fba22 Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 20 Dec 2023 19:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E5=A4=B4=E5=83=8F=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E9=80=A0=E5=9E=8B=EF=BC=8C=E5=A4=B4=E5=83=8F=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=A2=9E=E5=8A=A0model=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/user/ApiChangeInfo.ts | 23 ++++++++++++++++------- src/shared/public/user.ts | 8 ++++---- 2 files changed, 20 insertions(+), 11 deletions(-) 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