diff --git a/apps/character.js b/apps/character.js index 3d8a1a46..f7f58116 100644 --- a/apps/character.js +++ b/apps/character.js @@ -1,12 +1,8 @@ -import { Common, Cfg, App } from '../components/index.js' +import { Common, App } from '../components/index.js' import { Character } from '../models/index.js' import { renderAvatar } from './character/avatar-card.js' -// 角色图像上传 import { uploadCharacterImg } from './character/character-img-upload.js' - -// 老婆 import { wife, wifeReg } from './character/avatar-wife.js' - import { getOriginalPicture } from './character/utils.js' let app = App.init({ diff --git a/apps/character/avatar-card.js b/apps/character/avatar-card.js index f20af542..197f4c2e 100644 --- a/apps/character/avatar-card.js +++ b/apps/character/avatar-card.js @@ -1,4 +1,4 @@ -import { Artifact, Character } from '../../models/index.js' +import { Artifact, Character, Avatars } from '../../models/index.js' import { Cfg, Data, Common, Profile } from '../../components/index.js' import lodash from 'lodash' import { segment } from 'oicq' @@ -59,9 +59,10 @@ async function renderCard (e, avatar, renderType = 'card') { } let uid = e.uid || (e.targetUser && e.targetUser.uid) - let crownNum = 0; + let crownNum = 0 let talent = {} if (!char.isCustom) { + talent = await getTalent(e, avatar) // 计算皇冠个数 crownNum = lodash.filter(lodash.map(talent, (d) => d.original), (d) => d >= 10).length @@ -71,6 +72,7 @@ async function renderCard (e, avatar, renderType = 'card') { e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + bg.img)) } else { // 渲染图像 + // let talent = let msgRes = await Common.render('character/character-card', { save_id: uid, uid, @@ -93,17 +95,14 @@ async function renderCard (e, avatar, renderType = 'card') { // 获取角色技能数据 async function getTalent (e, avatars) { - let talent = {}; - let cons = 0; - let char = Character.get(avatars.id); - let mode = 'level' + let char = Character.get(avatars.id) if (char.isCustom) { return {} } + let uid = e.uid if (avatars.dataSource && avatars.talent) { // profile模式 - talent = avatars.talent || {} - cons = avatars.cons || 0 + return avatars.talent } else { let MysApi = await e.getMysApi({ auth: 'all', @@ -112,28 +111,9 @@ async function getTalent (e, avatars) { actionName: '查询信息' }) if (!MysApi && !MysApi.isSelfCookie) return {} - let skillRes = await MysApi.getAvatar(avatars.id) - cons = avatars.actived_constellation_num - mode = 'original' - if (skillRes && skillRes.skill_list) { - let skillList = lodash.orderBy(skillRes.skill_list, ['id'], ['asc']) - for (let val of skillList) { - if (val.name.includes('普通攻击')) { - talent.a = val - continue - } - if (val.max_level >= 10 && !talent.e) { - talent.e = val - continue - } - if (val.max_level >= 10 && !talent.q) { - talent.q = val - } - } - } + let avatar = new Avatars(uid, [avatars]) + return await avatar.getAvatarTalent(avatars.id, MysApi) } - - return char.getAvatarTalent(talent, cons, mode) } /* @@ -220,4 +200,4 @@ export async function getAvatarList (e, type, MysApi) { let sortKey = 'level,fetter,weapon_level,rarity,weapon_rarity,cons,weapon_affix_level' list = lodash.orderBy(list, sortKey, lodash.repeat('desc,', sortKey.length).split(',')) return list -} \ No newline at end of file +} diff --git a/apps/profile.js b/apps/profile.js index 38d255ba..35d7292c 100644 --- a/apps/profile.js +++ b/apps/profile.js @@ -3,13 +3,8 @@ import { Character } from '../models/index.js' import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js' import { profileArtis, profileArtisList } from './character/profile-artis.js' import { renderProfile } from './character/profile-detail.js' - -// 面板练度统计 import { profileStat } from './character/profile-stat.js' - -// 面板角色列表 import { profileList } from './character/profile-list.js' - import { enemyLv } from './character/utils.js' let app = App.init({ diff --git a/components/common-lib/render.js b/components/common-lib/render.js index 092df0c8..70284de8 100644 --- a/components/common-lib/render.js +++ b/components/common-lib/render.js @@ -28,7 +28,7 @@ export default async function (path, params, cfg) { copyright: `Created By Yunzai-Bot${Version.yunzai} & Miao-Plugin${Version.version}` } } - if (global.debugView === 'web-debug') { + if (process.argv.includes('web-debug')) { // debug下保存当前页面的渲染数据,方便模板编写与调试 // 由于只用于调试,开发者只关注自己当时开发的文件即可,暂不考虑app及plugin的命名冲突 let saveDir = _path + '/data/ViewData/' diff --git a/models/Avatars.js b/models/Avatars.js index 52578fca..92e0d553 100644 --- a/models/Avatars.js +++ b/models/Avatars.js @@ -99,50 +99,35 @@ export default class Avatars extends Base { } async getAvatarTalent (id, MysApi) { - let talent = { id, a: {}, e: {}, q: {} } + let talent = {} let talentRes = await MysApi.getDetail(id) let char = Character.get(id) let avatar = this.avatars[id] if (!char || !avatar) { return talent } - let consTalent = char.talentCons if (talentRes && talentRes.skill_list) { talent.id = id let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc']) for (let val of talentList) { let { max_level: maxLv, level_current: lv } = val - let ds = { - current: lv, - original: lv, - crown: lv === maxLv - } if (val.name.includes('普通攻击')) { - talent.a = ds + talent.a = lv continue } - if (maxLv >= 10 && !talent.e?.current) { - talent.e = ds + if (maxLv >= 10 && !talent.e) { + talent.e = lv continue } - if (maxLv >= 10 && !talent.q?.current) { - talent.q = ds + if (maxLv >= 10 && !talent.q) { + talent.q = lv continue } } - lodash.forEach([3, 5], (c) => { - if (avatar.cons >= c) { - if (consTalent.e === c) { - talent.e.current += 3 - talent.e.plus = true - } else if (consTalent.q === c) { - talent.q.current += 3 - talent.q.plus = true - } - } - }) } - return talent + let ret = char.getAvatarTalent(talent, avatar.cons, 'original') + ret.id = id + return ret } } diff --git a/resources/character/profile-stat.html b/resources/character/profile-stat.html index 39cce0ca..f88c2515 100644 --- a/resources/character/profile-stat.html +++ b/resources/character/profile-stat.html @@ -47,9 +47,9 @@ {{each tk talentKey}} - {{set curr = (avatar.talent||{})[talentKey] || {original:1,current:'-'} }} -