From 3a9df5bcc3689444d349fb2e6bff98e195cdebd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Thu, 26 Jun 2025 21:10:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E4=BE=BF=E6=94=B9=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E7=B1=BB=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-skill-parser.js | 127 ++++++++++++++++++++--------------------- script.js | 7 ++- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/script-skill-parser.js b/script-skill-parser.js index 548c9052..a85f4bcf 100644 --- a/script-skill-parser.js +++ b/script-skill-parser.js @@ -1,62 +1,61 @@ let merge_skill = false; -const Attributes = { - /*0: "Fire", - 1: "Water", - 2: "Wood", - 3: "Light", - 4: "Dark", - 5: "Heart", - 6: "Jammer", - 7: "Poison", - 8: "MPoison", - 9: "Bomb",*/ - Fire: 0, - Water: 1, - Wood: 2, - Light: 3, - Dark: 4, - Heart: 5, - Jammer: 6, - Poison: 7, - MPoison: 8, - Bomb: 9, +class Attributes { + static "0" = "Fire"; + static "1" = "Water"; + static "2" = "Wood"; + static "3" = "Light"; + static "4" = "Dark"; + static "5" = "Heart"; + static "6" = "Jammer"; + static "7" = "Poison"; + static "8" = "MPoison"; + static "9" = "Bomb"; + static Fire = 0; + static Water = 1; + static Wood = 2; + static Light = 3; + static Dark = 4; + static Heart = 5; + static Jammer = 6; + static Poison = 7; + static MPoison = 8; + static Bomb = 9; + static get all() { + return [ + Attributes.Fire, + Attributes.Water, + Attributes.Wood, + Attributes.Light, + Attributes.Dark + ]; + } + static get _6color() { + return [ + Attributes.Fire, + Attributes.Water, + Attributes.Wood, + Attributes.Light, + Attributes.Dark, + Attributes.Heart + ]; + } + static get orbs() { + return [ + Attributes.Fire, + Attributes.Water, + Attributes.Wood, + Attributes.Light, + Attributes.Dark, + Attributes.Heart, + Attributes.Jammer, + Attributes.Poison, + Attributes.MPoison, + Attributes.Bomb + ]; + } } -Object.entries(Attributes).forEach(([name, oid])=>Attributes[oid] = name) -Attributes.all = function () { - return [ - this.Fire, - this.Water, - this.Wood, - this.Light, - this.Dark - ]; -} -Attributes._6color = function () { - return [ - this.Fire, - this.Water, - this.Wood, - this.Light, - this.Dark, - this.Heart - ]; -} -Attributes.orbs = function () { - return [ - this.Fire, - this.Water, - this.Wood, - this.Light, - this.Dark, - this.Heart, - this.Jammer, - this.Poison, - this.MPoison, - this.Bomb, - ]; -} //代码来自于 https://www.jianshu.com/p/3644833bca33 function isEqual(obj1,obj2) { //判断是否是对象或数组 @@ -863,7 +862,7 @@ const c = { return { hp: { min: min / 100, max: max / 100 } }; }, exact: function (type, value, attrs, multiple = false) { - if (attrs === void 0) { attrs = Attributes.all(); } + if (attrs === void 0) { attrs = Attributes.all; } return { exact: { type: type, value: value, attrs: attrs, multiple: multiple} }; }, combos: function (min) { @@ -1417,7 +1416,7 @@ const skillObjectParsers = { const attrs = [attrs1, attrs2, attrs3, attrs4].filter(Boolean); return powerUp(null, null, p.scaleMatchAttrs(attrs.flatMap(Bin.unflags), min, bonus ? attrs.length : min, [mul, 100], [bonus ?? 0, 0]), null, v.percent(percent)); }, - [172]() { return setOrbState(Attributes.orbs(), 'unlocked'); }, + [172]() { return setOrbState(Attributes.orbs, 'unlocked'); }, [173](turns, attrAbsorb, comboAbsorb, damageAbsorb) { return activeTurns(turns, voidEnemyBuff( [ @@ -1488,7 +1487,7 @@ const skillObjectParsers = { }, [189]() { return [ - setOrbState(Attributes.orbs(), 'unlocked'), + setOrbState(Attributes.orbs, 'unlocked'), boardChange([0,1,2,3]), autoPath(3), ]; @@ -1748,7 +1747,7 @@ const skillObjectParsers = { [257]() { return [ - setOrbState(Attributes.orbs(), 'unlocked'), + setOrbState(Attributes.orbs, 'unlocked'), boardChange([0,1,2,3,4,5]), autoPath(5), ]; @@ -1764,7 +1763,7 @@ const skillObjectParsers = { [259](percent) { return breakingShield(v.xShield(percent)); }, [260](skillStage, voiceId) { return skillPlayVoice(skillStage, voiceId); }, [261](percent) { return gravity(v.xCHP(percent), 'single'); }, - [262](count) { return setOrbState(Attributes.orbs(), 'nail', {count: v.constant(count)}); }, + [262](count) { return setOrbState(Attributes.orbs, 'nail', {count: v.constant(count)}); }, [263](turns, cap, attr, type) { //按属性改变伤害上限主动技 return activeTurns(turns, increaseDamageCapacity(cap * 1e8, void 0, Bin.unflags(attr), Bin.unflags(type)) @@ -2642,7 +2641,7 @@ function renderSkill(skill, option = {}) if (condition) dict.condition = renderCondition(condition); let targetDict = {}, attrs_types = []; - if (attrs?.length && !isEqual(attrs, Attributes.all())) + if (attrs?.length && !isEqual(attrs, Attributes.all)) { targetDict.attrs = renderAttrs(attrs || [], {affix: attrs?.filter(attr=> attr !== 5)?.length}); attrs_types.push(targetDict.attrs); @@ -2762,7 +2761,7 @@ function renderSkill(skill, option = {}) } let attrs_types = []; - if (attrs?.length && !isEqual(attrs, Attributes.all())) + if (attrs?.length && !isEqual(attrs, Attributes.all)) { dict.attrs = renderAttrs(attrs || [], {affix: attrs?.filter(attr=> attr !== 5)?.length}); attrs_types.push(dict.attrs); @@ -2823,7 +2822,7 @@ function renderSkill(skill, option = {}) }; let targetDict = {}, attrs_types = []; - if (attrs?.length && !isEqual(attrs, Attributes.all())) + if (attrs?.length && !isEqual(attrs, Attributes.all)) { targetDict.attrs = renderAttrs(attrs || [], {affix: attrs?.filter(attr=> attr !== 5)?.length}); attrs_types.push(targetDict.attrs); @@ -3029,7 +3028,7 @@ function renderAttrs(attrs, option = {}) { const tsp = localTranslating.skill_parse; let contentFrg; - if (isEqual(attrs, Attributes.all())) + if (isEqual(attrs, Attributes.all)) { contentFrg = tsp.attrs.all(); } diff --git a/script.js b/script.js index 4e626ba0..ebcf24a2 100644 --- a/script.js +++ b/script.js @@ -116,6 +116,7 @@ DBOpenRequest.onupgradeneeded = function(event) { }; }; class Plus extends Array { + static maxValue = 297; constructor(hp = 0 , atk = 0, rcv = 0) { super(3);//建立 Array if (Array.isArray(hp) && hp.length >= 3 //传入数组的形式 @@ -135,7 +136,7 @@ class Plus extends Array { } set hp(num) { if (!Number.isInteger(num)) throw new TypeError("传入的 HP +值 不是整数"); - if (num < 0 || num > 99) throw new RangeError("HP +值应为 0-99 之间的整数"); + if (num < 0 || num > Plus.maxValue) throw new RangeError("HP +值应为 0-99 之间的整数"); this[0] = num; } get atk() { @@ -143,7 +144,7 @@ class Plus extends Array { } set atk(num) { if (!Number.isInteger(num)) throw new TypeError("传入的 ATK +值 不是整数"); - if (num < 0 || num > 99) throw new RangeError("ATK +值应为 0-99 之间的整数"); + if (num < 0 || num > Plus.maxValue) throw new RangeError("ATK +值应为 0-99 之间的整数"); this[1] = num; } get rcv() { @@ -151,7 +152,7 @@ class Plus extends Array { } set rcv(num) { if (!Number.isInteger(num)) throw new TypeError("传入的 RCV +值 不是整数"); - if (num < 0 || num > 99) throw new RangeError("RCV +值应为 0-99 之间的整数"); + if (num < 0 || num > Plus.maxValue) throw new RangeError("RCV +值应为 0-99 之间的整数"); this[2] = num; } get is297() {