给lib.characterPack增加二层Proxy
This commit is contained in:
parent
2244333914
commit
2797d1eed4
|
@ -2263,8 +2263,8 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
|
||||||
name = i + "_stonecharacter";
|
name = i + "_stonecharacter";
|
||||||
lib.card[name] = {
|
lib.card[name] = {
|
||||||
image: "mode/stone/character/" + i,
|
image: "mode/stone/character/" + i,
|
||||||
stoneact: lib.character[i].stoneModeData[0],
|
stoneact: lib.character[i].extraModeData[0],
|
||||||
career: lib.character[i].stoneModeData[2] || null,
|
career: lib.character[i].extraModeData[2] || null,
|
||||||
};
|
};
|
||||||
for (j in lib.element.stonecharacter) {
|
for (j in lib.element.stonecharacter) {
|
||||||
lib.card[name][j] = lib.element.stonecharacter[j];
|
lib.card[name][j] = lib.element.stonecharacter[j];
|
||||||
|
@ -2275,14 +2275,14 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
|
||||||
lib.card[name].stonehidden = true;
|
lib.card[name].stonehidden = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!lib.character[i].stoneModeData[2]) {
|
if (!lib.character[i].extraModeData[2]) {
|
||||||
if (lib.character[i].stoneModeData[0] < 3) {
|
if (lib.character[i].extraModeData[0] < 3) {
|
||||||
list.push(name);
|
list.push(name);
|
||||||
} else {
|
} else {
|
||||||
list2.push(name);
|
list2.push(name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list3[lib.character[i].stoneModeData[2]].push(name);
|
list3[lib.character[i].extraModeData[2]].push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_status.mode == "deck") {
|
if (_status.mode == "deck") {
|
||||||
|
@ -7234,8 +7234,8 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
|
||||||
if (
|
if (
|
||||||
lib.character[i].isFellowInStoneMode &&
|
lib.character[i].isFellowInStoneMode &&
|
||||||
!lib.character[i].isHiddenInStoneMode &&
|
!lib.character[i].isHiddenInStoneMode &&
|
||||||
lib.character[i].stoneModeData &&
|
lib.character[i].extraModeData &&
|
||||||
lib.character[i].stoneModeData[0] == num
|
lib.character[i].extraModeData[0] == num
|
||||||
) {
|
) {
|
||||||
list.push(i);
|
list.push(i);
|
||||||
}
|
}
|
||||||
|
@ -7789,8 +7789,8 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
|
||||||
if (
|
if (
|
||||||
lib.character[i].isFellowInStoneMode &&
|
lib.character[i].isFellowInStoneMode &&
|
||||||
!lib.character[i].isHiddenInStoneMode &&
|
!lib.character[i].isHiddenInStoneMode &&
|
||||||
lib.character[i].stoneModeData &&
|
lib.character[i].extraModeData &&
|
||||||
lib.character[i].stoneModeData[0] == 1
|
lib.character[i].extraModeData[0] == 1
|
||||||
) {
|
) {
|
||||||
list.push(i);
|
list.push(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,8 +166,8 @@ Reflect.defineProperty(HTMLDivElement.prototype, "setBackground", {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let imgPrefixUrl;
|
let imgPrefixUrl;
|
||||||
if (!modeimage && nameinfo && nameinfo[4]) {
|
if (!modeimage && nameinfo && nameinfo.trashBin) {
|
||||||
for (const value of nameinfo[4]) {
|
for (const value of nameinfo.trashBin) {
|
||||||
if (value.startsWith("img:")) {
|
if (value.startsWith("img:")) {
|
||||||
imgPrefixUrl = value.slice(4);
|
imgPrefixUrl = value.slice(4);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -96,10 +96,10 @@ export class Character {
|
||||||
**/
|
**/
|
||||||
isAiForbidden = false;
|
isAiForbidden = false;
|
||||||
/**
|
/**
|
||||||
* 武将牌在炉石模式下的特殊信息
|
* 武将牌在炉石模式/挑战模式下的特殊信息
|
||||||
* @type { array|undefined }
|
* @type { array|undefined }
|
||||||
**/
|
**/
|
||||||
stoneModeData;
|
extraModeData;
|
||||||
/**
|
/**
|
||||||
* 武将牌是否为炉石模式下的随从
|
* 武将牌是否为炉石模式下的随从
|
||||||
* @type { boolean }
|
* @type { boolean }
|
||||||
|
@ -162,7 +162,7 @@ export class Character {
|
||||||
this.hujia = get.infoHujia(data[2]);
|
this.hujia = get.infoHujia(data[2]);
|
||||||
this.skills = get.copy(data[3] || []);
|
this.skills = get.copy(data[3] || []);
|
||||||
if (data[4]) Character.convertTrashToProperties(this, data[4]);
|
if (data[4]) Character.convertTrashToProperties(this, data[4]);
|
||||||
if (data[5]) this.stoneModeData = data[5];
|
if (data.length > 5) this.extraModeData = data[5];
|
||||||
} 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;
|
||||||
|
@ -350,9 +350,9 @@ export class Character {
|
||||||
}
|
}
|
||||||
|
|
||||||
get 5(){
|
get 5(){
|
||||||
return this.stoneModeData;
|
return this.extraModeData;
|
||||||
}
|
}
|
||||||
set 5(stoneData){
|
set 5(stoneData){
|
||||||
this.stoneModeData = stoneData;
|
this.extraModeData = stoneData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3330,7 +3330,7 @@ export class Player extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
for (var j in lib.characterPack[list[i]]) {
|
for (var j in lib.characterPack[list[i]]) {
|
||||||
if (lib.characterPack[list[i]][j][3].includes(name)) {
|
if (lib.characterPack[list[i]][j].skills.includes(name)) {
|
||||||
name = j;
|
name = j;
|
||||||
stop = true;
|
stop = true;
|
||||||
break;
|
break;
|
||||||
|
@ -3341,7 +3341,7 @@ export class Player extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lib.character[this.name2] && lib.character[this.name2][3].includes(skill)) {
|
if (lib.character[this.name2] && lib.character[this.name2].skills.includes(skill)) {
|
||||||
this.setAvatarQueue(this.name2, [name]);
|
this.setAvatarQueue(this.name2, [name]);
|
||||||
} else {
|
} else {
|
||||||
this.setAvatarQueue(this.name, [name]);
|
this.setAvatarQueue(this.name, [name]);
|
||||||
|
|
|
@ -69,7 +69,13 @@ export class Library {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Reflect.set(target, prop, newValue);
|
const newPack = new Proxy({}, {
|
||||||
|
set(target, prop, newValue) {
|
||||||
|
return Reflect.set(target, prop, get.convertedCharacter(newValue));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.assign(newPack, newValue);
|
||||||
|
return Reflect.set(target, prop, newPack);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -4947,7 +4953,7 @@ export class Library {
|
||||||
storage.translate[i] = mode.translate[i];
|
storage.translate[i] = mode.translate[i];
|
||||||
}
|
}
|
||||||
for (var i in mode.jiangeboss) {
|
for (var i in mode.jiangeboss) {
|
||||||
if (mode.jiangeboss[i][4].includes("bossallowed")) {
|
if (mode.jiangeboss[i].isBossAllowed) {
|
||||||
storage.versus[i] = mode.jiangeboss[i];
|
storage.versus[i] = mode.jiangeboss[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4959,7 +4965,7 @@ export class Library {
|
||||||
storage.translate[i] = mode.translate[i];
|
storage.translate[i] = mode.translate[i];
|
||||||
}
|
}
|
||||||
for (var i in mode.characterPack.mode_boss) {
|
for (var i in mode.characterPack.mode_boss) {
|
||||||
if (mode.characterPack.mode_boss[i][4].includes("bossallowed")) {
|
if (mode.characterPack.mode_boss[i].isBossAllowed) {
|
||||||
storage.boss[i] = mode.characterPack.mode_boss[i];
|
storage.boss[i] = mode.characterPack.mode_boss[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3287,15 +3287,7 @@ export class Create {
|
||||||
group: ui.create.div(".identity", node),
|
group: ui.create.div(".identity", node),
|
||||||
intro: ui.create.div(".intro", node),
|
intro: ui.create.div(".intro", node),
|
||||||
};
|
};
|
||||||
var infoitem = lib.character[item];
|
var infoitem = get.character(item);
|
||||||
if (!infoitem) {
|
|
||||||
for (var itemx in lib.characterPack) {
|
|
||||||
if (lib.characterPack[itemx][item]) {
|
|
||||||
infoitem = lib.characterPack[itemx][item];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node.node.name.innerHTML = get.slimName(item);
|
node.node.name.innerHTML = get.slimName(item);
|
||||||
if (
|
if (
|
||||||
lib.config.buttoncharacter_style == "default" ||
|
lib.config.buttoncharacter_style == "default" ||
|
||||||
|
@ -3313,11 +3305,11 @@ export class Create {
|
||||||
"raw"
|
"raw"
|
||||||
);
|
);
|
||||||
ui.create.div(node.node.hp);
|
ui.create.div(node.node.hp);
|
||||||
var hp = get.infoHp(infoitem[2]),
|
var hp = infoitem.hp,
|
||||||
maxHp = get.infoMaxHp(infoitem[2]),
|
maxHp = infoitem.maxHp,
|
||||||
hujia = get.infoHujia(infoitem[2]);
|
hujia = infoitem.hujia;
|
||||||
var str = get.numStr(hp);
|
var str = get.numStr(hp);
|
||||||
if (hp != maxHp) {
|
if (hp !== maxHp) {
|
||||||
str += "/";
|
str += "/";
|
||||||
str += get.numStr(maxHp);
|
str += get.numStr(maxHp);
|
||||||
}
|
}
|
||||||
|
@ -3334,11 +3326,11 @@ export class Create {
|
||||||
ui.create.div(".text", get.numStr(hujia), node.node.hp);
|
ui.create.div(".text", get.numStr(hujia), node.node.hp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var hp = get.infoHp(infoitem[2]);
|
var hp = infoitem.hp,
|
||||||
var maxHp = get.infoMaxHp(infoitem[2]);
|
maxHp = infoitem.maxHp,
|
||||||
var shield = get.infoHujia(infoitem[2]);
|
shield = infoitem.hujia;
|
||||||
if (maxHp > 14) {
|
if (maxHp > 14) {
|
||||||
if (typeof infoitem[2] == "string")
|
if (hp !== maxHp || shield > 0)
|
||||||
node.node.hp.innerHTML = infoitem[2];
|
node.node.hp.innerHTML = infoitem[2];
|
||||||
else node.node.hp.innerHTML = get.numStr(infoitem[2]);
|
else node.node.hp.innerHTML = get.numStr(infoitem[2]);
|
||||||
node.node.hp.classList.add("text");
|
node.node.hp.classList.add("text");
|
||||||
|
|
|
@ -159,7 +159,7 @@ export const characterPackMenu = function (connectMenu) {
|
||||||
var alterableCharacters = [];
|
var alterableCharacters = [];
|
||||||
var charactersToAlter = [];
|
var charactersToAlter = [];
|
||||||
for (var i in _info) {
|
for (var i in _info) {
|
||||||
const characterInfo = get.convertedCharacter( _info[i]);
|
const characterInfo = _info[i];
|
||||||
if (characterInfo.isUnseen) continue;
|
if (characterInfo.isUnseen) continue;
|
||||||
if (connectMenu && lib.connectBanned.includes(i)) continue;
|
if (connectMenu && lib.connectBanned.includes(i)) continue;
|
||||||
list.push(i);
|
list.push(i);
|
||||||
|
|
Loading…
Reference in New Issue