给lib.characterPack增加二层Proxy

This commit is contained in:
Spmario233 2024-04-25 17:42:05 +08:00
parent 2244333914
commit 2797d1eed4
7 changed files with 37 additions and 39 deletions

View File

@ -2263,8 +2263,8 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
name = i + "_stonecharacter";
lib.card[name] = {
image: "mode/stone/character/" + i,
stoneact: lib.character[i].stoneModeData[0],
career: lib.character[i].stoneModeData[2] || null,
stoneact: lib.character[i].extraModeData[0],
career: lib.character[i].extraModeData[2] || null,
};
for (j in lib.element.stonecharacter) {
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;
continue;
}
if (!lib.character[i].stoneModeData[2]) {
if (lib.character[i].stoneModeData[0] < 3) {
if (!lib.character[i].extraModeData[2]) {
if (lib.character[i].extraModeData[0] < 3) {
list.push(name);
} else {
list2.push(name);
}
} else {
list3[lib.character[i].stoneModeData[2]].push(name);
list3[lib.character[i].extraModeData[2]].push(name);
}
}
if (_status.mode == "deck") {
@ -7234,8 +7234,8 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
if (
lib.character[i].isFellowInStoneMode &&
!lib.character[i].isHiddenInStoneMode &&
lib.character[i].stoneModeData &&
lib.character[i].stoneModeData[0] == num
lib.character[i].extraModeData &&
lib.character[i].extraModeData[0] == num
) {
list.push(i);
}
@ -7789,8 +7789,8 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
if (
lib.character[i].isFellowInStoneMode &&
!lib.character[i].isHiddenInStoneMode &&
lib.character[i].stoneModeData &&
lib.character[i].stoneModeData[0] == 1
lib.character[i].extraModeData &&
lib.character[i].extraModeData[0] == 1
) {
list.push(i);
}

View File

@ -166,8 +166,8 @@ Reflect.defineProperty(HTMLDivElement.prototype, "setBackground", {
}
}
let imgPrefixUrl;
if (!modeimage && nameinfo && nameinfo[4]) {
for (const value of nameinfo[4]) {
if (!modeimage && nameinfo && nameinfo.trashBin) {
for (const value of nameinfo.trashBin) {
if (value.startsWith("img:")) {
imgPrefixUrl = value.slice(4);
break;

View File

@ -96,10 +96,10 @@ export class Character {
**/
isAiForbidden = false;
/**
* 武将牌在炉石模式下的特殊信息
* 武将牌在炉石模式/挑战模式下的特殊信息
* @type { array|undefined }
**/
stoneModeData;
extraModeData;
/**
* 武将牌是否为炉石模式下的随从
* @type { boolean }
@ -162,7 +162,7 @@ export class Character {
this.hujia = get.infoHujia(data[2]);
this.skills = get.copy(data[3] || []);
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)) {
Object.assign(this, data);
if (typeof this.maxHp !== "number") this.maxHp = this.hp;
@ -350,9 +350,9 @@ export class Character {
}
get 5(){
return this.stoneModeData;
return this.extraModeData;
}
set 5(stoneData){
this.stoneModeData = stoneData;
this.extraModeData = stoneData;
}
}

View File

@ -3330,7 +3330,7 @@ export class Player extends HTMLDivElement {
}
for (var i = 0; i < list.length; 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;
stop = true;
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]);
} else {
this.setAvatarQueue(this.name, [name]);

View File

@ -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];
}
for (var i in mode.jiangeboss) {
if (mode.jiangeboss[i][4].includes("bossallowed")) {
if (mode.jiangeboss[i].isBossAllowed) {
storage.versus[i] = mode.jiangeboss[i];
}
}
@ -4959,7 +4965,7 @@ export class Library {
storage.translate[i] = mode.translate[i];
}
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];
}
}

View File

@ -3287,15 +3287,7 @@ export class Create {
group: ui.create.div(".identity", node),
intro: ui.create.div(".intro", node),
};
var infoitem = lib.character[item];
if (!infoitem) {
for (var itemx in lib.characterPack) {
if (lib.characterPack[itemx][item]) {
infoitem = lib.characterPack[itemx][item];
break;
}
}
}
var infoitem = get.character(item);
node.node.name.innerHTML = get.slimName(item);
if (
lib.config.buttoncharacter_style == "default" ||
@ -3313,11 +3305,11 @@ export class Create {
"raw"
);
ui.create.div(node.node.hp);
var hp = get.infoHp(infoitem[2]),
maxHp = get.infoMaxHp(infoitem[2]),
hujia = get.infoHujia(infoitem[2]);
var hp = infoitem.hp,
maxHp = infoitem.maxHp,
hujia = infoitem.hujia;
var str = get.numStr(hp);
if (hp != maxHp) {
if (hp !== maxHp) {
str += "/";
str += get.numStr(maxHp);
}
@ -3334,11 +3326,11 @@ export class Create {
ui.create.div(".text", get.numStr(hujia), node.node.hp);
}
} else {
var hp = get.infoHp(infoitem[2]);
var maxHp = get.infoMaxHp(infoitem[2]);
var shield = get.infoHujia(infoitem[2]);
var hp = infoitem.hp,
maxHp = infoitem.maxHp,
shield = infoitem.hujia;
if (maxHp > 14) {
if (typeof infoitem[2] == "string")
if (hp !== maxHp || shield > 0)
node.node.hp.innerHTML = infoitem[2];
else node.node.hp.innerHTML = get.numStr(infoitem[2]);
node.node.hp.classList.add("text");

View File

@ -159,7 +159,7 @@ export const characterPackMenu = function (connectMenu) {
var alterableCharacters = [];
var charactersToAlter = [];
for (var i in _info) {
const characterInfo = get.convertedCharacter( _info[i]);
const characterInfo = _info[i];
if (characterInfo.isUnseen) continue;
if (connectMenu && lib.connectBanned.includes(i)) continue;
list.push(i);