diff --git a/apps/character/avatar-card.js b/apps/character/avatar-card.js index 639de073..3f8d3162 100644 --- a/apps/character/avatar-card.js +++ b/apps/character/avatar-card.js @@ -1,8 +1,7 @@ import { Artifact, Character } from "../../components/models.js"; -import { Cfg } from "../../components/index.js"; +import { Cfg, Data, Common, Profile } from "../../components/index.js"; import lodash from "lodash"; import { segment } from "oicq"; -import { Common, Profile } from "../../components/index.js"; //角色昵称 let nameID = ""; @@ -104,7 +103,6 @@ async function renderCard(e, avatar, render, renderType = "card") { //获取角色技能数据 async function getTalent(e, avatars) { let talent = {}, cons = 0, char = Character.get(avatars.id), mode = "level"; - console.log('isCustom', char.isCustom, char.id); if (char.isCustom) { return {} } @@ -225,9 +223,9 @@ function getCharacterData(avatars) { return { name: avatars.name, showName: genshin.abbr[avatars.name] ? genshin.abbr[avatars.name] : avatars.name, - level: avatars.lv || avatars.level, + level: Data.def(avatars.lv, avatars.level), fetter: avatars.fetter, - cons: avatars.cons || avatars.actived_constellation_num, + cons: Data.def(avatars.cons, avatars.actived_constellation_num), weapon, artiEffect, reliquaries diff --git a/components/Data.js b/components/Data.js index eb45956e..8b71142f 100644 --- a/components/Data.js +++ b/components/Data.js @@ -186,6 +186,25 @@ let Data = { sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); + }, + + def() { + for (let idx in arguments) { + if (!lodash.isUndefined(arguments[idx])) { + return arguments[idx]; + } + } + }, + eachStr: (arr, fn) => { + if (lodash.isString(arr)) { + arr = arr.replace(/\s*(;|;|、|,)\s*/, ","); + arr = arr.split(","); + } + lodash.forEach(arr, (str, idx) => { + if (!lodash.isUndefined(str)) { + fn(str.trim ? str.trim() : str, idx) + } + }); } } diff --git a/components/models/Character.js b/components/models/Character.js index c1679b62..beb8c4f2 100644 --- a/components/models/Character.js +++ b/components/models/Character.js @@ -15,7 +15,7 @@ async function init() { charCfg = await Data.importModule(`plugins/miao-plugin/config`, 'character_default.js'), custom = await Data.importModule(`plugins/miao-plugin/config`, 'character.js'); - lodash.forEach([charCfg.customCharacters, custom.customCharacters, sysCfg.roleId], (roleIds) => { + lodash.forEach([custom.customCharacters, charCfg.customCharacters, sysCfg.roleId], (roleIds) => { lodash.forEach(roleIds || {}, (aliases, id) => { aliases = aliases || []; if (aliases.length === 0) { @@ -32,11 +32,11 @@ async function init() { lodash.forEach([sysCfg.wifeData, charCfg.wifeData, custom.wifeData], (wifeData) => { lodash.forEach(wifeData || {}, (ids, type) => { - type = { girlfriend: 0, boyfriend: 1, daughter: 2, son: 3 }[type] || type; + type = Data.def({ girlfriend: 0, boyfriend: 1, daughter: 2, son: 3 }[type], type); if (!wifeMap[type]) { wifeMap[type] = {}; } - lodash.forEach(ids, (id) => { + Data.eachStr(ids, (id) => { id = aliasMap[id]; if (id) { wifeMap[type][id] = true; diff --git a/config/character_default.js b/config/character_default.js index 7110e34f..20a0bb60 100644 --- a/config/character_default.js +++ b/config/character_default.js @@ -1,23 +1,28 @@ /* -* 请不要直接修改此文件,防止后续冲突 -* 如需编辑可【复制】此文件,改名为character.js自行编辑 -* character.js character_default.js两份配置会叠加生效 +* 请不要直接修改此或删除此文件,防止后续更新冲突 +* 如需新增自定义角色可【复制】此文件,改名为character.js +* 复制的character.js中可按格式及自己需求进行配置 +* 最终character.js character_default.js两份配置会叠加生效 * * 暂未做热更新,修改完毕请重启yunzai * */ -// 角色列表,首位需要是标准名字 -// 实装的角色需要以roleid为key,非实装请以英文为key +/* +* 角色列表,别名的第一个是标准名字,后面的为别名 +* 实装的角色需要以数字roleid为key,自定义的角色及非实装角色请以英文为key +* */ export const customCharacters = { + + // 已有角色添加别名示例:为魈增加新的别名 + // roleid请参见Yunzai roleId.js + 10000026: ["魈", "风夜叉"], + + // 以下为新增自定义角色,角色id请以小写英文定义 paimon: ["派蒙", "应急食物", "应急食品", "吉祥物", "宠物", "外置器官", "会说话的动物", "矮堇瓜", "飞行矮堇瓜", "最好的伙伴"], - - // 啊, 原谅英语白痴。。 - sb: ["散兵", "国崩", "雷电国崩", "大炮", "雷电大炮", "逆子"], - + sb: ["散兵", "国崩", "雷电国崩", "大炮", "雷电大炮", "雷大炮", "伞兵"], + nvshi: ["女士", "炽热的炎之魔女", "炎之魔女"], baizhu: ["白术", "长生"], - - yaoyao: ["瑶瑶", "遥遥无期"], - + yaoyao: ["瑶瑶", "遥遥", "遥遥无期"], fanan: ["伐难", "水夜叉"] } @@ -27,14 +32,13 @@ export const customCharacters = { * */ export const wifeData = { // 老婆&女朋友:成女、少女 - girlfriend: ['伐难'], + girlfriend: "伐难, 女士", // 老公&男朋友:成男、少男 - boyfriend: ['散兵', '白术'], + boyfriend: "散兵, 白术", // 女儿:萝莉 - daughter: ['派蒙', '瑶瑶'], - + daughter: "派蒙, 瑶瑶", // 儿子:正太 - son: [] + son: "" } \ No newline at end of file diff --git a/resources/character-img/女士/01.jpg b/resources/character-img/女士/01.jpg new file mode 100644 index 00000000..9074283e Binary files /dev/null and b/resources/character-img/女士/01.jpg differ diff --git a/resources/character-img/女士/02.jpg b/resources/character-img/女士/02.jpg new file mode 100644 index 00000000..efa8e648 Binary files /dev/null and b/resources/character-img/女士/02.jpg differ diff --git a/resources/character-img/女士/03.jpg b/resources/character-img/女士/03.jpg new file mode 100644 index 00000000..b765f067 Binary files /dev/null and b/resources/character-img/女士/03.jpg differ diff --git a/resources/character-img/女士/04.jpg b/resources/character-img/女士/04.jpg new file mode 100644 index 00000000..3cb04fa9 Binary files /dev/null and b/resources/character-img/女士/04.jpg differ diff --git a/resources/character-img/女士/05.jpg b/resources/character-img/女士/05.jpg new file mode 100644 index 00000000..dde971b6 Binary files /dev/null and b/resources/character-img/女士/05.jpg differ