From a4bd5478ac8c01ab89d9878d110970ba2c47d02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Fri, 13 Aug 2021 03:21:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E6=9D=A1=E4=BB=B6=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E5=B0=B1=E9=9D=9E=E5=B8=B8=E5=A4=8D=E6=9D=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- languages/zh-CN.js | 45 +++++++++-- script-skill-parser.js | 172 +++++++++++++++++++++++++++++++++++------ style.css | 4 + 3 files changed, 192 insertions(+), 29 deletions(-) diff --git a/languages/zh-CN.js b/languages/zh-CN.js index b546f304..e17aa56b 100644 --- a/languages/zh-CN.js +++ b/languages/zh-CN.js @@ -58,7 +58,7 @@ board7x6: tp`【${'icon'}7×6版面】`, counter_attack: tp`受到${'target'}攻击时,${'prob'}进行受到伤害${'value'}的${'attr'}${'icon'}反击`, change_orbs: tp`${'from'}→${'to'}`, - generate_orbs: tp`${'exclude'}生成${'orbs'}各${'count'}个`, + generate_orbs: tp`${'exclude'}生成${'orbs'}各${'value'}个`, fixed_orbs: tp`在${'position'}产生${'orbs'}`, orb_drop_increase: tp`${'orbs'}的掉落率提高到${'value'}`, attr_absorb: tp`${'icon'}属性吸收`, @@ -68,13 +68,31 @@ void_enemy_buff: tp`敌人的 ${'buff'} 无效化`, change_attribute: tp`将${'target'}变为${'attrs'}`, set_orb_state_enhanced: tp`强化${'orbs'}(每颗宝珠效力增加${'value'})`, - set_orb_state_locked: tp`将${'orbs'}锁定${'count'}`, + set_orb_state_locked: tp`将${'orbs'}锁定${'value'}`, set_orb_state_unlocked: tp`${'icon'}解除所有宝珠的锁定状态`, set_orb_state_bound: tp`无法消除${'orbs'}`, rate_multiply: tp`作为队长进入地下城时,${'rate'}变为${'value'}`, rate_multiply_drop: tp`${'icon'}怪物蛋掉落率`, rate_multiply_coin: tp`${'icon'}金币掉落率`, rate_multiply_exp: tp`${'icon'}等级经验倍率`, + reduce_damage: tp`${'condition'}受到的${'attrs'}伤害${'icon'}减少${'value'}`, + }, + cond: { + unknown: tp`[ 未知条件 ]`, + hp_equal: tp`${'hp'} == ${'min'} 时`, + hp_less_or_equal: tp`${'hp'} ≤ ${'max'} 时`, + hp_greater_or_equal: tp`${'hp'} ≥ ${'min'} 时`, + hp_belong_to_range: tp`${'hp'} ∈ [${'min'},${'max'}] 时`, + use_skill: tp`使用技能时`, + multi_player: tp`协力时`, + remain_orbs: tp`剩余宝珠 ≤ ${'value'} 时`, + exact_combo: tp`≥ ${'value'}连击 时`, + exact_match_length: tp`相连消除 ≥ ${'value'}${'orbs'}时`, + exact_match_enhanced: tp`并且其中包含至少一个强化宝珠`, + + compo_type_card: tp`队伍中同时存在 ${'ids'} 时`, + compo_type_series: tp`队员组成全为 ${'ids'} 系列时`, + compo_type_evolution: tp`队员组成全为 ${'ids'} 进化时`, }, position: { top: tp`上方第${'pos'}横行`, @@ -126,6 +144,7 @@ range_hyphen: tp`~`, //范围连字符 affix_attr: tp`${'cotent'}属性`, //词缀-属性 affix_orb: tp`${'cotent'}宝珠`, //词缀-宝珠 + affix_type: tp`${'cotent'}类型`, //词缀-类型 affix_exclude: tp`${'cotent'}以外`, //词缀-属性 }, attrs: { @@ -136,9 +155,25 @@ [4]: tp`${'icon'}暗`, [5]: tp`${'icon'}回复`, [6]: tp`${'icon'}空`, + all: tp`所有`, self: tp`${'icon'}自身属性`, fixed: tp`${'icon'}无视防御固定`, }, + types: { + [0]: tp`${'icon'}进化用`, + [1]: tp`${'icon'}平衡`, + [2]: tp`${'icon'}体力`, + [3]: tp`${'icon'}回复`, + [4]: tp`${'icon'}龙`, + [5]: tp`${'icon'}神`, + [6]: tp`${'icon'}攻击`, + [7]: tp`${'icon'}恶魔`, + [8]: tp`${'icon'}攻击`, + [9]: tp`${'icon'}特别保护`, + [12]: tp`${'icon'}能力觉醒用`, + [14]: tp`${'icon'}强化合成用`, + [15]: tp`${'icon'}贩卖用`, + }, orbs: { [0]: tp`${'icon'}火`, [1]: tp`${'icon'}水`, @@ -150,8 +185,8 @@ [7]: tp`${'icon'}毒`, [8]: tp`${'icon'}剧毒`, [9]: tp`${'icon'}炸弹`, - all: tp`${'icon'}所有`, - any: tp`${'icon'}任何`, + all: tp`所有`, + any: tp`任何`, }, }, } @@ -1361,7 +1396,7 @@ function parseSkillDescription(skill) { lnk.textContent = cid; if (idx < arr.length-1) lnk.insertAdjacentText('afterend', "、");; }); - fragment.appendChild(document.createTextNode(`合作角色时,所有宠物的${getFixedHpAtkRcvString({hp:sk[3],atk:sk[4],rcv:sk[5]})}`)); + fragment.appendChild(document.createTextNode(`系列角色时,所有宠物的${getFixedHpAtkRcvString({hp:sk[3],atk:sk[4],rcv:sk[5]})}`)); return fragment; break; case 176: diff --git a/script-skill-parser.js b/script-skill-parser.js index 5722f2c2..38c2f8c0 100644 --- a/script-skill-parser.js +++ b/script-skill-parser.js @@ -79,7 +79,43 @@ Attributes.orbs = function () { this.Bomb, ]; } +//代码来自于 https://www.jianshu.com/p/3644833bca33 +function isEqual(obj1,obj2) { + //判断是否是对象或数组 + function isObject(obj) { + return typeof obj === 'object' && obj !== null; + } + // 两个数据有任何一个不是对象或数组 + if (!isObject(obj1) || !isObject(obj2)) { + // 值类型(注意:参与equal的一般不会是函数) + return obj1 === obj2; + } + // 如果传的两个参数都是同一个对象或数组 + if (obj1 === obj2) { + return true; + } + // 两个都是对象或数组,而且不相等 + // 1.先比较obj1和obj2的key的个数,是否一样 + const obj1Keys = Object.keys(obj1); + const obj2Keys = Object.keys(obj2); + if (obj1Keys.length !== obj2Keys.length) { + return false; + } + + // 如果key的个数相等,就是第二步 + // 2.以obj1为基准,和obj2依次递归比较 + for (let key in obj1) { + // 比较当前key的value --- 递归 + const res = isEqual(obj1[key], obj2[key]); + if (!res) { + return false; + } + } + + // 3.全相等 + return true +} class Board { #rowCount = 6; @@ -954,6 +990,7 @@ const parsers = { [202](id) { return henshin(id); }, + [203](evotype, hp, atk, rcv) { return powerUp(null, null, p.mul({ hp, atk, rcv }), c.compo('evolution', [evotype])); }, [215](turns, attrs) { return activeTurns(turns, setOrbState(flags(attrs), 'bound')); }, [218](turns) { return skillBoost(v.constant(-turns)); }, @@ -1333,7 +1370,7 @@ function renderSkill(skill, option = {}) dict = { exclude: exclude.length ? tsp.word.affix_exclude({cotent: renderOrbs(exclude)}) : void 0, orbs: renderOrbs(orbs), - count: count, + value: count, }; let board = new Board(); board.generateOrbs(orbs, count); @@ -1436,7 +1473,7 @@ function renderSkill(skill, option = {}) } case "locked":{ if (arg.count.value < 42) - dict.count = renderValue(arg.count, {unit: tsp.unit.unit}); + dict.value = renderValue(arg.count, {unit: tsp.unit.unit}); frg.ap(tsp.skill.set_orb_state_locked(dict)); break; } @@ -1461,6 +1498,17 @@ function renderSkill(skill, option = {}) frg.ap(tsp.skill.rate_multiply(dict)); break; } + case SkillKinds.ReduceDamage: { + let attrs = skill.attrs, percent = skill.percent, condition = skill.condition; + dict = { + icon: createIcon(skill.kind), + attrs: renderAttrs(attrs, {affix: true}), + value: renderValue(percent, {percent: true}), + }; + if (condition) dict.condition = renderCondition(condition); + frg.ap(tsp.skill.reduce_damage(dict)); + break; + } /* case SkillKinds.ReduceDamage: { @@ -1523,13 +1571,21 @@ function renderAttrs(attrs, option = {}) { if (typeof localTranslating == "undefined") return frg; const tsp = localTranslating.skill_parse; - const contentFrg = attrs.map(attr => { - const icon = document.createElement("icon"); - icon.className = "attr"; - icon.setAttribute("data-attr-icon",attr); - return tsp.attrs[attr]({icon: icon}); - }) - .nodeJoin(tsp.word.slight_pause()); + let contentFrg; + if (isEqual(attrs, Attributes.all())) + { + contentFrg = option.any ? tsp.attrs.any() : tsp.attrs.all(); + } + else + { + contentFrg = attrs.map(attr => { + const icon = document.createElement("icon"); + icon.className = "attr"; + icon.setAttribute("data-attr-icon",attr); + return tsp.attrs[attr]({icon: icon}); + }) + .nodeJoin(tsp.word.slight_pause()); + } frg.ap(option.affix ? tsp.word.affix_attr({cotent: contentFrg}) : contentFrg); return frg; } @@ -1542,17 +1598,8 @@ function renderOrbs(attrs, option = {}) { const tsp = localTranslating.skill_parse; let contentFrg; - if (attrs.includes(0) && - attrs.includes(1) && - attrs.includes(2) && - attrs.includes(3) && - attrs.includes(4) && - attrs.includes(5) && - attrs.includes(6) && - attrs.includes(7) && - attrs.includes(8) && - attrs.includes(9) - ) + + if (isEqual(attrs, Attributes.orbs())) { contentFrg = option.any ? tsp.orbs.any() : tsp.orbs.all(); } @@ -1571,13 +1618,90 @@ function renderOrbs(attrs, option = {}) { return frg; } -/* -function renderTypes(types: Types | Types[]) { +function renderTypes(types, option = {}) { if (!Array.isArray(types)) - types = [types]; - return types.map(type => ); + types = [types ?? 0]; + const frg = document.createDocumentFragment(); + if (typeof localTranslating == "undefined") return frg; + + const tsp = localTranslating.skill_parse; + const contentFrg = types.map(attr => { + const icon = document.createElement("icon"); + icon.className = "type"; + icon.setAttribute("data-type-icon",attr); + return tsp.types[attr]({icon: icon}); + }) + .nodeJoin(tsp.word.slight_pause()); + frg.ap(option.affix ? tsp.word.affix_type({cotent: contentFrg}) : contentFrg); + return frg; } +function renderCondition(cond) { + const frg = document.createDocumentFragment(); + const tsp = localTranslating.skill_parse; + if (cond.hp) { + let dict = { + hp: renderStat('hp'), + min: renderValue(v.percent(cond.hp.min * 100), {percent: true}), + max: renderValue(v.percent(cond.hp.max * 100), {percent: true}), + }; + if (cond.hp.min === cond.hp.max) + frg.ap(tsp.cond.hp_equal(dict)); + else if (cond.hp.min === 0) + frg.ap(tsp.cond.hp_less_or_equal(dict)); + else if (cond.hp.max === 1) + frg.ap(tsp.cond.hp_greater_or_equal(dict)); + else + frg.ap(tsp.cond.hp_belong_to_range(dict)); + } else if (cond.useSkill) { + frg.ap(tsp.cond.use_skill()); + } else if (cond.multiplayer) { + frg.ap(tsp.cond.multi_player()); + } else if (cond.remainOrbs) { + let dict = { + count: renderValue(v.constant(cond.remainOrbs.count), {unit: tsp.unit.unit}), + }; + frg.ap(tsp.cond.remain_orbs(dict)); + } else if (cond.exact) { + if (cond.exact.type === 'combo') { + let dict = {value: cond.exact.value}; + frg.ap(tsp.cond.exact_combo(dict)); + } else if (cond.exact.type === 'match-length') { + let dict = { + value: cond.exact.value, + orbs: cond.exact.attrs === 'enhanced' ? tsp.cond.exact_match_enhanced() : renderOrbs(cond.exact.attrs) + }; + frg.ap(tsp.cond.exact_match_length(dict)); + } else if (cond.exact.type === 'match-count') { + } + } else if (cond.compo) { + let dict = {}; + switch (cond.compo.type) + { + case 'card':{ + dict.ids = cond.compo.ids.join(); + frg.ap(tsp.cond.compo_type_card(dict)); + break; + } + case 'series':{ + dict.ids = cond.compo.ids.join(); + frg.ap(tsp.cond.compo_type_series(dict)); + break; + } + case 'evolution':{ + dict.ids = cond.compo.ids.join(); + frg.ap(tsp.cond.compo_type_evolution(dict)); + break; + } + } + } else { + frg.ap(tsp.cond.unknown()); + } + return frg; +} + +/* + function renderCondition(cond: SkillCondition) { if (cond.hp) { diff --git a/style.css b/style.css index bf3f082f..37c8c4d4 100644 --- a/style.css +++ b/style.css @@ -3480,4 +3480,8 @@ table .orb-icon .icon-skill[data-icon-type="rate-mul-exp"] { background-position-y:calc(-36px * 31); +} +.icon-skill[data-icon-type="reduce-damage"] +{ + background-position-y:calc(-36px * 32); } \ No newline at end of file