diff --git a/apps/character.js b/apps/character.js index d9692626..467b54b6 100644 --- a/apps/character.js +++ b/apps/character.js @@ -1,19 +1,17 @@ import fetch from "node-fetch"; import { segment } from "oicq"; import lodash from "lodash"; +import { Character } from "../components/models.js" import fs from "fs"; +import sizeOf from "image-size"; let getUrl, getServer; -import { Character } from "../components/models.js"; - - //角色昵称 let nameID = ""; let genshin = {}; await init(); - export async function init(isUpdate = false) { let _path = "file://" + process.cwd(); console.log(_path + "config/gen"); @@ -23,26 +21,19 @@ export async function init(isUpdate = false) { nameID = ""; } - -//#神里 +// 查看当前角色 export async function character(e, { render, MysApi }) { - let roleId = roleIdToName(e.msg.replace(/#|老婆|老公|[1|2|5][0-9]{8}/g, "").trim()); - - - let hutao = Character.get("胡桃"); - - console.log(hutao.a) - - return true; - - if (!roleId) return false; + let name = e.msg.replace(/#|老婆|老公|[1|2|5][0-9]{8}/g, "").trim(); + let char = Character.get(name); + if (!char) { + return false; + } + let roleId = char.id; getUrl = MysApi.getUrl; getServer = MysApi.getServer; let uidRes = await getUid(e); - - if (!uidRes.uid && uidRes.isSelf) { e.reply("请先发送#+你游戏的uid"); return true; @@ -93,16 +84,20 @@ export async function character(e, { render, MysApi }) { avatars = avatars[roleId]; - let skill = await getSkill(e, uid, avatars); - let type = "character"; - - let base64 = await render("miao-plugin", type, { + let talent = await getTalent(e, uid, avatars); + 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, - skill, - ...get_character(avatars), + talent, + crownNum, + talentMap: { a: "普攻", e: "战技", q: "爆发" }, + bg: getCharacterImg(char.name), + ...getCharacterData(avatars), + ds: char.getData("name,id,title,desc"), + }, "png"); if (base64) { @@ -112,9 +107,13 @@ export async function character(e, { render, MysApi }) { return true; //事件结束不再往下 } +// 设置角色图像 +export async function setCharacterImg(e, render) { + +} //获取角色技能数据 -async function getSkill(e, uid, avatars) { +async function getTalent(e, uid, avatars) { let skill = {}; if (NoteCookie && NoteCookie[e.user_id] && NoteCookie[e.user_id].uid == uid && NoteCookie[e.user_id].cookie.includes("cookie_token")) { @@ -161,14 +160,12 @@ async function getSkill(e, uid, avatars) { return skill; } - -function get_character(avatars) { +function getCharacterData(avatars) { let list = []; let set = {}; let setArr = []; let text1 = ""; let text2 = ""; - let bg = 2; let weapon = { type: "weapon", @@ -232,7 +229,6 @@ function get_character(avatars) { weapon, text1, text2, - bg, reliquaries, set: setArr, }; @@ -523,3 +519,13 @@ function getDayEnd() { return dayEnd - parseInt(now.getTime() / 1000); } +function getCharacterImg(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); + + let ret = sizeOf(`./plugins/miao-plugin/resources/characterImg/${name}/${img}`); + ret.img = `/characterImg/${name}/${img}`; + ret.mode = ret.width > ret.height ? "left" : "bottom"; + return ret; +} diff --git a/components/Data.js b/components/Data.js index 2c5fde31..504d1b5f 100644 --- a/components/Data.js +++ b/components/Data.js @@ -7,7 +7,6 @@ let Data = { * 根据指定的path依次检查与创建目录 * */ createDir(rootPath = "", path, includeFile = false) { - console.log(rootPath, path) let pathList = path.split("/"), nowPath = rootPath; pathList.forEach((name, idx) => { @@ -16,7 +15,6 @@ let Data = { nowPath += name + "/"; if (name) { if (!fs.existsSync(nowPath)) { - console.log(nowPath) fs.mkdirSync(nowPath); } } @@ -79,7 +77,6 @@ let Data = { keyRet = keyTo; if (cfg.lowerFirstKey) { keyRet = lodash.lowerFirst(keyRet); - console.log('keyRet', keyRet) } if (cfg.keyPrefix) { keyRet = cfg.keyPrefix + keyRet; diff --git a/components/index.js b/components/index.js index 2e675a64..2f13c943 100644 --- a/components/index.js +++ b/components/index.js @@ -1 +1,3 @@ -export Data from "./Data.js"; \ No newline at end of file +import Data from "./Data.js"; + +export { Data } \ No newline at end of file diff --git a/components/models.js b/components/models.js index d0d6e9be..f720f741 100644 --- a/components/models.js +++ b/components/models.js @@ -1,5 +1,3 @@ - import Character from "./models/Character.js"; -export {Character}; - +export { Character }; diff --git a/components/models/Character.js b/components/models/Character.js index 10d6ae42..0dfbff8d 100644 --- a/components/models/Character.js +++ b/components/models/Character.js @@ -32,14 +32,6 @@ class Character extends Base { lodash.extend(this, getMetaData(name)) } - get id() { - for (let id in roleId) { - if (roleId[id] && role[id][0] === this.name) { - return id; - } - } - } - async checkImgCache(resDir) { // 处理img信息 let chcheDir = resDir + "/cache/"; @@ -101,7 +93,6 @@ let getMetaData = function (name) { cons[key.replace("Constellation")] = Data.getData(data, "Name,icon:Source,desc:Description", metaCfg); }) ret.cons = cons; - return ret; } diff --git a/config.js b/config.js index 7b46be8d..57bccc49 100644 --- a/config.js +++ b/config.js @@ -1,3 +1,5 @@ -export default{ - +export default { + apps: { + character: true, // 查询角色 + } } \ No newline at end of file diff --git a/index.js b/index.js index f03b276f..36e03e48 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,16 @@ - - export const rule = { character: { - reg: "^#(.*)$", + reg: "^#(.*)(#.*)?$", priority: 208, describe: "【#刻晴】角色详情", - } + }, + setCharacterImg: { + reg: "^#(添加|更新)(.*)图片(#.*)?(上|右|下|左)?$", + priority: 208, + }, + }; +import { character, setCharacterImg } from "./apps/character.js"; -export { character } from "./apps/character.js"; - +export { character, setCharacterImg }; diff --git a/resources/character/character.css b/resources/character/character.css index 6f96c923..a5005712 100644 --- a/resources/character/character.css +++ b/resources/character/character.css @@ -1,13 +1,13 @@ @font-face { font-family: "HWZhongSong"; - src: url("../../font/华文中宋.TTF"); + src: url("../font/华文中宋.TTF"); font-weight: normal; font-style: normal; } @font-face { font-family: "tttgbnumber"; - src: url("../../font/tttgbnumber.ttf"); + src: url("../font/tttgbnumber.ttf"); font-weight: normal; font-style: normal; } @@ -26,14 +26,10 @@ user-select: none; } -html, body { - width: 500px; -} body { font-size: 16px; color: #fff; - font-family: "tttgbnumber"; transform: scale(1.40); transform-origin: 0 0; } @@ -47,6 +43,7 @@ body { .container img.bg { width: 100%; margin-bottom: -1px; + display: block; } .info { @@ -56,7 +53,10 @@ body { left: 0px; right: 0px; box-shadow: 0 -5px 10px 0 #000; - padding:35px 10px 10px 35px; + padding: 35px 10px 10px 35px; + text-shadow: 0 0 1px #000, 1px 1px 3px #000; + font-family: tttgbnumber; + } .role_box { @@ -69,20 +69,20 @@ body { font-size: 36px; } -.role_name { +.char_name { font-family: "NZBZ"; font-size: 80px; letter-spacing: 5px; line-height: 90px; height: 100px; - text-shadow: 0 0 1px #000, 3px 3px 6px #000; + text-shadow: 0 0 3px #000, 3px 3px 5px #000; display: inline-block; - position:absolute; - top:-70px; - left:20px; + position: absolute; + top: -60px; + left: 20px; } -.role_name:after { +.char_name:after { content: ""; display: block; position: absolute; @@ -96,39 +96,71 @@ body { transition: width 0.3s 0.1s, opacity 0.3s 0.1s; } - -.weapon { - text-align: center; - font-size: 20px; - padding: 3px; - background: rgba(0, 0, 0, 0.6); - border-radius: 5px; - height: 100px; - width: 100px; +.char_name .uid { + font-size: 24px; position: absolute; - overflow: hidden; - right:15px; - top:45px; + height: 25px; + line-height: 25px; + top: -25px; + left: 15px; + letter-spacing: 0; } -.lv { - font-family: "tttgbnumber"; +.crown { + width: 35px; + height: 35px; + margin-top: -3px; + margin-left: 15px; + display: inline-block; + background-size: contain; + vertical-align: bottom; + background-image: url("./imgs/crown.png"); +} + +.crown.crown_0 { + background-image: none; +} + +.crown.crown_1 { + +} + +.crown.crown_2 { + width: 70px; +} + +.crown.crown_3 { + width: 105px; +} + +.detail { + font-size: 26px; margin: 10px 5px 2px 5px; } -.weapon .num { +.weapon { + text-align: center; + font-size: 20px; + width: 100px; + position: absolute; + background: rgba(0, 0, 0, 0.2); +} + + +.weapon_lv { position: absolute; bottom: 0px; - font-size: 12px; + right: 0; + font-size: 18px; border-radius: 5px; padding: 1px 5px; background-color: rgba(0, 0, 0, var(--bg-opacity)); --bg-opacity: 0.75; } -.weapon_num { +.weapon_affix { position: absolute; top: 0; right: 0; @@ -142,9 +174,19 @@ body { padding: 1px 3px; } -.weapon img { +.weapon_cont { + position: relative; +} + +.weapon_cont img { width: 100%; - transform: scale(1.2, 1.2); + height: 100%; +} + +.weapon_name { + height: 30px; + line-height: 30px; + font-size: 15px; } .equiv .img_box { @@ -170,12 +212,13 @@ body { position: relative; } -.skill { +.talent { margin-left: 5px; width: 300px; - padding-bottom: 6px; + padding: 5px 5px 8px; display: flex; position: relative; + font-size: 20px; } .text_box::before { @@ -219,7 +262,7 @@ body { } .detail p, -.skill p { +.talent div { margin-right: 4px; line-height: 16px; width: 90px; @@ -256,7 +299,7 @@ body { height: 52px; width: 52px; position: relative; - display:flex; + display: flex; } .equiv .num { @@ -292,6 +335,7 @@ body { border-radius: 10px; background: linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), rgba(114, 102, 104, 0.3); margin-left: 5px; + margin-top: 5px; } .equiv_info .text { @@ -302,3 +346,154 @@ body { -webkit-box-orient: vertical; -webkit-line-clamp: 2; } + +body.bottom_mode { + width: 500px; +} + +.bottom_mode .info { + padding-left: 150px; +} + +.bottom_mode .weapon { + left: 0; + bottom: 0; + top: 40px; + padding-top: 120px; + width: 140px; +} + +.bottom_mode .weapon_affix { + display: none; +} + +.bottom_mode .weapon_cont { + position: absolute; + top: 0; + width: 100%; +} + +.bottom_mode .weapon_lv { + border-radius: 8px 0 0 0; + padding-left: 8px; + background: rgba(0, 0, 0, .5); + bottom: 2px; + font-size: 15px; +} + +.bottom_mode .weapon_cont img { + width: 110px; + height: 110px; +} + +.bottom_mode .weapon_name { + background: rgba(0, 0, 0, .5); + height: 35px; + line-height: 35px; + position: absolute; + bottom: 0; + left: 0; + right: 0; + +} + +.equiv_info { + width: calc(100% - 20px); +} + +.bottom_mode .detail { + font-family: NZBZ; +} + +.bottom_mode .for_left { + display: none; +} + + +/******** left mode **********/ +.left_mode { + width: 800px; + transform: scale(1); + +} + +.left_mode .info { + bottom: 0; + right: initial; + padding: 10px 10px 5px 10px; + border-radius: 0 20px 0 0; +} + +.left_mode .char_name { + position: fixed; + top: 10px; + font-size: 60px; + padding-left: 20px; + left: 0; + height: 85px; + text-shadow: 0 0 3px #000, 3px 3px 5px #000; +} + +.left_mode .char_name:after { + box-shadow: 0 0 2px 0 #000; +} + +.left_mode .char_name:after { + bottom: 1px; +} + +.left_mode .char_name .uid { + top: 90px; +} + +.left_mode .weapon { + top: -170px; + width: 110px; + padding: 0 0 3px 0; + left: 0; + border-radius: 0 10px 10px 0; + background: rgba(0, 0, 0, 0.8); +} + +.left_mode .weapon_cont { + padding: 3px 10px 0 0; + border-radius: 0 10px 0 0; + border-bottom: 0.5px solid rgba(0, 0, 0, 0.3); +} + +.left_mode .for_bottom, +.left_mode .weapon_lv, +.left_mode .weapon_affix { + display: none; +} + +.left_mode .for_left { + display: block; +} + +.left_mode .weapon_name { + height: 50px; + padding: 5px 0 0; + line-height: 20px; +} + +.left_mode .detail { + width: auto; + margin-top: -5px; +} + +.left_mode .talent { + padding-left: 0; + margin-right: -5px; +} + +.left_mode .info, +.left_mode .weapon { + background: rgba(0, 0, 0, 0.5); + box-shadow: 0 0 5px 1px #000; +} + +.left_mode .equiv_info { + padding: 0; + background: none; +} diff --git a/resources/character/character.html b/resources/character/character.html index 4830cb33..940b1170 100644 --- a/resources/character/character.html +++ b/resources/character/character.html @@ -3,52 +3,47 @@ - - - - - - + - +
-
- {{"神里凌华"}} +
+
ID:{{uid}}
+ {{ds.name}} +
+
Lv.{{level}} ❤{{fetter}} +
-
ID:{{uid}} Lv.{{level}} ❤{{fetter}}
-
- +
+ +

Lv.{{weapon.level}}

+

{{weapon.affix_level}}

-

lv{{weapon.level}}

-

{{weapon.affix_level}}

+

+ Lv.{{weapon.level}} 精{{weapon.affix_level}} + 精{{weapon.affix_level}} + {{weapon.name}} +

- {{ if skill.a }} -
-

爆发:{{ skill.q.level_current}}

-

战技:{{ skill.e.level_current}}

-

普攻:{{ skill.a.level_current}}

+ {{ if talent.a }} +
+ {{each talentMap name key}} +
{{name}}:{{ talent[key].level_current}}
+ {{/each}}
{{/if}} -
-
-
- -
-

+{{reliquaries.level}}

-
-
{{text1}}
{{text2}}
-
+
diff --git a/resources/character/imgs/crown.png b/resources/character/imgs/crown.png new file mode 100644 index 00000000..14cbafa4 Binary files /dev/null and b/resources/character/imgs/crown.png differ diff --git a/resources/character/星星.png b/resources/character/imgs/star.png similarity index 100% rename from resources/character/星星.png rename to resources/character/imgs/star.png diff --git a/resources/font/HYWenHei-55W.ttf b/resources/font/HYWenHei-55W.ttf new file mode 100644 index 00000000..7ccaf435 Binary files /dev/null and b/resources/font/HYWenHei-55W.ttf differ diff --git a/resources/font/tttgbnumber.ttf b/resources/font/tttgbnumber.ttf new file mode 100644 index 00000000..89a392f7 Binary files /dev/null and b/resources/font/tttgbnumber.ttf differ diff --git a/resources/font/华文中宋.TTF b/resources/font/华文中宋.TTF new file mode 100644 index 00000000..2ddb8b23 Binary files /dev/null and b/resources/font/华文中宋.TTF differ