为死亡备用语音提供更清晰的写法
This commit is contained in:
parent
3473708d85
commit
d895fb4cc0
|
@ -1468,15 +1468,24 @@ export class Game {
|
|||
*/
|
||||
trySkillAudio(skill, player, directaudio, nobroadcast, skillInfo) {
|
||||
if (!nobroadcast) game.broadcast(game.trySkillAudio, skill, player, directaudio, nobroadcast, skillInfo);
|
||||
if (!lib.config.background_speak) return;
|
||||
|
||||
const info = skillInfo || lib.skill[skill];
|
||||
if (!info) return;
|
||||
if (!lib.config.background_speak) return;
|
||||
if (info.direct && !directaudio) return;
|
||||
if (lib.skill.global.includes(skill) && !info.forceaudio) return;
|
||||
let audio,
|
||||
list = game.parseSkillTextMap(skill, player, skillInfo).randomSort();
|
||||
|
||||
let audio, list = get.Audio.skill({ skill, player, info: skillInfo }).randomSort();
|
||||
const check = () => {
|
||||
if (list.length) return true;
|
||||
//@ts-ignore
|
||||
if (!list.alternate) return false;
|
||||
//@ts-ignore
|
||||
list = list.alternate;
|
||||
return check();
|
||||
};
|
||||
return (function play() {
|
||||
if (!list.length) return;
|
||||
if (!check()) return;
|
||||
audio = list.shift();
|
||||
return game.playAudio(audio.file, play);
|
||||
})();
|
||||
|
@ -1489,21 +1498,13 @@ export class Game {
|
|||
game.broadcast(game.tryDieAudio, player);
|
||||
if (!lib.config.background_speak) return;
|
||||
|
||||
let playerName;
|
||||
if (typeof player === "string") playerName = player;
|
||||
else if (player.skin && player.skin.name) playerName = player.skin.name;
|
||||
else playerName = player.name;
|
||||
|
||||
let audio,
|
||||
isDefault,
|
||||
list = game.parseDieTextMap(player).randomSort();
|
||||
let audio, list = get.Audio.die({player}).randomSort();
|
||||
const check = () => {
|
||||
if (list.length) return true;
|
||||
if (!audio) return false;
|
||||
if (!audio.isDefault) return false;
|
||||
if (!playerName.includes("_")) return false;
|
||||
playerName = playerName.slice(playerName.indexOf("_") + 1);
|
||||
list = game.parseDieTextMap(playerName).randomSort();
|
||||
//@ts-ignore
|
||||
if (!list.alternate) return false;
|
||||
//@ts-ignore
|
||||
list = list.alternate;
|
||||
return check();
|
||||
};
|
||||
return (function play() {
|
||||
|
|
|
@ -27,6 +27,10 @@ export class Audio {
|
|||
* @returns { textMap[] }
|
||||
*/
|
||||
skill({ skill, player, info }) {
|
||||
if (skill === void 0) {
|
||||
console.error(new ReferenceError(`skill is not defined`));
|
||||
return [];
|
||||
}
|
||||
//@ts-ignore
|
||||
if (typeof player === "string") player = get.convertedCharacter({ name: player });
|
||||
//@ts-ignore
|
||||
|
@ -77,6 +81,10 @@ export class Audio {
|
|||
* @returns { textMap[] }
|
||||
*/
|
||||
die({ player, info }) {
|
||||
if (player === void 0) {
|
||||
console.error(new ReferenceError(`player is not defined`));
|
||||
return [];
|
||||
}
|
||||
let name = typeof player === "string" ? player : player.name;
|
||||
let skinInfo;
|
||||
if (info) skinInfo = { dieAudios: info };
|
||||
|
@ -113,7 +121,8 @@ export class Audio {
|
|||
* @returns { textMap[] }
|
||||
*/
|
||||
#parse = function (arg) {
|
||||
const { name, info, data = {}, options, getInfo, isExist, getAudioInfo } = arg;
|
||||
const { data = {}, options, getInfo, isExist, getAudioInfo } = arg;
|
||||
let { name, info } = arg;
|
||||
const { type, defaultPath, defaultInfo } = options;
|
||||
data.history = [];
|
||||
|
||||
|
@ -205,7 +214,18 @@ export class Audio {
|
|||
return [this.#textMap({ path, name: audioInfo, ext, type, isDefault, defaultPath })];
|
||||
}
|
||||
|
||||
return getAudioList(name, data, info);
|
||||
const getResult = () => {
|
||||
const result = getAudioList(name, data, info);
|
||||
if (!result.every(i => i.isDefault)) return result;
|
||||
if (name.includes("_")) {
|
||||
name = name.slice(name.indexOf("_") + 1);
|
||||
info = void 0;
|
||||
//@ts-ignore
|
||||
result.alternate = getResult();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue