From c06233e86ac52e69bf04fc71d46993198b522927 Mon Sep 17 00:00:00 2001 From: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com> Date: Wed, 31 May 2023 03:16:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/profile/ProfileRank.js | 5 +- apps/wiki/CharTalent.js | 59 +++++++++++++ components/Common.js | 33 +++---- resources/common/tpl/talent-detail.html | 106 +++++++++++------------ resources/meta-sr/artifact/artis-mark.js | 4 +- resources/meta-sr/character/meta.js | 6 +- resources/wiki/character-talent.html | 18 ++-- 7 files changed, 145 insertions(+), 86 deletions(-) diff --git a/apps/profile/ProfileRank.js b/apps/profile/ProfileRank.js index 9c5abb57..6956f94f 100644 --- a/apps/profile/ProfileRank.js +++ b/apps/profile/ProfileRank.js @@ -122,12 +122,13 @@ export async function refreshRank (e) { return true } e.reply('面板数据刷新中,等待时间可能较长,请耐心等待...') + let game = e.isSr ? 'sr' : 'gs' await ProfileRank.resetRank(groupId) - let groupUids = await Common.getGroupUids(e) + let groupUids = await Common.getGroupUids(e, game) let count = 0 for (let qq in groupUids) { for (let { uid, type } of groupUids[qq]) { - let player = new Player(uid) + let player = new Player(uid, game) let profiles = player.getProfiles() // 刷新rankLimit await ProfileRank.setUidInfo({ uid, profiles, qq, uidType: type }) diff --git a/apps/wiki/CharTalent.js b/apps/wiki/CharTalent.js index 4bf4b5fa..1b97569c 100644 --- a/apps/wiki/CharTalent.js +++ b/apps/wiki/CharTalent.js @@ -7,9 +7,26 @@ const CharTalent = { for (let i = 1; i <= 15; i++) { lvs.push('Lv' + i) } + let detail = lodash.extend({}, char.getDetail()) + if (char.game === 'sr') { + lodash.forEach(['cons', 'talent', 'treeData'], (key) => { + lodash.forEach(detail[key], (ds, idx) => { + if (ds.desc) { + if (key === 'talent') { + let desc = CharTalent.getDesc(ds.desc, ds.tables, idx === 'a' ? 5 : 8) + ds.desc = desc.desc + ds.tables = desc.tables + } else if (ds.desc.split) { + ds.desc = ds.desc.split('
') + } + } + }) + }) + } return await Common.render('wiki/character-talent', { saveId: `${mode}-${char.id}`, ...char.getData(), + game: char.game, detail: char.getDetail(), imgs: char.getImgs(), mode, @@ -18,6 +35,9 @@ const CharTalent = { }, { e, scale: 1.1 }) }, getLineData (char) { + if (char.isSr) { + return [] + } let ret = [] const attrMap = { atkPct: '大攻击', @@ -43,6 +63,45 @@ const CharTalent = { label: `成长·${attrMap[ga.key]}` }) return ret + }, + // 获取精炼描述 + getDesc (desc, tables, lv = 5) { + let reg = /\$(\d)\[[i|f1]\](\%?)/g + let ret + + let idxFormat = {} + while ((ret = reg.exec(desc)) !== null) { + let idx = ret[1] + let pct = ret[2] + let value = tables?.[idx - 1]?.values[lv - 1] + if (value) { + if (pct === '%') { + idxFormat[idx - 1] = 'percent' + value = Format.percent(value) + } else { + idxFormat[idx - 1] = 'comma' + value = Format.comma(value) + } + value = value + ` (lv${lv})` + desc = desc.replaceAll(ret[0], value) + } + } + let tableRet = [] + lodash.forEach(tables, (ds, idx) => { + let values = [] + lodash.forEach(ds.values, (v) => { + values.push(Format[idxFormat[idx] || 'comma'](v)) + }) + tableRet.push({ + name: ds.name, + isSame: ds.isSame, + values + }) + }) + return { + desc: desc.split('
'), + tables: tableRet + } } } diff --git a/components/Common.js b/components/Common.js index 2b243358..f11fa4f6 100644 --- a/components/Common.js +++ b/components/Common.js @@ -14,21 +14,20 @@ const Common = { console.log('down file') }, - async getNoteQQUids (e) { + async getNoteQQUids (e, game='gs') { let ret = {} if (Version.isV3) { if (e.runtime) { - let noteCks = await e.runtime?.gsCfg?.getBingCk() || {} - lodash.forEach(noteCks, (cks, qq) => { - lodash.forEach(cks, (ck) => { - let { qq, uid } = ck - if (qq && uid) { - ret[qq] = ret[qq] || [] - if (!ret[qq].includes(uid)) { - ret[qq].push(uid) - } + let noteCks = await e.runtime?.gsCfg?.getBingCk(game) || {} + lodash.forEach(noteCks.ck, (ck, _qq) => { + let qq = ck.qq || _qq + let uid = ck.uid + if (qq && uid) { + ret[qq] = ret[qq] || [] + if (!ret[qq].includes(uid)) { + ret[qq].push(uid) } - }) + } }) } } else { @@ -43,7 +42,11 @@ const Common = { return ret }, - async getBindUid (qq) { + async getBindUid (qq, runtime, game = 'gs') { + if (Version.isMiao && runtime.NoteUser) { + let user = await runtime.NoteUser.create(qq) + return user ? user.getUid(game) : false + } if (Version.isV3) { return await redis.get(`Yz:genshin:mys:qq-uid:${qq}`) } else { @@ -51,9 +54,9 @@ const Common = { } }, - async getGroupUids (e) { + async getGroupUids (e, game = 'gs') { // 获取ck用户列表 - let noteUids = await Common.getNoteQQUids(e) + let noteUids = await Common.getNoteQQUids(e, game) let ret = {} let uidMap = {} @@ -78,7 +81,7 @@ const Common = { if (ret[qq]) { continue } - let uid = await Common.getBindUid(qq) + let uid = await Common.getBindUid(qq, e.runtime, game) if (uid && !uidMap[uid]) { ret[qq] = [{ uid, diff --git a/resources/common/tpl/talent-detail.html b/resources/common/tpl/talent-detail.html index 77d2e75a..838a0785 100644 --- a/resources/common/tpl/talent-detail.html +++ b/resources/common/tpl/talent-detail.html @@ -1,61 +1,61 @@ {{set ds = $data[0] || false }} -{{set {_res_path, icon,lvs,type} = $data[1]}} +{{set {_res_path, icon,lvs,type,game,minLv,maxLv} = $data[1]}}
-
- -
-
-
{{ds.name}}
-
- {{each ds.desc d}} - {{ if d[0] === "<" }} - {{@d}} - {{else if d!=""}} -

{{d}}

- {{/if}} - {{/each}} -
+
+ +
+
+
{{ds.name}}
+
+ {{each ds.desc d}} + {{ if d[0] === "<" || game==='sr' }} + {{@d}} + {{else if d!=""}} +

{{d}}

+ {{/if}} + {{/each}}
+
- {{if ds.tables && ds.tables.length > 0}} -
- {{each ds.tables tr}} - {{if tr.isSame}} -
- {{tr.name}}{{if tr.unit}}({{tr.unit}}){{/if}} - {{tr.values[0]}} -
- {{/if}} - {{/each}} + {{if ds.tables && ds.tables.length > 0}} +
+ {{each ds.tables tr}} + {{if tr.isSame}} +
+ {{tr.name}}{{if tr.unit}}({{tr.unit}}){{/if}} + {{tr.values[0]}}
- - - - {{each lvs lv idx}} - {{if (type=="a" && idx>4 && idx<11) || (type!="a" && idx>4 && idx < 13)}} - - {{/if}} - {{/each}} - - {{each ds.tables tr}} - {{if !tr.isSame}} - - - - {{each tr.values v idx}} - {{if (type=="a" && idx>4 && idx<11) || (type!="a" && idx>4 && idx < 13)}} - - {{/if}} - {{/each}} - {{/if}} - - {{/each}} -
{{lv}}
- {{tr.name}} - {{if tr.unit}} - ({{tr.unit}}) - {{/if}} - {{v}}
{{/if}} + {{/each}} +
+ + + + {{each lvs lv idx}} + {{if idx+1 >= minLv && idx+1 <= maxLv }} + + {{/if}} + {{/each}} + + {{each ds.tables tr}} + {{if !tr.isSame}} + + + + {{each tr.values v idx}} + {{if idx+1 >= minLv && idx+1 <= maxLv }} + + {{/if}} + {{/each}} + {{/if}} + + {{/each}} +
{{minLv}} {{maxLv}}{{lv}}
+ {{tr.name}} + {{if tr.unit}} + ({{tr.unit}}) + {{/if}} + {{v}}
+ {{/if}}
diff --git a/resources/meta-sr/artifact/artis-mark.js b/resources/meta-sr/artifact/artis-mark.js index 88a83c4d..ac5de7ad 100644 --- a/resources/meta-sr/artifact/artis-mark.js +++ b/resources/meta-sr/artifact/artis-mark.js @@ -5,7 +5,7 @@ export const usefulAttr = { 景元: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, 希儿: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, - 布洛妮娅: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 0, cdmg: 100, stance: 0, heal: 0, recharge: 100, effPct: 0, effDef: 0, dmg: 100 }, + 布洛妮娅: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 75, cdmg: 100, stance: 0, heal: 0, recharge: 100, effPct: 0, effDef: 0, dmg: 100 }, 杰帕德: { hp: 50, atk: 0, def: 100, speed: 100, cpct: 0, cdmg: 0, stance: 0, heal: 0, recharge: 100, effPct: 50, effDef: 50, dmg: 0 }, 姬子: { hp: 0, atk: 75, def: 0, speed: 75, cpct: 100, cdmg: 100, stance: 50, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, 瓦尔特: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, @@ -15,7 +15,7 @@ export const usefulAttr = { 三月七: { hp: 50, atk: 0, def: 100, speed: 100, cpct: 0, cdmg: 0, stance: 0, heal: 0, recharge: 100, effPct: 50, effDef: 50, dmg: 0 }, 丹恒: { hp: 0, atk: 75, def: 0, speed: 75, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, 阿兰: { hp: 0, atk: 75, def: 0, speed: 75, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, - 艾丝妲: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 0, cdmg: 0, stance: 75, heal: 0, recharge: 100, effPct: 0, effDef: 0, dmg: 100 }, + 艾丝妲: { hp: 0, atk: 75, def: 0, speed: 100, cpct: 75, cdmg: 75, stance: 100, heal: 0, recharge: 100, effPct: 0, effDef: 0, dmg: 100 }, 黑塔: { hp: 0, atk: 75, def: 0, speed: 75, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, 希露瓦: { hp: 0, atk: 75, def: 0, speed: 75, cpct: 100, cdmg: 100, stance: 0, heal: 0, recharge: 50, effPct: 0, effDef: 0, dmg: 100 }, 娜塔莎: { hp: 100, atk: 0, def: 50, speed: 75, cpct: 0, cdmg: 0, stance: 0, heal: 100, recharge: 75, effPct: 0, effDef: 50, dmg: 0 }, diff --git a/resources/meta-sr/character/meta.js b/resources/meta-sr/character/meta.js index addede52..37a9a59e 100644 --- a/resources/meta-sr/character/meta.js +++ b/resources/meta-sr/character/meta.js @@ -6,7 +6,7 @@ let alias = { 佩拉: '佩菈', 停云: '', 克拉拉: '', - 卡夫卡: '亲妈', + 卡夫卡: '亲妈,卡芙卡', 姬子: '', 娜塔莎: '纳塔莎,纳塔沙,纳塔沙', 布洛妮娅: '大鸭鸭,鸭鸭,板鸭,布洛尼亚,布洛妮亚,布洛尼娅', @@ -16,7 +16,7 @@ let alias = { 景元: '景原,景源,神君发射器', 杰帕德: '', 桑博: '桑柏,桑伯', - 瓦尔特: '老杨,杨叔,瓦尔特杨', + 瓦尔特: '老杨,杨叔,瓦尔特杨,第一律者,手搓黑洞', 白露: '小龙人', 素裳: '', 罗刹: '罗沙,罗杀', @@ -25,7 +25,7 @@ let alias = { 银狼: '小鸭鸭,小板鸭,黑客,骇客,骇兔', 阿兰: '', 青雀: '赌神,赌圣,青鹊', - 黑塔: '' + 黑塔: '转圈圈' } let aliasMap = {} diff --git a/resources/wiki/character-talent.html b/resources/wiki/character-talent.html index b17f0df4..7b1f4409 100644 --- a/resources/wiki/character-talent.html +++ b/resources/wiki/character-talent.html @@ -5,18 +5,11 @@ {{/block}} {{block 'main'}} +
- -
{{title}}·{{name}}
{{@desc}}
@@ -43,12 +36,15 @@ {{/if}}
+ {{if mode == "talent"}} {{each detail.talent talent type}}
- <% include(_tpl_path+'/talent-detail.html', [talent, {_res_path,lvs,type,icon:imgs[type]}]) %> + {{set minLv = game === 'gs' ? 4 : (type==='a'?1:4) }} + {{set maxLv = game === 'gs' ? (type==='a'?11:13) : (type==='a'?9:12)}} + <% include(_tpl_path+'/talent-detail.html', [talent, {_res_path,lvs,type,icon:imgs[type],minLv,maxLv,game}]) %>
{{/each}} @@ -56,7 +52,7 @@
{{each detail.passive pass idx}} - <% include(_tpl_path+'/talent-detail.html', [pass, {_res_path,icon:imgs['passive'+idx]}]) %> + <% include(_tpl_path+'/talent-detail.html', [pass, {_res_path,icon:imgs['passive'+idx],game}]) %> {{/each}}
@@ -66,7 +62,7 @@
{{each detail.cons con idx}} - <% include(_tpl_path+'/talent-detail.html', [con, {_res_path,lvs,type,icon:imgs['cons'+idx]}]) %> + <% include(_tpl_path+'/talent-detail.html', [con, {_res_path,lvs,type,icon:imgs['cons'+idx],game}]) %> {{/each}}