From f19c1fa7c178569a218bb1e775ed2a979cf731ad Mon Sep 17 00:00:00 2001 From: Kokomi <1379177109@qq.com> Date: Thu, 2 Nov 2023 21:20:16 +0800 Subject: [PATCH] =?UTF-8?q?Avatar=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9D=90=E6=96=99=E7=9B=B8=E5=85=B3=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/profile/ProfileStat.js | 5 ++- models/Avatar.js | 83 +++++++++++++++++++------------------ models/Player.js | 9 +++- models/avatar/MysAvatar.js | 8 ++++ 4 files changed, 63 insertions(+), 42 deletions(-) diff --git a/apps/profile/ProfileStat.js b/apps/profile/ProfileStat.js index ebd05afa..b4603d23 100644 --- a/apps/profile/ProfileStat.js +++ b/apps/profile/ProfileStat.js @@ -11,7 +11,7 @@ const ProfileStat = { }, // 渲染 - // isAvatarList true:练度统计 false角色列表 + // isAvatarList true:角色列表 false练度统计 async render (e, isAvatarList = false) { // 缓存时间,单位小时 let msg = e.msg.replace('#', '').trim() @@ -20,6 +20,8 @@ const ProfileStat = { return false } + let isTalent = !isAvatarList && /天赋|技能/.test(msg) + let mys = await MysApi.init(e) if (!mys || !mys.uid) return false @@ -32,6 +34,7 @@ const ProfileStat = { detail: 1, talent: isAvatarList ? 0 : 1, rank: true, + materials: isTalent, retType: 'array', sort: true }) diff --git a/models/Avatar.js b/models/Avatar.js index 2590a4df..56ef94ba 100644 --- a/models/Avatar.js +++ b/models/Avatar.js @@ -8,6 +8,7 @@ import Artis from './artis/Artis.js' import ProfileAvatar from './avatar/ProfileAvatar.js' import ArtisMark from './artis/ArtisMark.js' import moment from 'moment' +import MysAvatar from './avatar/MysAvatar.js' const charKey = 'name,abbr,sName,star,imgs,face,side,gacha,weaponTypeName'.split(',') @@ -26,7 +27,6 @@ export default class Avatar extends Base { this.setAvatar(ds) } - get hasTalent () { return this.talent && !lodash.isEmpty(this.talent) && !!this._talent } @@ -91,13 +91,50 @@ export default class Avatar extends Base { return '' } + get isAvatar () { + return true + } + + // 是否是合法面板数据 + get isProfile () { + return ProfileAvatar.isProfile(this) + } + + // profile.hasData 别名 + get hasData () { + return !!(this.level > 1 || this?.weapon?.name) + } + + get imgs () { + return this.char.getImgs(this.costume) || {} + } + + get costumeSplash () { + return ProfileAvatar.getCostumeSplash(this) + } + + get hasDmg () { + return this.isProfile && !!ProfileDmg.dmgRulePath(this.name, this.game) + } + + get artis () { + return this._artis + } + + static create (ds, game = 'gs') { + let profile = new Avatar(ds, game) + if (!profile) { + return false + } + return profile + } + _get (key) { if (charKey.includes(key)) { return this.char[key] } } - /** * 设置角色基础数据 * @param ds @@ -253,44 +290,6 @@ export default class Avatar extends Base { } } - get isAvatar () { - return true - } - - // 是否是合法面板数据 - get isProfile () { - return ProfileAvatar.isProfile(this) - } - - // profile.hasData 别名 - get hasData () { - return !!(this.level > 1 || this?.weapon?.name) - } - - get imgs () { - return this.char.getImgs(this.costume) || {} - } - - get costumeSplash () { - return ProfileAvatar.getCostumeSplash(this) - } - - get hasDmg () { - return this.isProfile && !!ProfileDmg.dmgRulePath(this.name, this.game) - } - - get artis () { - return this._artis - } - - static create (ds, game = 'gs') { - let profile = new Avatar(ds, game) - if (!profile) { - return false - } - return profile - } - setAvatarBase (ds, source = '') { this._now = new Date() * 1 this.setBasic(ds, source) @@ -373,4 +372,8 @@ export default class Avatar extends Base { getArtisDetail (mysArtis = false) { return (mysArtis ? this.mysArtis : this.artis).getDetail() } + + getMaterials () { + return MysAvatar.getMaterials(this) + } } diff --git a/models/Player.js b/models/Player.js index ba1c97ba..2520b242 100644 --- a/models/Player.js +++ b/models/Player.js @@ -360,8 +360,10 @@ export default class Player extends Base { * @param cfg.detail mys-detail数据更新级别,角色列表与详情 * @param cfg.talent mys-talent数据更新级别,角色天赋数据 * @param cfg.index mys-index数据更新级别,游戏统计数据 + * @param cfg.materials 是否返回角色的材料,默认false * @param cfg.retType 返回类型,默认id为key对象,设置为array时返回数组 - * @param cfg.rank 返回为数组时,数据是否排序,排序规则:等级、星级、天赋、命座、武器、好感的顺序排序 + * @param cfg.rank 面板数据是否参与群排序 + * @param cfg.sort 返回为数组时,数据是否排序,排序规则:等级、星级、天赋、命座、武器、好感的顺序排序 * @returns {Promise} */ @@ -390,6 +392,9 @@ export default class Player extends Base { rank.getRank(profile) } } + if (cfg.materials) { + ds.materials = avatar.getMaterials() + } }) if (cfg.retType !== 'array') { return avatarRet @@ -402,4 +407,6 @@ export default class Player extends Base { } return avatarRet } + + } diff --git a/models/avatar/MysAvatar.js b/models/avatar/MysAvatar.js index f461b45b..c324d81d 100644 --- a/models/avatar/MysAvatar.js +++ b/models/avatar/MysAvatar.js @@ -317,6 +317,14 @@ const MysAvatar = { stats.avatar5 = avatar5Count ret.stats = stats return ret + }, + + getMaterials (avatar) { + let ret = {} + let { char } = avatar + ret.talent = char.getMaterials('talent') + ret.weekly = char.getMaterials('weekly') + return ret } } export default MysAvatar