Merge pull request #1425 from zhichaoxi2006/noname_get_plainText

优化〖博览〗、〖挈挟〗的字段筛选机制
This commit is contained in:
Spmario233 2024-06-02 21:39:42 +08:00 committed by GitHub
commit a6d4b587ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 7 deletions

View File

@ -1438,7 +1438,7 @@ const skills = {
var info = lib.character[name];
if (
info[3].some(function (skill) {
var info = get.skillInfoTranslation(skill);
var info = get.plainText(get.skillInfoTranslation(skill));
if (!info.includes("【杀】")) return false;
var list = get.skillCategoriesOf(skill, player);
list.remove("锁定技");
@ -1470,7 +1470,7 @@ const skills = {
var name = button.link;
var info = lib.character[name];
var skills = info[3].filter(function (skill) {
var info = get.skillInfoTranslation(skill);
var info = get.plainText(get.skillInfoTranslation(skill));
if (!info.includes("【杀】")) return false;
var list = get.skillCategoriesOf(skill, get.player());
list.remove("锁定技");
@ -1509,7 +1509,7 @@ const skills = {
node = ui.create.buttonPresets.character(item, "character", position, noclick);
const info = lib.character[item];
const skills = info[3].filter(function (skill) {
var info = get.skillInfoTranslation(skill);
var info = get.plainText(get.skillInfoTranslation(skill));
if (!info.includes("【杀】")) return false;
var list = get.skillCategoriesOf(skill, get.player());
list.remove("锁定技");
@ -1588,7 +1588,7 @@ const skills = {
var maxHp = get.infoMaxHp(info[2]);
if (maxHp != 1) card.distance = { attackFrom: 1 - maxHp };
var skills = info[3].filter(function (skill) {
var info = get.skillInfoTranslation(skill);
var info = get.plainText(get.skillInfoTranslation(skill));
if (!info.includes("【杀】")) return false;
var list = get.skillCategoriesOf(skill, get.player());
list.remove("锁定技");
@ -1617,10 +1617,10 @@ const skills = {
if (skills.length) {
for (var skill of skills) {
if (lib.skill[skill].nobracket) {
append += '<div class="skilln">' + get.translation(skill) + '</div><div><span style="font-family: yuanli">' + get.skillInfoTranslation(skill) + "</span></div><br><br>";
append += '<div class="skilln">' + get.translation(skill) + '</div><div><span style="font-family: yuanli">' + get.plainText(get.skillInfoTranslation(skill)) + "</span></div><br><br>";
} else {
var translation = lib.translate[skill + "_ab"] || get.translation(skill).slice(0, 2);
append += '<div class="skill">【' + translation + '】</div><div><span style="font-family: yuanli">' + get.skillInfoTranslation(skill) + "</span></div><br><br>";
append += '<div class="skill">【' + translation + '】</div><div><span style="font-family: yuanli">' + get.plainText(get.skillInfoTranslation(skill)) + "</span></div><br><br>";
}
}
str = str.slice(0, str.length - 8);

View File

@ -1750,7 +1750,7 @@ const skills = {
var skill = lib.skill[j];
if (!skill || skill.juexingji || skill.hiddenSkill || skill.zhuSkill || skill.dutySkill || skill.chargeSkill || lib.skill.bolan.banned.includes(j)) continue;
if (skill.init || (skill.ai && (skill.ai.combo || skill.ai.notemp || skill.ai.neg))) continue;
var info = lib.translate[j + "_info"];
var info = get.plainText(lib.translate[j + "_info"]);
if (info && info.indexOf("出牌阶段限一次") != -1) skills.add(j);
}
}

View File

@ -974,6 +974,16 @@ export class Get {
return target;
}
/**
* 用于将HTML代码转换为纯文本
* @param { string } htmlContent
* @returns { string }
*/
plainText(htmlContent) {
var parser = new DOMParser();
var doc = parser.parseFromString(htmlContent || '', 'text/html');
return doc.body.textContent || doc.body.innerText;
}
inpilefull(type) {
var list = [];
for (var i in lib.cardPile) {