From 46de6f4958c7a92e68f1e8389aaa6f6db7027b0c Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Wed, 22 May 2024 00:30:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0get.Audio.toFile=E5=92=8CtoTe?= =?UTF-8?q?xt=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/game/index.js | 10 ++++++---- noname/get/audio.js | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index e4f0fb4b5..d69b15670 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1412,6 +1412,8 @@ export class Game { return audio; } /** + * @deprecated 请使用get.Audio.skill + get.Audio.toFile + * * 根据skill中的audio,audioname,audioname2和player来获取音频地址列表 * @typedef {[string,number]|string|number|boolean} audioInfo * @typedef {{audio: audioInfo, audioname?:string[], audioname2?:{[playerName: string]: audioInfo}}} skillInfo @@ -1421,9 +1423,11 @@ export class Game { * @returns { string[] } 语音地址列表 */ parseSkillAudio(skill, player, skillInfo) { - return get.Audio.skill({ skill, player, info: skillInfo }).map(data => data.file); + return get.Audio.toFile(get.Audio.skill({ skill, player, info: skillInfo })); } /** + * @deprecated 请使用get.Audio.skill + get.Audio.toText + * * 根据skill中的audio,audioname,audioname2和player来获取技能台词列表 * @param { string } skill 技能名 * @param { Player | Object | string } [player] 角色/角色名 @@ -1431,9 +1435,7 @@ export class Game { * @returns { string[] } 语音地址列表 */ parseSkillText(skill, player, skillInfo) { - return get.Audio.skill({ skill, player, info: skillInfo }) - .map(data => data.text) - .filter(text => text !== void 0); + return get.Audio.toText(get.Audio.skill({ skill, player, info: skillInfo })); } /** * @deprecated 请使用get.Audio.skill diff --git a/noname/get/audio.js b/noname/get/audio.js index c416b2787..2d97c430e 100644 --- a/noname/get/audio.js +++ b/noname/get/audio.js @@ -269,4 +269,30 @@ export class Audio { return result; } + /** + * @param {textMap[]} list + * @returns {string[]} + */ + toFile(list) { + return (function getResult(textMap) { + const result = textMap.map(data => data.file); + //@ts-ignore + if (textMap.alternate) result.alternate = getResult(textMap.alternate); + return result; + })(list); + } + + /** + * @param {textMap[]} list + * @returns {string[]} + */ + toText(list) { + return (function getResult(textMap) { + const result = textMap.map(data => data.text).filter(text => text !== void 0); + //@ts-ignore + if (textMap.alternate) result.alternate = getResult(textMap.alternate); + return result; + })(list); + } + } \ No newline at end of file