Merge pull request #1315 from libccy/die-audio-dev
添加game.parseDieTextMap,将character[4]里的阵亡语音相关屎山规范化
This commit is contained in:
commit
f1699f7594
|
@ -94,7 +94,9 @@ export default {
|
||||||
"#clanxieshu2": "我有佐国之术,可缚苍龙。",
|
"#clanxieshu2": "我有佐国之术,可缚苍龙。",
|
||||||
"#clanbaozu_clan_zhonghui1": "不为刀下脍,且做俎上刀。",
|
"#clanbaozu_clan_zhonghui1": "不为刀下脍,且做俎上刀。",
|
||||||
"#clanbaozu_clan_zhonghui2": "吾族恒大,谁敢欺之?",
|
"#clanbaozu_clan_zhonghui2": "吾族恒大,谁敢欺之?",
|
||||||
"#clan_zhonghui:die": "谋事在人,成事在天……",
|
"#clan_zhonghui:die": "兵来似欲作恶,当云何?",
|
||||||
|
"#clan_zhonghui2:die": "伯约误我!",
|
||||||
|
"#clan_zhonghui3:die": "谋事在人,成事在天……",
|
||||||
"#clanjiejian1": "庙胜之策,不临矢石。",
|
"#clanjiejian1": "庙胜之策,不临矢石。",
|
||||||
"#clanjiejian2": "王者之兵,有征无战。",
|
"#clanjiejian2": "王者之兵,有征无战。",
|
||||||
"#clanhuanghan1": "居天子阶下,故诚惶诚恐。",
|
"#clanhuanghan1": "居天子阶下,故诚惶诚恐。",
|
||||||
|
|
|
@ -1580,6 +1580,60 @@ export class Game {
|
||||||
|
|
||||||
return getAudioList(skill, { audioname: [], history: [] }, skillInfo);
|
return getAudioList(skill, { audioname: [], history: [] }, skillInfo);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取角色死亡时能播放的所有阵亡语音
|
||||||
|
* @param { string | Player } player 角色名
|
||||||
|
* @returns { any[] } 语音地址列表
|
||||||
|
*/
|
||||||
|
parseDieTextMap(player){
|
||||||
|
let name, rawName;
|
||||||
|
if (typeof player === "string") {
|
||||||
|
name = player;
|
||||||
|
rawName = name;
|
||||||
|
}
|
||||||
|
else if (get.itemtype(player) === "player") {
|
||||||
|
// @ts-ignore
|
||||||
|
name = player.skin.name || player.name;
|
||||||
|
rawName = player.name;
|
||||||
|
}
|
||||||
|
const info = get.character(name), datas = [];
|
||||||
|
let dieAudios;
|
||||||
|
if(info && info.dieAudios.length > 0){
|
||||||
|
dieAudios = info.dieAudios;
|
||||||
|
}
|
||||||
|
//@mengxinzxz写的屎山
|
||||||
|
else if(rawName !== name && lib.characterSubstitute[rawName] && lib.characterSubstitute[rawName].some((i) => i[0] == name)){
|
||||||
|
const trashes = lib.characterSubstitute[rawName].find((i) => i[0] == name)[1];
|
||||||
|
const newCharacter = get.convertedCharacter(['','',0,[],trashes]);
|
||||||
|
dieAudios = newCharacter.dieAudios;
|
||||||
|
}
|
||||||
|
if(dieAudios && dieAudios.length > 0){
|
||||||
|
dieAudios.forEach(item => {
|
||||||
|
let key, file;
|
||||||
|
if(item.startsWith("ext:")){
|
||||||
|
key = item.slice(4).split("/")[1];
|
||||||
|
file = item;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key = item;
|
||||||
|
file = `die/${item}.mp3`;
|
||||||
|
}
|
||||||
|
const data = {key, file}
|
||||||
|
if(lib.translate[`#${key}:die`]) data.text = lib.translate[`#${key}:die`];
|
||||||
|
datas.push(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const data = {
|
||||||
|
key: name,
|
||||||
|
file: `die/${name}.mp3`,
|
||||||
|
isDefault: true,
|
||||||
|
}
|
||||||
|
if(lib.translate[`#${name}:die`]) data.text = lib.translate[`#${name}:die`];
|
||||||
|
datas.push(data);
|
||||||
|
}
|
||||||
|
return datas;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param { string } skill
|
* @param { string } skill
|
||||||
|
|
|
@ -145,6 +145,11 @@ export class Character {
|
||||||
* @type { string[] }
|
* @type { string[] }
|
||||||
**/
|
**/
|
||||||
clans = [];
|
clans = [];
|
||||||
|
/**
|
||||||
|
* 武将牌拥有的全部阵亡语音
|
||||||
|
* @type { string[] }
|
||||||
|
**/
|
||||||
|
dieAudios = [];
|
||||||
/**
|
/**
|
||||||
* 武将牌“无法享受到的主公/地主红利”
|
* 武将牌“无法享受到的主公/地主红利”
|
||||||
* @type { string[] }
|
* @type { string[] }
|
||||||
|
@ -191,6 +196,7 @@ export class Character {
|
||||||
this.clans = [];
|
this.clans = [];
|
||||||
this.initFilters = [];
|
this.initFilters = [];
|
||||||
this.trashBin = [];
|
this.trashBin = [];
|
||||||
|
this.dieAudios = [];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param { any[] } trash
|
* @param { any[] } trash
|
||||||
|
@ -248,6 +254,10 @@ export class Character {
|
||||||
clans.push(item.slice(5));
|
clans.push(item.slice(5));
|
||||||
} else if (item.startsWith("InitFilter:")) {
|
} else if (item.startsWith("InitFilter:")) {
|
||||||
this.initFilters = item.slice(11).split(":");
|
this.initFilters = item.slice(11).split(":");
|
||||||
|
} else if (item.startsWith("die:")){
|
||||||
|
this.dieAudios.push(item.slice(4));
|
||||||
|
} else if (item.startsWith("die_audio:")){
|
||||||
|
this.dieAudios = item.slice(10).split(":");
|
||||||
} else {
|
} else {
|
||||||
keptTrashes.push(item);
|
keptTrashes.push(item);
|
||||||
}
|
}
|
||||||
|
@ -369,6 +379,10 @@ export class Character {
|
||||||
if (character.initFilters.length > 0) {
|
if (character.initFilters.length > 0) {
|
||||||
trashes.push(`InitFilters:${character.initFilters.join(":")}`);
|
trashes.push(`InitFilters:${character.initFilters.join(":")}`);
|
||||||
}
|
}
|
||||||
|
if (character.dieAudios.length > 0) {
|
||||||
|
if (character.dieAudios.length === 1) trashes.push(`die:${character.dieAudios[0]}`)
|
||||||
|
else trashes.push(`die_audio:${character.dieAudios.join(":")}`);
|
||||||
|
}
|
||||||
|
|
||||||
return new Proxy(trashes.concat(character.trashBin), {
|
return new Proxy(trashes.concat(character.trashBin), {
|
||||||
set(target, prop, newValue) {
|
set(target, prop, newValue) {
|
||||||
|
|
|
@ -8786,38 +8786,16 @@ export const Content = {
|
||||||
_status.dying.remove(player);
|
_status.dying.remove(player);
|
||||||
|
|
||||||
if (lib.config.background_speak) {
|
if (lib.config.background_speak) {
|
||||||
const name = player.skin.name || player.name;
|
const audios = game.parseDieTextMap(player).randomGet();
|
||||||
const goon = !lib.character[name];
|
if (audios.isDefault) {
|
||||||
if (goon)
|
const name = audios.key;
|
||||||
lib.character[name] = [
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
0,
|
|
||||||
[],
|
|
||||||
((lib.characterSubstitute[player.name] || []).find((i) => i[0] == name) || [
|
|
||||||
name,
|
|
||||||
[],
|
|
||||||
])[1],
|
|
||||||
];
|
|
||||||
if (lib.character[name][4].some((tag) => /^die:.+$/.test(tag))) {
|
|
||||||
var tag = lib.character[name][4].find((tag) => /^die:.+$/.test(tag));
|
|
||||||
var reg = new RegExp("^ext:(.+)?/");
|
|
||||||
var match = tag.match(/^die:(.+)$/);
|
|
||||||
if (match) {
|
|
||||||
var path = match[1];
|
|
||||||
if (reg.test(path)) path = path.replace(reg, (_o, p) => `../extension/${p}/`);
|
|
||||||
game.playAudio(path);
|
|
||||||
}
|
|
||||||
} else if (lib.character[name][4].some((tag) => tag.startsWith("die_audio"))) {
|
|
||||||
var tag = lib.character[name][4].find((tag) => tag.startsWith("die_audio"));
|
|
||||||
var list = tag.split(":").slice(1);
|
|
||||||
game.playAudio("die", list.length ? list.randomGet() : name);
|
|
||||||
} else {
|
|
||||||
game.playAudio("die", name, function () {
|
game.playAudio("die", name, function () {
|
||||||
game.playAudio("die", name.slice(name.indexOf("_") + 1));
|
game.playAudio("die", name.slice(name.indexOf("_") + 1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (goon) delete lib.character[name];
|
else{
|
||||||
|
game.playAudio(audios.file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, player);
|
}, player);
|
||||||
|
|
||||||
|
|
|
@ -3633,21 +3633,23 @@ export class Click {
|
||||||
htmlParser.innerHTML = get.characterIntro(name);
|
htmlParser.innerHTML = get.characterIntro(name);
|
||||||
Array.from(htmlParser.childNodes).forEach((value) => introduction.appendChild(value));
|
Array.from(htmlParser.childNodes).forEach((value) => introduction.appendChild(value));
|
||||||
//添加技能语音部分
|
//添加技能语音部分
|
||||||
const dieAudio = lib.translate[`#${name}:die`];
|
const dieAudios = game.parseDieTextMap(name).filter(i => "text" in i);
|
||||||
const skillAudioMap = new Map();
|
const skillAudioMap = new Map();
|
||||||
nameInfo.skills.forEach(skill => {
|
nameInfo.skills.forEach(skill => {
|
||||||
const voiceMap = game.parseSkillText(skill, name, null, true);
|
const voiceMap = game.parseSkillText(skill, name, null, true);
|
||||||
if(voiceMap.length) skillAudioMap.set(skill, voiceMap);
|
if(voiceMap.length) skillAudioMap.set(skill, voiceMap);
|
||||||
});
|
});
|
||||||
if (dieAudio || skillAudioMap.size > 0){
|
if (dieAudios.length || skillAudioMap.size > 0) {
|
||||||
introduction.appendChild(document.createElement("hr"));
|
introduction.appendChild(document.createElement("hr"));
|
||||||
|
|
||||||
|
if (skillAudioMap.size > 0) {
|
||||||
const skillNameSpan = document.createElement("span");
|
const skillNameSpan = document.createElement("span");
|
||||||
skillNameSpan.innerHTML = `技能台词<br>`;
|
skillNameSpan.innerHTML = `技能台词<br>`;
|
||||||
introduction.appendChild(skillNameSpan);
|
introduction.appendChild(skillNameSpan);
|
||||||
|
|
||||||
if(skillAudioMap.size > 0){
|
|
||||||
skillAudioMap.forEach((texts, skill) => {
|
skillAudioMap.forEach((texts, skill) => {
|
||||||
const skillNameSpan = document.createElement("span"), skillNameSpanStyle = skillNameSpan.style;
|
const skillNameSpan = document.createElement("span"),
|
||||||
|
skillNameSpanStyle = skillNameSpan.style;
|
||||||
skillNameSpanStyle.fontWeight = "bold";
|
skillNameSpanStyle.fontWeight = "bold";
|
||||||
skillNameSpan.innerHTML = `<br>${get.translation(skill)}<br>`;
|
skillNameSpan.innerHTML = `<br>${get.translation(skill)}<br>`;
|
||||||
introduction.appendChild(skillNameSpan);
|
introduction.appendChild(skillNameSpan);
|
||||||
|
@ -3655,18 +3657,22 @@ export class Click {
|
||||||
const skillTextSpan = document.createElement("span");
|
const skillTextSpan = document.createElement("span");
|
||||||
skillTextSpan.innerHTML = `${index + 1}. ${text}<br>`;
|
skillTextSpan.innerHTML = `${index + 1}. ${text}<br>`;
|
||||||
introduction.appendChild(skillTextSpan);
|
introduction.appendChild(skillTextSpan);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(dieAudio){
|
|
||||||
const skillNameSpan = document.createElement("span"), skillNameSpanStyle = skillNameSpan.style;
|
if (dieAudios.length > 0) {
|
||||||
|
const skillNameSpan = document.createElement("span"),
|
||||||
|
skillNameSpanStyle = skillNameSpan.style;
|
||||||
skillNameSpanStyle.fontWeight = "bold";
|
skillNameSpanStyle.fontWeight = "bold";
|
||||||
skillNameSpan.innerHTML = `<br>阵亡台词<br>`;
|
skillNameSpan.innerHTML = `<br>阵亡台词`;
|
||||||
introduction.appendChild(skillNameSpan);
|
introduction.appendChild(skillNameSpan);
|
||||||
|
|
||||||
const skillTextSpan = document.createElement("span");
|
dieAudios.forEach((item, index) => {
|
||||||
skillTextSpan.innerHTML = `${dieAudio}`;
|
const dieTextSpan = document.createElement("span");
|
||||||
introduction.appendChild(skillTextSpan);
|
dieTextSpan.innerHTML = `<br>${dieAudios.length > 1 ? `${index + 1}. ` : ""}${item.text}`;
|
||||||
|
introduction.appendChild(dieTextSpan);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const introduction2 = ui.create.div(".characterintro.intro2", uiintro);
|
const introduction2 = ui.create.div(".characterintro.intro2", uiintro);
|
||||||
|
|
Loading…
Reference in New Issue