This commit is contained in:
kuangshen04 2024-05-12 23:37:11 +08:00
parent 4984d78209
commit 214f9c29d7
1 changed files with 11 additions and 6 deletions

View File

@ -1711,18 +1711,23 @@ export class Game {
game.broadcast(game.tryDieAudio, player); game.broadcast(game.tryDieAudio, player);
if (!lib.config.background_speak) return; 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, isDefault, list = game.parseDieTextMap(player).randomSort();
const check = audio => { const check = () => {
if (list.length) return true; if (list.length) return true;
if (!audio) return false; if (!audio) return false;
if (!audio.isDefault) return false; if (!audio.isDefault) return false;
const name = audio.name; if (!playerName.includes("_")) return false;
if (!name.includes("_")) return false; playerName = playerName.slice(playerName.indexOf("_") + 1);
list = game.parseDieTextMap(name.slice(name.indexOf("_") + 1)).randomSort(); list = game.parseDieTextMap(playerName).randomSort();
return check(list[0]); return check();
} }
return (function play() { return (function play() {
if (!check(audio)) return; if (!check()) return;
audio = list.shift(); audio = list.shift();
return game.playAudio(audio.file, play); return game.playAudio(audio.file, play);
})(); })();