diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df0efd9..59b565c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.10.1 + +* `#刻晴面板`、`#芭芭拉圣遗物`支持展示角色时装 + * 如果角色装备了时装,面板的角色图会展示时装立绘 + * 需要重新`#更新面板`以获取时装数据 + # 1.10.0 * 新增`#面板练度统计`功能 diff --git a/apps/character/profile-artis.js b/apps/character/profile-artis.js index 4031fe01..1f22641c 100644 --- a/apps/character/profile-artis.js +++ b/apps/character/profile-artis.js @@ -36,6 +36,7 @@ export async function profileArtis (e) { uid, elem: char.elem, data: profile, + costume: profile.costume ? '2' : '', artis, totalMark, totalMarkClass, diff --git a/apps/character/profile-detail.js b/apps/character/profile-detail.js index 6cac5740..304a1d17 100644 --- a/apps/character/profile-detail.js +++ b/apps/character/profile-detail.js @@ -13,6 +13,7 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) { e.reply('暂不支持主角的面板信息查看') return true } + if (char.isCustom) { e.reply(`暂不支持自定义角色${char.name}的面板信息查看`) return true @@ -93,11 +94,13 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) { basic.dmg = Format.comma(basic.dmg) basic.avg = Format.comma(basic.avg) } + const costume = profile.costume ? '2' : '' // 渲染图像 return await Common.render('character/profile-detail', { save_id: uid, uid, data: profile.getData('cons,level,weapon,dataSource,updateTime'), + costume, attr, cons: char.cons, name: char.name, @@ -114,7 +117,7 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) { totalMarkClass, usefulMark, talentMap: { a: '普攻', e: '战技', q: '爆发' }, - bodyClass: `char-${char.name}`, + bodyClass: `char-${char.name}${costume}`, mode }, { e, scale: 1.6 }) } diff --git a/apps/character/profile-list.js b/apps/character/profile-list.js index 00148884..9ba7ef4b 100644 --- a/apps/character/profile-list.js +++ b/apps/character/profile-list.js @@ -29,6 +29,7 @@ export async function profileList (e) { tmp.source = profile.dataSource tmp.level = profile.level || 1 tmp.isNew = 0 + tmp.costume = profile.costume ? '2' : '' if (newChar[char.name]) { tmp.isNew = 1 newCount++ diff --git a/components/Common.js b/components/Common.js index 8e1bab63..84774f08 100644 --- a/components/Common.js +++ b/components/Common.js @@ -1,6 +1,7 @@ import Cfg from './Cfg.js' import { Data, Version } from './index.js' import { puppeteer } from '../adapter/index.js' +import fs from 'fs' const plugin = 'miao-plugin' const _path = process.cwd() @@ -27,6 +28,17 @@ export const render = async function (path, params, cfg) { copyright: `Created By Yunzai-Bot${Version.yunzai} & Miao-Plugin${Version.version}` } } + if (global.debugView === 'web-debug') { + // debug下保存当前页面的渲染数据,方便模板编写与调试 + // 由于只用于调试,开发者只关注自己当时开发的文件即可,暂不考虑app及plugin的命名冲突 + let saveDir = _path + '/data/ViewData/' + if (!fs.existsSync(saveDir)) { + fs.mkdirSync(saveDir) + } + let file = saveDir + tpl + '.json' + data._app = app + fs.writeFileSync(file, JSON.stringify(data)) + } let base64 = await puppeteer.screenshot(`miao-plugin/${app}/${tpl}`, data) let ret = true if (base64) { diff --git a/components/profile-data/enka-data.js b/components/profile-data/enka-data.js index 992a8f81..30fae6ca 100644 --- a/components/profile-data/enka-data.js +++ b/components/profile-data/enka-data.js @@ -41,6 +41,7 @@ let EnkaData = { level: data.propMap['4001'].val * 1, cons: data.talentIdList ? data.talentIdList.length : 0, fetter: data.fetterInfo.expLevel, + costume: char.checkCostume(data.costumeId) ? data.costumeId : 0, dataSource: 'enka' }) profile.setAttr(EnkaData.getAttr(data.fightPropMap)) diff --git a/components/profile-data/miao-data.js b/components/profile-data/miao-data.js index c562cf6d..d7e04cef 100644 --- a/components/profile-data/miao-data.js +++ b/components/profile-data/miao-data.js @@ -35,6 +35,7 @@ let MiaoData = { level: ds.level, cons: ds.constellationNum || 0, fetter: ds.fetterLevel, + costume: char.checkCostume(ds.costumeID) ? ds.costumeID : 0, dataSource: 'miao' }) profile.setAttr(MiaoData.getAttr(ds.combatValue)) diff --git a/models/Character.js b/models/Character.js index 565bbd54..8f409ada 100644 --- a/models/Character.js +++ b/models/Character.js @@ -11,7 +11,7 @@ let wifeMap = {} const _path = process.cwd() const metaPath = `${_path}/plugins/miao-plugin/resources/meta/character/` -async function init() { +async function init () { let { sysCfg, diyCfg } = await Data.importCfg('character') lodash.forEach([diyCfg.customCharacters, sysCfg.characters], (roleIds) => { lodash.forEach(roleIds || {}, (aliases, id) => { @@ -49,7 +49,7 @@ async function init() { await init() class Character extends Base { - constructor(name, id) { + constructor (name, id) { super() if (id * 1 === 10000005) { @@ -65,7 +65,7 @@ class Character extends Base { this.id = id } - get weaponType() { + get weaponType () { const map = { sword: '单手剑', catalyst: '法器', @@ -77,15 +77,15 @@ class Character extends Base { return map[weaponType.toLowerCase()] || '' } - get isCustom() { + get isCustom () { return !/10\d{6}/.test(this.id) } - get abbr() { + get abbr () { return abbrMap[this.name] || this.name } - getCardImg(se = false, def = true) { + getCardImg (se = false, def = true) { let name = this.name let list = [] let addImg = function (charImgPath, disable = false) { @@ -130,7 +130,7 @@ class Character extends Base { return ret } - checkAvatars(avatars) { + checkAvatars (avatars) { if (!lodash.includes([20000000, 10000005, 10000007], this.id * 1)) { return } @@ -150,7 +150,7 @@ class Character extends Base { } } - getAvatarTalent(talent = {}, cons = 0, mode = 'level') { + getAvatarTalent (talent = {}, cons = 0, mode = 'level') { let ret = {} let consTalent = this.getConsTalent() lodash.forEach(['a', 'e', 'q'], (key) => { @@ -177,7 +177,6 @@ class Character extends Base { level: (key !== 'a' && cons >= consTalent[key]) ? (level + 3) : level } } - }) if (this.id * 1 !== 10000033) { let a = ret.a || {} @@ -193,7 +192,7 @@ class Character extends Base { return ret } - getConsTalent() { + getConsTalent () { let talent = this.talent || false if (!talent) { return { e: 3, q: 5 } @@ -208,9 +207,20 @@ class Character extends Base { } } - checkWifeType(type) { + checkWifeType (type) { return !!wifeMap[type][this.id] } + + checkCostume (id) { + return [ + 200301, // 琴 + 201401, // 芭芭拉 + 204201, // 刻晴 + 202701, // 凝光 + 201601, // 迪卢克 + 203101 // 菲谢尔 + ].includes(id * 1) + } } let getMeta = function (name) { diff --git a/models/ProfileData.js b/models/ProfileData.js index b38a4f28..8c5c03a9 100644 --- a/models/ProfileData.js +++ b/models/ProfileData.js @@ -26,6 +26,7 @@ export default class ProfileData extends Base { this.level = ds.lv || ds.level || 1 this.cons = ds.cons || 0 this.fetter = ds.fetter || 0 + this.costume = ds.costume || 0 this.dataSource = ds.dataSource || 'enka' this._time = ds._time || ds.updateTime || new Date() * 1 } @@ -91,7 +92,7 @@ export default class ProfileData extends Base { // toJSON 供保存使用 toJSON () { - return this.getData('id,name,level,cons,fetter,attr,weapon,talent,artis,dataSource,_time') + return this.getData('id,name,level,cons,fetter,attr,weapon,talent,artis,dataSource,costume,_time') } get updateTime () { diff --git a/resources/character/artis-mark.html b/resources/character/artis-mark.html index ac71f67d..07293ef2 100644 --- a/resources/character/artis-mark.html +++ b/resources/character/artis-mark.html @@ -13,7 +13,7 @@ {{block 'main'}}