From eecaefabe16cd5decb31a57e8c0518b94d33d309 Mon Sep 17 00:00:00 2001 From: Aluxes <39981645+AshenAshes@users.noreply.github.com> Date: Sun, 28 Jan 2024 05:59:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20*=E5=88=B7=E6=96=B0=E6=8E=92=E5=90=8D=20?= =?UTF-8?q?=E8=AF=AF=E9=87=8D=E7=BD=AE=E5=8E=9F=E7=A5=9E=E6=8E=92=E5=90=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E6=98=9F=E9=93=81=E6=8E=92=E5=90=8D?= =?UTF-8?q?=E4=BC=A4=E5=AE=B3=E4=B8=8E=E9=9D=A2=E6=9D=BF=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E9=97=AE=E9=A2=98=E3=80=82=E6=96=B0=E5=A2=9E*?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E6=8E=92=E5=90=8D=EF=BC=8C*=E7=BE=A4?= =?UTF-8?q?=E6=9C=80=E5=BC=BAxx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/profile.js | 10 +++++----- apps/profile/ProfileRank.js | 11 ++++++----- models/Character.js | 2 +- models/ProfileRank.js | 9 ++++----- models/artis/ArtisMark.js | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/profile.js b/apps/profile.js index 96d8b9b0..42c41ad4 100644 --- a/apps/profile.js +++ b/apps/profile.js @@ -36,17 +36,17 @@ app.reg({ groupProfile: { name: '群内最强', fn: groupRank, - rule: /^#(群|群内)?(排名|排行)?(最强|最高|最高分|最牛|第一|极限)+.+/ + rule: /^#(星铁|原神)?(群|群内)?(排名|排行)?(最强|最高|最高分|最牛|第一|极限)+.+/ }, resetRank: { name: '重置排名', fn: resetRank, - rule: /^#(重置|重设)(.*)(排名|排行)$/ + rule: /^#(星铁|原神)?(重置|重设)(.*)(排名|排行)$/ }, refreshRank: { - name: '重置排名', + name: '刷新排名', fn: refreshRank, rule: /^#(星铁|原神)?(刷新|更新|重新加载)(群内|群|全部)*(排名|排行)$/ }, @@ -60,7 +60,7 @@ app.reg({ rankList: { name: '面板排名榜', fn: groupRank, - rule: /^#(群|群内)?.+(排名|排行)(榜)?$/ + rule: /^#(星铁|原神)?(群|群内)?.+(排名|排行)(榜)?$/ }, artisList: { @@ -80,7 +80,7 @@ app.reg({ talentStat: { name: '天赋统计', fn: ProfileStat.stat, - rule: /^#*(我的)*(今日|今天|明日|明天|周.*)?(五|四|5|4|星)?(技能|天赋)+(汇总|统计|列表)?[ |0-9]*$/, + rule: /^#*(我的)*(今日|今天|明日|明天|周.*)?(五|四|5|4|星)?(技能|天赋)+(汇总|统计|列表)?[ |0-9]*$/ }, avatarList: { diff --git a/apps/profile/ProfileRank.js b/apps/profile/ProfileRank.js index 26bc9e3b..acc25f01 100644 --- a/apps/profile/ProfileRank.js +++ b/apps/profile/ProfileRank.js @@ -18,7 +18,7 @@ export async function groupRank (e) { if (!type || (!groupId && type !== 'super')) { return false } - let mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'mark' : 'dmg' + let mode = /(分|圣遗物|遗器|评分|ACE)/.test(msg) ? 'mark' : 'dmg' mode = /(词条)/.test(msg) ? 'valid' : mode mode = /(双爆)/.test(msg) ? 'crit' : mode let name = msg.replace(/(#|星铁|最强|最高分|第一|词条|双爆|极限|最高|最多|最牛|圣遗物|评分|群内|群|排名|排行|面板|面版|详情|榜)/g, '') @@ -81,7 +81,7 @@ export async function groupRank (e) { if (uids.length > 0) { return renderCharRankList({ e, uids, char, mode, groupId }) } else { - if (e.isSr){ + if (e.isSr) { e.reply('暂无排名:请通过【*面板】查看角色面板以更新排名信息...') } else { e.reply('暂无排名:请通过【#面板】查看角色面板以更新排名信息...') @@ -101,6 +101,7 @@ export async function resetRank (e) { e.reply('只有管理员可重置排名') return true } + let game = e.isSr ? 'sr' : 'gs' let msg = e.original_msg || e.msg let name = msg.replace(/(#|重置|重设|排名|排行|群|群内|面板|详情|面版)/g, '').trim() let charId = '' @@ -114,7 +115,7 @@ export async function resetRank (e) { charId = char.id charName = char.name } - await ProfileRank.resetRank(groupId, charId) + await ProfileRank.resetRank(groupId, charId, game) e.reply(`本群${charName}排名已重置...`) } @@ -134,7 +135,7 @@ export async function refreshRank (e) { } e.reply('面板数据刷新中,等待时间可能较长,请耐心等待...') let game = e.isSr ? 'sr' : 'gs' - await ProfileRank.resetRank(groupId) + await ProfileRank.resetRank({ groupId, game }) let uidMap = await ProfileRank.getUserUidMap(e, game) let count = 0 for (let uid in uidMap) { @@ -206,7 +207,7 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) { } title = title.length > 10 ? title.replace(/伤害$/, '') : title tmp.dmg = { - title: title, + title, avg: Format.comma(dmg.avg, 1) } } diff --git a/models/Character.js b/models/Character.js index b8095864..8d9b98fa 100644 --- a/models/Character.js +++ b/models/Character.js @@ -81,7 +81,7 @@ class Character extends Base { get sName () { let name = this.name let abbr = this.abbr - return name.length <= 4 ? name : (abbr || name) + return name.length < 4 ? name : (abbr || name) } // 是否是旅行者 diff --git a/models/ProfileRank.js b/models/ProfileRank.js index b5227be8..61eab5d3 100644 --- a/models/ProfileRank.js +++ b/models/ProfileRank.js @@ -69,10 +69,10 @@ export default class ProfileRank { * @param charId * @returns {Promise} */ - static async resetRank (groupId, charId = '') { + static async resetRank (groupId, charId = '', game = 'gs') { let keys = await redis.keys(`miao:rank:${groupId}:*`) for (let key of keys) { - let charRet = /^miao:rank:\d+:(?:mark|dmg|crit|valid):(\d{8})$/.exec(key) + let charRet = game === 'gs' ? /^miao:rank:\d+:(?:mark|dmg|crit|valid):(\d{8})$/.exec(key) : /^miao:rank:\d+:(?:mark|dmg|crit|valid):(\d{4})$/.exec(key) if (charRet) { if (charId === '' || charId * 1 === charRet[1] * 1) { await redis.del(key) @@ -398,7 +398,8 @@ export default class ProfileRank { } } if (type === 'dmg' && profile.hasDmg) { - let dmg = await profile.calcDmg({ mode: 'single' }) + let enemyLv = profile.game === 'gs' ? 91 : 80 + let dmg = await profile.calcDmg({ enemyLv, mode: 'single' }) if (dmg && dmg.avg) { return { score: dmg.avg, @@ -408,6 +409,4 @@ export default class ProfileRank { } return false } - - } diff --git a/models/artis/ArtisMark.js b/models/artis/ArtisMark.js index 0d95ffad..f5567591 100644 --- a/models/artis/ArtisMark.js +++ b/models/artis/ArtisMark.js @@ -213,7 +213,7 @@ let ArtisMark = { mark: Format.comma(totalMark, 1), _mark: artis.mark, markClass: artis.markClass, - ...Data.getData(setData, 'sets,names,imgs'), + ...Data.getData(setData, 'sets,names,imgs') } if (withDetail) { ret.charWeight = lodash.mapValues(charCfg.attrs, ds => ds.weight)