reformat again

This commit is contained in:
Spmario233 2024-04-23 14:51:52 +08:00
parent b21516fe67
commit 48add72a16
1 changed files with 155 additions and 168 deletions

View File

@ -5,164 +5,151 @@ import { _status } from "../../status/index.js";
import { ui } from "../../ui/index.js"; import { ui } from "../../ui/index.js";
export class Character { export class Character {
/** @type { string } */ /** @type { string } */
sex; sex;
/** @type { number } */ /** @type { number } */
hp; hp;
/** @type { number } */ /** @type { number } */
maxHp; maxHp;
/** @type { number } */ /** @type { number } */
hujia = 0; hujia = 0;
/** @type { string } */ /** @type { string } */
group; group;
/** @type { string } */ /** @type { string } */
groupBorder; groupBorder;
/** @type { string } */ /** @type { string } */
groupInGuozhan; groupInGuozhan;
/** @type { string[] } */ /** @type { string[] } */
skills = []; skills = [];
/** @type { boolean } */ /** @type { boolean } */
isZhugong = false; isZhugong = false;
/** @type { boolean } */ /** @type { boolean } */
isUnseen = false; isUnseen = false;
/** @type { boolean } */ /** @type { boolean } */
hasHiddenSkill = false; hasHiddenSkill = false;
/** @type { Array } */ /** @type { Array } */
trashBin = []; trashBin = [];
/** @type { string } */ /** @type { string } */
dualSideCharacter; dualSideCharacter;
/** @type { Array } */ /** @type { Array } */
doubleGroup = []; doubleGroup = [];
/** @type { boolean } */ /** @type { boolean } */
isMinskin = false; isMinskin = false;
/** @type { boolean } */ /** @type { boolean } */
isBoss = false; isBoss = false;
/** @type { boolean } */ /** @type { boolean } */
isHiddenBoss = false; isHiddenBoss = false;
/** @type { boolean } */ /** @type { boolean } */
isAiForbidden = false; isAiForbidden = false;
/** @type { boolean } */ /** @type { boolean } */
isHiddenInStoneMode = false; isHiddenInStoneMode = false;
/** @type { boolean } */ /** @type { boolean } */
isBossAllowed = false; isBossAllowed = false;
/** /**
* @param { Array|Object } [data] * @param { Array|Object } [data]
*/ */
constructor(data) { constructor(data) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
this.sex = data[0]; this.sex = data[0];
this.group = data[1]; this.group = data[1];
this.hp = get.infoHp(data[2]); this.hp = get.infoHp(data[2]);
this.maxHp = get.infoMaxHp(data[2]); this.maxHp = get.infoMaxHp(data[2]);
this.hujia = get.infoHujia(data[2]); this.hujia = get.infoHujia(data[2]);
this.skills = get.copy(data[3] || []); this.skills = get.copy(data[3] || []);
this.trashBin = get.copy(data[4] || []); this.trashBin = get.copy(data[4] || []);
Character.convertTrashToProperties(this, this.trashBin); Character.convertTrashToProperties(this, this.trashBin);
} } else if (get.is.object(data)) {
else if (get.is.object(data)) { Object.assign(this, data);
Object.assign(this, data); if (typeof this.maxHp !== "number") this.maxHp = this.hp;
if (typeof this.maxHp !== 'number') this.maxHp = this.hp; }
} }
}; /**
/** * @param { Character } character
* @param { Character } character * @param { Array } trash
* @param { Array } trash */
*/ static convertTrashToProperties(character, trash) {
static convertTrashToProperties(character, trash) { for (let i = 0; i < trash.length; i++) {
for (let i = 0; i < trash.length; i++) { let item = trash[i];
let item = trash[i]; if (i === 0 && lib.group.includes(item)) {
if (i === 0 && lib.group.includes(item)) { character.groupInGuozhan = item;
character.groupInGuozhan = item; } else if (item === "zhu") {
} character.isZhugong = true;
else if (item === 'zhu') { } else if (item === "unseen") {
character.isZhugong = true; character.isUnseen = true;
} } else if (item === "minskin") {
else if (item === 'unseen') { character.isMinskin = true;
character.isUnseen = true; } else if (item === "boss") {
} character.isBoss = true;
else if (item === 'minskin') { } else if (item === "bossallowed") {
character.isMinskin = true; character.isBossAllowed = true;
} } else if (item === "hiddenBoss") {
else if (item === 'boss') { character.isHiddenBoss = true;
character.isBoss = true; } else if (item === "forbidai") {
} character.isAiForbidden = true;
else if (item === 'bossallowed') { } else if (item === "stonehidden") {
character.isBossAllowed = true; character.isHiddenInStoneMode = true;
} } else if (item === "hiddenSkill") {
else if (item === 'hiddenBoss') { character.hasHiddenSkill = true;
character.isHiddenBoss = true; } else if (item.startsWith("border:")) {
} character.groupBorder = item.slice(7);
else if (item === 'forbidai') { } else if (item.startsWith("dualside:")) {
character.isAiForbidden = true; character.dualSideCharacter = item.slice(9);
} } else if (item.startsWith("doublegroup:")) {
else if (item === 'stonehidden') { character.doubleGroup = item.slice(12).split(":");
character.isHiddenInStoneMode = true; }
} }
else if (item === 'hiddenSkill') { }
character.hasHiddenSkill = true; /**
} * @deprecated
else if (item.startsWith('border:')) { */
character.groupBorder = item.slice(7); get 0() {
} return this.sex;
else if (item.startsWith('dualside:')) { }
character.dualSideCharacter = item.slice(9); set 0(sex) {
} this.sex = sex;
else if (item.startsWith('doublegroup:')) { }
character.doubleGroup = item.slice(12).split(":")
}
}
};
/**
* @deprecated
*/
get 0() {
return this.sex;
};
set 0(sex) {
this.sex = sex;
};
/** /**
* @deprecated * @deprecated
*/ */
get 1() { get 1() {
return this.group; return this.group;
}; }
set 1(group) { set 1(group) {
this.group = group; this.group = group;
}; }
/** /**
* @deprecated * @deprecated
*/ */
get 2() { get 2() {
if (this.hujia > 0) return `${this.hp}/${this.maxHp}/${this.hujia}`; if (this.hujia > 0) return `${this.hp}/${this.maxHp}/${this.hujia}`;
else if (this.hp !== this.maxHp) return `${this.hp}/${this.maxHp}`; else if (this.hp !== this.maxHp) return `${this.hp}/${this.maxHp}`;
return this.hp; return this.hp;
}; }
set 2(hp) { set 2(hp) {
this.hp = get.infoHp(hp); this.hp = get.infoHp(hp);
this.maxHp = get.infoMaxHp(hp); this.maxHp = get.infoMaxHp(hp);
this.hujia = get.infoHujia(hp); this.hujia = get.infoHujia(hp);
}; }
/** /**
* @deprecated * @deprecated
*/ */
get 3() { get 3() {
return this.skills; return this.skills;
}; }
set 3(skills) { set 3(skills) {
this.skills = skills; this.skills = skills;
}; }
/** /**
* @deprecated * @deprecated
*/ */
get 4() { get 4() {
return this.trashBin; return this.trashBin;
}; }
set 4(trashBin) { set 4(trashBin) {
this.trashBin = trashBin; this.trashBin = trashBin;
}; }
} }