From 2797d1eed4849acd74daca2d132b5452cac5d342 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Thu, 25 Apr 2024 17:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99lib.characterPack=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=8C=E5=B1=82Proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mode/stone.js | 18 ++++++------- noname/init/polyfill.js | 4 +-- noname/library/element/character.js | 10 +++---- noname/library/element/player.js | 4 +-- noname/library/index.js | 12 ++++++--- noname/ui/create/index.js | 26 +++++++------------ .../ui/create/menu/pages/characterPackMenu.js | 2 +- 7 files changed, 37 insertions(+), 39 deletions(-) diff --git a/mode/stone.js b/mode/stone.js index 3add5cd4c..1f2b142f7 100644 --- a/mode/stone.js +++ b/mode/stone.js @@ -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); } diff --git a/noname/init/polyfill.js b/noname/init/polyfill.js index 72a18d34d..1c685b50b 100644 --- a/noname/init/polyfill.js +++ b/noname/init/polyfill.js @@ -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; diff --git a/noname/library/element/character.js b/noname/library/element/character.js index 772693efb..cf378a11a 100644 --- a/noname/library/element/character.js +++ b/noname/library/element/character.js @@ -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; } } diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 15a0bfbda..c46ab9447 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -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]); diff --git a/noname/library/index.js b/noname/library/index.js index 755a30a55..b89b25cad 100644 --- a/noname/library/index.js +++ b/noname/library/index.js @@ -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]; } } diff --git a/noname/ui/create/index.js b/noname/ui/create/index.js index 8c9318851..b481146ff 100644 --- a/noname/ui/create/index.js +++ b/noname/ui/create/index.js @@ -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"); diff --git a/noname/ui/create/menu/pages/characterPackMenu.js b/noname/ui/create/menu/pages/characterPackMenu.js index b6958bec6..10d8f9921 100644 --- a/noname/ui/create/menu/pages/characterPackMenu.js +++ b/noname/ui/create/menu/pages/characterPackMenu.js @@ -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);