Merge branch 'feature/playerhead' into dev

This commit is contained in:
dy 2023-12-20 19:18:10 +08:00
commit 5f0d645c08
2 changed files with 20 additions and 11 deletions

View File

@ -1,16 +1,25 @@
import { ApiCall } from "tsrpc"; import {ApiCall} from "tsrpc";
import { PlayerFun } from '../../public/player'; import {PlayerFun} from '../../public/player';
import { ReqChangeInfo, ResChangeInfo } from "../../shared/protocols/user/PtlChangeInfo"; import {ReqChangeInfo, ResChangeInfo} from "../../shared/protocols/user/PtlChangeInfo";
import { ResLogin } from '../../shared/protocols/user/PtlLogin'; import {ResLogin} from '../../shared/protocols/user/PtlLogin';
import { UserShared } from '../../shared/public/user'; import {UserShared} from '../../shared/public/user';
export default async function (call: ApiCall<ReqChangeInfo, ResChangeInfo>) { export default async function (call: ApiCall<ReqChangeInfo, ResChangeInfo>) {
if (call.req.type == 'model' && !call.req.pos) return call.error(globalThis.lng.shiwu_6); 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 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); if (!isMeet && call.req.type != 'headFrame' && call.req.type != 'chatFrame') return call.error(globalThis.lng.user_1);

View File

@ -1,15 +1,14 @@
export class UserShared { export class UserShared {
/**获取头像之类id */ /**获取头像之类id */
static getInfoId(type: 'head' | 'headFrame' | 'chatFrame' | 'model', id: string, pos?: string) { static getInfoId(type: 'head' | 'headFrame' | 'chatFrame' | 'model', id: string, pos?: string) {
return Array.from(arguments).filter(s => s != '').join('_'); return Array.from(arguments).filter(s => s != '').join('_');
} }
/** /**
* *
* @param id 使 UserShared.getInfo id * @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 [type, id, pos] = fmtId.split('_');
const jsonName = 'player' + type.slice(0, 1).toLocaleUpperCase() + type.slice(1); 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] == '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] == '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] == '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; else return false;
} }
} }