From fd5d31b3e1b24ebbc53d98c50751774d4b768776 Mon Sep 17 00:00:00 2001 From: mengxinzxz <2223529500@qq.com> Date: Wed, 13 Mar 2024 18:25:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96changeSkill=E7=9A=84=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BD=BF=E5=85=B6?= =?UTF-8?q?=E6=8B=A5=E6=9C=89=E6=9B=B4=E5=A4=9A=E5=8F=AF=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 具体介绍(令第一个参数为map): Ⅰ、若map为字符串类型,则默认为传入技能 Ⅱ、若map为object类型,则: ①map.skill,更换所含map.skill技能的武将牌 ②map.characterName,更换xxx[name]等于map.characterName的武将牌 ③map.characterSkinName,更换xxx.skin[name]等于map.characterSkinName的对应位的武将牌 ④map.source,更换name等于map.source的对应位的武将牌 --- noname/library/element/player.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/noname/library/element/player.js b/noname/library/element/player.js index bca4e52a7..88d083e06 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -2330,19 +2330,32 @@ export class Player extends HTMLDivElement { * * 如果lib.character[character]不存在,且想引用其他路径的图片素材或阵亡素材,请以[character,[]]的形式写入lib.character.characterSubstitute[name]中,第二个数组填入形式同lib.character[4]的书写形式 * - * @param { string | string } + * @param { string | object | function } map + * @param { string } character */ - changeSkin(skill, character) { - if (!skill || !character) { - console.log('error: no sourceSkill or character to changeSkin', get.translation(this)); + changeSkin(map, character) { + if (!map || !character) { + console.warn('error: no sourceMap or character to changeSkin', get.translation(this)); return; } + if (typeof map == 'string') { + map = { skill: map }; + } for (const i of ['name', 'name1', 'name2']) { if (i == 'name1' && this.name === this.name1) continue; const list = lib.characterSubstitute[this[i]]; if (this[i] && list) { - if ((get.character(this[i], 3) || []).includes(skill)) { - const name = (i == 'name2' ? 'name2' : 'name'); + const name = (i == 'name2' ? 'name2' : 'name'); + if ((() => { + if (typeof map == 'function') { + return map(this, name); + } + if (typeof map.skill == 'string' && (get.character(this[i], 3) || []).includes(map.skill)) return true; + if (typeof map.characterName == 'string' && this[i] == map.characterName) return true; + if (typeof map.characterSkinName == 'string' && this.skin[name] == map.characterSkinName) return true; + if (typeof map.source == 'string' && name == map.source) return true; + return false; + })()) { if (this.skin[name] != character) { const origin = this.skin[name]; game.broadcastAll((player, name, character, list, origin) => {