mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-24 17:19:25 +00:00
1. 将#老婆命令使用新版卡片进行渲染
2. 增加卡片的命座展示
This commit is contained in:
parent
cce76ea8f2
commit
83479c3589
@ -14,7 +14,6 @@ await init();
|
||||
|
||||
export async function init(isUpdate = false) {
|
||||
let _path = "file://" + process.cwd();
|
||||
console.log(_path + "config/gen");
|
||||
let version = isUpdate ? new Date().getTime() : 0;
|
||||
|
||||
genshin = await import(_path + `/config/genshin/roleId.js?version=${version}`);
|
||||
@ -23,19 +22,14 @@ export async function init(isUpdate = false) {
|
||||
|
||||
// 查看当前角色
|
||||
export async function character(e, { render, MysApi, User }) {
|
||||
|
||||
if (!e.msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let name = e.msg.replace(/#?|老婆|老公|[1|2|5][0-9]{8}/g, "").trim();
|
||||
let char = Character.get(name);
|
||||
if (!char) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
let check = await User.checkAuth(e, "bind", {
|
||||
action: "查询角色详情"
|
||||
});
|
||||
@ -96,7 +90,7 @@ export async function character(e, { render, MysApi, User }) {
|
||||
avatars = avatars[roleId];
|
||||
|
||||
|
||||
let talent = await getTalent(e, uid, avatars);
|
||||
let talent = await getTalent(e, uid, avatars, MysApi);
|
||||
let crownNum = lodash.filter(lodash.map(talent, (d) => d.level_original), (d) => d >= 10).length
|
||||
let base64 = await render("miao-plugin", "character", {
|
||||
_plugin: true,
|
||||
@ -117,19 +111,141 @@ export async function character(e, { render, MysApi, User }) {
|
||||
return true; //事件结束不再往下
|
||||
}
|
||||
|
||||
|
||||
//#老婆
|
||||
export async function wife(e, { render, MysApi, User }) {
|
||||
let msg = e.msg;
|
||||
if (!msg) {
|
||||
return;
|
||||
}
|
||||
let check = await User.checkAuth(e, "bind", {
|
||||
action: "查询角色详情"
|
||||
});
|
||||
if (!check) {
|
||||
return true;
|
||||
}
|
||||
|
||||
msg = msg.replace(/#|\w/g, "");
|
||||
|
||||
let i = 0;
|
||||
if (["老婆", "媳妇", "妻子", "娘子", "女朋友", "女友", "女神"].includes(msg)) {
|
||||
i = 0;
|
||||
} else if (["老公", "丈夫", "夫君", "郎君", "男朋友", "男友", "男神"].includes(msg)) {
|
||||
i = 1;
|
||||
} else if (["女儿"].includes(msg)) {
|
||||
i = 2;
|
||||
} else if (["儿子"].includes(msg)) {
|
||||
e.reply("暂无正太角色");
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
let { selfUser, targetUser } = e;
|
||||
if (!targetUser.uid) {
|
||||
e.reply("暂未查询到角色信息");
|
||||
return true;
|
||||
}
|
||||
|
||||
let uid = targetUser.uid;
|
||||
|
||||
let res = await MysApi.requestData(e, uid, "character");
|
||||
|
||||
if (res.retcode == "-1") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkRetcode(res, uid, e)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let avatars = res.data.avatars;
|
||||
|
||||
if (avatars.length <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let list = [];
|
||||
|
||||
for (let val of avatars) {
|
||||
if (!genshin.wifeData[i].includes(Number(val.id))) {
|
||||
continue;
|
||||
}
|
||||
if (val.rarity > 5) {
|
||||
val.rarity = 5;
|
||||
}
|
||||
|
||||
//等级+好感*10+命座*5+五星*20
|
||||
val.sort = val.level + val.fetter * 10 + val.actived_constellation_num * 5 * (val.rarity - 3) + (val.rarity - 4) * 20;
|
||||
|
||||
//超过80级的每级*5
|
||||
if (val.level > 80) {
|
||||
val.sort += (val.level - 80) * 5;
|
||||
}
|
||||
|
||||
//武器 等级+五星*25+精炼*5
|
||||
val.sort += val.weapon.level + (val.weapon.rarity - 4) * 25 + val.weapon.affix_level * 5;
|
||||
|
||||
//武器超过80级的每级*5
|
||||
if (val.weapon.level > 80) {
|
||||
val.sort += (val.weapon.level - 80) * 5;
|
||||
}
|
||||
|
||||
//圣遗物等级
|
||||
for (let rel of val.reliquaries) {
|
||||
val.sort += rel.level * 1.2;
|
||||
}
|
||||
|
||||
list.push(val);
|
||||
}
|
||||
|
||||
if (list.length <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//limitSet(e);
|
||||
|
||||
list = lodash.orderBy(list, ["sort"], ["desc"]);
|
||||
|
||||
avatars = lodash.sample(list.slice(0, 5));
|
||||
|
||||
let talent = await getTalent(e, uid, avatars, MysApi);
|
||||
|
||||
let char = Character.get(avatars.name);
|
||||
|
||||
let crownNum = lodash.filter(lodash.map(talent, (d) => d.level_original), (d) => d >= 10).length
|
||||
|
||||
let base64 = await render("miao-plugin", "character", {
|
||||
_plugin: true,
|
||||
save_id: uid,
|
||||
uid: uid,
|
||||
talent,
|
||||
crownNum,
|
||||
talentMap: { a: "普攻", e: "战技", q: "爆发" },
|
||||
bg: getCharacterImg(char.name),
|
||||
...getCharacterData(avatars),
|
||||
ds: char.getData("name,id,title,desc"),
|
||||
}, "png");
|
||||
|
||||
if (base64) {
|
||||
e.reply(segment.image(`base64://${base64}`));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 设置角色图像
|
||||
export async function setCharacterImg(e, render) {
|
||||
|
||||
}
|
||||
|
||||
//获取角色技能数据
|
||||
async function getTalent(e, uid, avatars) {
|
||||
async function getTalent(e, uid, avatars, MysApi) {
|
||||
|
||||
let skill = {};
|
||||
if (NoteCookie && NoteCookie[e.user_id] && NoteCookie[e.user_id].uid == uid && NoteCookie[e.user_id].cookie.includes("cookie_token")) {
|
||||
let skillres = await mysApi(e, uid, "detail", {
|
||||
role_id: uid,
|
||||
server: getServer(uid),
|
||||
|
||||
let skillres = await MysApi.requestData(e, uid, "detail", {
|
||||
avatar_id: avatars.id,
|
||||
});
|
||||
if (skillres.retcode == 0 && skillres.data && skillres.data.skill_list) {
|
||||
@ -164,7 +280,7 @@ async function getTalent(e, uid, avatars) {
|
||||
skill.q.level_current += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return skill;
|
||||
@ -530,10 +646,20 @@ function getDayEnd() {
|
||||
}
|
||||
|
||||
function getCharacterImg(name) {
|
||||
|
||||
if (!fs.existsSync(`./plugins/miao-plugin/resources/characterImg/${name}/`)) {
|
||||
fs.mkdirSync(`./plugins/miao-plugin/resources/characterImg/${name}/`);
|
||||
}
|
||||
|
||||
|
||||
let imgs = fs.readdirSync(`./plugins/miao-plugin/resources/characterImg/${name}/`);
|
||||
imgs = imgs.filter((img) => /\.(png|jpg|webp)/.test(img));
|
||||
let img = lodash.sample(imgs);
|
||||
|
||||
if (!img) {
|
||||
name = "刻晴";
|
||||
img = "01.jpg";
|
||||
}
|
||||
let ret = sizeOf(`./plugins/miao-plugin/resources/characterImg/${name}/${img}`);
|
||||
ret.img = `/characterImg/${name}/${img}`;
|
||||
ret.mode = ret.width > ret.height ? "left" : "bottom";
|
||||
|
@ -1,3 +0,0 @@
|
||||
export default{
|
||||
|
||||
}
|
9
index.js
9
index.js
@ -5,6 +5,11 @@ export const rule = {
|
||||
priority: 208,
|
||||
describe: "【#刻晴】角色详情",
|
||||
},
|
||||
wife: {
|
||||
reg: "^#(老婆|妻子|媳妇|娘子|女朋友|女友|女神|老公|丈夫|夫君|郎君|男朋友|男友|男神|女儿|儿子)(1|2)*$",
|
||||
priority: 206,
|
||||
describe: "【#老婆,#老公,#女儿】角色详情",
|
||||
},
|
||||
setCharacterImg: {
|
||||
prehash: true,
|
||||
reg: "^#(添加|更新)(.*)图片(#.*)?(上|右|下|左)?$",
|
||||
@ -23,7 +28,7 @@ export const rule = {
|
||||
|
||||
};
|
||||
|
||||
import { character, setCharacterImg } from "./apps/character.js";
|
||||
import { character, setCharacterImg, wife } from "./apps/character.js";
|
||||
import { userStat, rebuildCookie } from "./apps/admin.js";
|
||||
|
||||
export { character, setCharacterImg, userStat, rebuildCookie };
|
||||
export { character, setCharacterImg, userStat, rebuildCookie, wife };
|
||||
|
@ -80,6 +80,7 @@ body {
|
||||
position: absolute;
|
||||
top: -60px;
|
||||
left: 20px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.char_name:after {
|
||||
@ -106,6 +107,49 @@ body {
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.char_name .cons {
|
||||
display: inline-block;
|
||||
width: 55px;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
border-radius: 10px;
|
||||
font-size: 20px;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
letter-spacing: 0px;
|
||||
font-family: tttgbnumber;
|
||||
box-shadow: 0px 0px 3px 0px #000;
|
||||
text-shadow: 0 0 3px #000;
|
||||
}
|
||||
|
||||
.cons_0 {
|
||||
background: #666;
|
||||
}
|
||||
|
||||
.cons_1 {
|
||||
background-color: #62a8ea;
|
||||
}
|
||||
|
||||
.cons_2 {
|
||||
background-color: #62a8ea;
|
||||
}
|
||||
|
||||
.cons_3 {
|
||||
background-color: #45b97c;
|
||||
}
|
||||
|
||||
.cons_4 {
|
||||
background-color: #45b97c;
|
||||
}
|
||||
|
||||
.cons_5 {
|
||||
background-color: #ff5722;
|
||||
}
|
||||
|
||||
.cons_6 {
|
||||
background-color: #ff5722;
|
||||
}
|
||||
|
||||
.crown {
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
@ -351,6 +395,16 @@ body.bottom_mode {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.bottom_mode .cons {
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: -30px;
|
||||
}
|
||||
|
||||
.bottom_mode .uid {
|
||||
left: 70px;
|
||||
}
|
||||
|
||||
.bottom_mode .info {
|
||||
padding-left: 150px;
|
||||
}
|
||||
|
@ -10,7 +10,8 @@
|
||||
<div class="info">
|
||||
<div class="char_name">
|
||||
<div class="uid">ID:{{uid}}</div>
|
||||
<span>{{ds.name}}</span>
|
||||
<span>{{ds.name}} <span
|
||||
class="cons cons_{{actived_constellation_num}}">{{actived_constellation_num}}命</span></span>
|
||||
</div>
|
||||
<div class="detail"> Lv.{{level}} ❤{{fetter}}
|
||||
<span class="crown crown_{{crownNum}}"></span>
|
||||
@ -35,11 +36,15 @@
|
||||
<div class="talent_{{key}}"> {{name}}:<span>{{ talent[key].level_current}}</span></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="talent">
|
||||
<div class="talent_{{key}}">暂无天赋信息</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="equiv_info">
|
||||
<div class="text">{{text1}}</div>
|
||||
<div class="text">{{text2}}</div>
|
||||
<div class="text">{{text1|| "-"}}</div>
|
||||
<div class="text">{{text2 || "-"}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user