#角色详情圣遗物部分样式更新

This commit is contained in:
yoimiya-kokomi 2022-04-15 22:33:51 +08:00
parent 4c04738ebe
commit c921d57a81
2 changed files with 69 additions and 1 deletions

View File

@ -503,6 +503,30 @@ function getCharacterData(avatars) {
};
}
async function getAvatar(e, char, MysApi) {
let charData = await MysApi.getCharacter();
if (!charData) return true;
let avatars = charData.avatars;
let length = avatars.length;
char.checkAvatars(avatars);
avatars = lodash.keyBy(avatars, "id");
if (!avatars[char.id]) {
let name = lodash.truncate(e.sender.card, { length: 8 });
if (length > 8) {
e.reply([segment.at(e.user_id, name), `\n没有${e.msg}`]);
} else {
e.reply([segment.at(e.user_id, name), "\n请先在米游社展示该角色"]);
}
return false;
}
return avatars[char.id];
}
export async function renderProfile(e, char, render) {
let MysApi = await e.getMysApi({
auth: "cookie",
@ -536,18 +560,37 @@ export async function renderProfile(e, char, render) {
dmgBonus: p(a.dmgBonus)
};
let avatar = await getAvatar(e, char, MysApi);
let talent = await getTalent(e, avatar);
let reliquaries = [];
lodash.forEach(avatar.reliquaries, (ds, idx)=>{
let arti = profile.artis[`arti${idx+1}`];
if(arti){
ds.main = Profile.formatArti(arti.main);
ds.attrs = Profile.formatArti(arti.attrs);
}
reliquaries.push(ds);
})
let base64 = await render("character", "detail", {
save_id: uid,
uid: uid,
data: profile,
meta: char,
// meta: char,
attr,
avatar,
talent,
cons: char.cons,
name: char.name,
elem: char.elem,
reliquaries,
talentMap: { a: "普攻", e: "战技", q: "爆发" },
cfgScale: Cfg.scale(1.25)
}, "png");
if (base64) {
e.reply(segment.image(`base64://${base64}`));
}
return true;
}

View File

@ -1,6 +1,7 @@
import fs from "fs";
import fetch from "node-fetch";
import lodash from "lodash";
import Format from "./Format.js";
const _path = process.cwd();
const cfgPath = `${_path}/plugins/miao-plugin/components/setting.json`;
@ -247,6 +248,30 @@ let Profile = {
return userData.chars[charId];
}
return false;
},
formatArti(ds) {
if (lodash.isArray(ds[0])) {
let ret = [];
lodash.forEach(ds, (d) => {
ret.push(Profile.formatArti(d));
})
return ret;
}
let title = ds[0], val = ds[1];
if (/伤害加成/.test(title) && val<1) {
val = Format.pct(val*100);
}else if (/伤害加成|大|暴|爆|充能|治疗/.test(title)) {
val = Format.pct(val);
} else {
val = Format.comma(val,1);
}
if (title == "爆伤") {
title = "暴击伤害";
}
if (/元素伤害加成/.test(title)) {
title = title.replace("元素伤害", "伤");
}
return [title, val];
}
};
export default Profile;