消灭[4]中clan属性的引用
This commit is contained in:
parent
b9ca903c1d
commit
5732a3b328
|
@ -105,6 +105,11 @@ export class Character {
|
|||
* @type { boolean }
|
||||
**/
|
||||
isBossAllowed = false;
|
||||
/**
|
||||
* 武将牌对应的全部宗族
|
||||
* @type { string[] }
|
||||
**/
|
||||
clans = [];
|
||||
/**
|
||||
* @param { Array|Object } [data]
|
||||
*/
|
||||
|
@ -116,7 +121,7 @@ export class Character {
|
|||
this.maxHp = get.infoMaxHp(data[2]);
|
||||
this.hujia = get.infoHujia(data[2]);
|
||||
this.skills = get.copy(data[3] || []);
|
||||
Character.convertTrashToProperties(this, this.trashBin);
|
||||
if (data[4]) Character.convertTrashToProperties(this, data[4]);
|
||||
} else if (get.is.object(data)) {
|
||||
Object.assign(this, data);
|
||||
if (typeof this.maxHp !== "number") this.maxHp = this.hp;
|
||||
|
@ -127,7 +132,8 @@ export class Character {
|
|||
* @param { Array } trash
|
||||
*/
|
||||
static convertTrashToProperties(character, trash) {
|
||||
let keptTrashes = [];
|
||||
let keptTrashes = [],
|
||||
clans = [];
|
||||
for (let i = 0; i < trash.length; i++) {
|
||||
let item = trash[i];
|
||||
if (i === 0 && lib.group.includes(item)) {
|
||||
|
@ -156,10 +162,13 @@ export class Character {
|
|||
character.dualSideCharacter = item.slice(9);
|
||||
} else if (item.startsWith("doublegroup:")) {
|
||||
character.doubleGroup = item.slice(12).split(":");
|
||||
} else if (item.startsWith("clan:")) {
|
||||
clans.push(item.slice(5));
|
||||
} else {
|
||||
keptTrashes.push(item);
|
||||
}
|
||||
}
|
||||
if (clans.length > 0) character.clans = clans;
|
||||
character.trashBin = keptTrashes;
|
||||
}
|
||||
/**
|
||||
|
@ -210,50 +219,54 @@ export class Character {
|
|||
* @deprecated
|
||||
*/
|
||||
get 4() {
|
||||
const trashes = [], character = this;
|
||||
const trashes = [],
|
||||
character = this;
|
||||
if (lib.group.includes(character.groupInGuozhan)) {
|
||||
trashes.push(character.groupInGuozhan);
|
||||
}
|
||||
if (character.isZhugong) {
|
||||
trashes.push('zhu');
|
||||
trashes.push("zhu");
|
||||
}
|
||||
if (character.isUnseen) {
|
||||
trashes.push('unseen');
|
||||
trashes.push("unseen");
|
||||
}
|
||||
if (character.isMinskin) {
|
||||
trashes.push('minskin');
|
||||
trashes.push("minskin");
|
||||
}
|
||||
if (character.isBoss) {
|
||||
trashes.push('boss');
|
||||
trashes.push("boss");
|
||||
}
|
||||
if (character.isBossAllowed) {
|
||||
trashes.push('bossallowed');
|
||||
trashes.push("bossallowed");
|
||||
}
|
||||
if (character.isHiddenBoss) {
|
||||
trashes.push('hiddenboss');
|
||||
trashes.push("hiddenboss");
|
||||
}
|
||||
if (character.isAiForbidden) {
|
||||
trashes.push('forbidai');
|
||||
trashes.push("forbidai");
|
||||
}
|
||||
if (character.isHiddenInStoneMode) {
|
||||
trashes.push('stonehidden');
|
||||
trashes.push("stonehidden");
|
||||
}
|
||||
if (character.hasHiddenSkill) {
|
||||
trashes.push('hiddenSkill');
|
||||
trashes.push("hiddenSkill");
|
||||
}
|
||||
if (character.groupBorder) {
|
||||
trashes.push(`border:${character.groupBorder}`);
|
||||
}
|
||||
if (character.dualSideCharacter) {
|
||||
trashes.push(`duaslside:${character.dualSideCharacter}`)
|
||||
trashes.push(`duaslside:${character.dualSideCharacter}`);
|
||||
}
|
||||
if (character.doubleGroup.length > 0) {
|
||||
trashes.push(`doublegroup:${character.doubleGroup.join(':')}`)
|
||||
trashes.push(`doublegroup:${character.doubleGroup.join(":")}`);
|
||||
}
|
||||
if (character.clans.length > 0) {
|
||||
character.clans.forEach((item) => trashes.push(`clan:${item}`));
|
||||
}
|
||||
|
||||
return trashes.concat(character.trashBin);
|
||||
}
|
||||
set 4(trashBin) {
|
||||
this.trashBin = trashBin;
|
||||
console.warn("你set你🐎的废弃属性");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1492,27 +1492,28 @@ export class Player extends HTMLDivElement {
|
|||
else this.markSkill("cooperation_" + reason);
|
||||
}
|
||||
/**
|
||||
* @param { string } clan 氏族名称
|
||||
* @param { boolean } unseen 是否无视暗将的限制
|
||||
* @returns { string[] }
|
||||
*/
|
||||
hasClan(clan, unseen) {
|
||||
getClans(unseen){
|
||||
const clans = [];
|
||||
if (unseen || !this.isUnseen(0)) {
|
||||
let info = lib.character[this.name1];
|
||||
if (info && info[4]) {
|
||||
for (let i of info[4]) {
|
||||
if (typeof i == "string" && i.startsWith("clan:") && i.slice(5) == clan) return true;
|
||||
}
|
||||
}
|
||||
if (info && info.clans) clans.addArray(info.clans);
|
||||
}
|
||||
if (this.name2 && (unseen || !this.isUnseen(1))) {
|
||||
let info = lib.character[this.name2];
|
||||
if (info && info[4]) {
|
||||
for (let i of info[4]) {
|
||||
if (typeof i == "string" && i.startsWith("clan:") && i.slice(5) == clan) return true;
|
||||
if (info && info.clans) clans.addArray(info.clans);
|
||||
}
|
||||
return clans;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
/**
|
||||
* @param { string } clan 氏族名称
|
||||
* @param { boolean } unseen 是否无视暗将的限制
|
||||
* @returns { boolean }
|
||||
*/
|
||||
hasClan(clan, unseen) {
|
||||
return this.getClans(unseen).includes(clan);
|
||||
}
|
||||
/**
|
||||
* @param { string } skill
|
||||
|
|
Loading…
Reference in New Issue