diff --git a/CHANGELOG.md b/CHANGELOG.md index 064b54c6..510cf3ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * 角色面板彩蛋图(满命/三皇冠/ACE 任一触发)支持自定义 * 自定义图像可放置在 **resources/profile/super-character/** 目录下 +* 增加命令 `#最强排行`、`#最高分排行` 查看群排行 # 2.0.1~2.0.9 diff --git a/apps/character/ProfileRank.js b/apps/character/ProfileRank.js index 0cfd2f79..fad8bf40 100644 --- a/apps/character/ProfileRank.js +++ b/apps/character/ProfileRank.js @@ -21,7 +21,7 @@ export async function groupRank (e) { let mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'mark' : 'dmg' let name = msg.replace(/(#|最强|最高分|第一|最高|最牛|圣遗物|评分|群内|群|排名|排行|面板|面版|详情|榜)/g, '') let char = Character.get(name) - if (!char) { + if (!char && type !== 'list') { return false } if (!groupRank) { @@ -41,10 +41,15 @@ export async function groupRank (e) { } } } else if (type === 'list') { - if (mode === 'dmg' && !ProfileDmg.dmgRulePath(char.name)) { + if (mode === 'dmg' && char && !ProfileDmg.dmgRulePath(char.name)) { e.reply(`暂无排名:${char.name}暂不支持伤害计算,无法进行排名..`) } else { - let uids = await ProfileRank.getGroupUidList(groupId, char.id, mode) + let uids = [] + if (char) { + uids = await ProfileRank.getGroupUidList(groupId, char ? char.id : '', mode) + } else { + uids = await ProfileRank.getGroupMaxUidList(groupId, mode) + } if (uids.length > 0) { return renderCharRankList({ e, uids, char, mode, groupId }) } else { @@ -121,10 +126,10 @@ export async function refreshRank (e) { async function renderCharRankList ({ e, uids, char, mode, groupId }) { let list = [] - for (let ds of uids) { - let uid = ds.value - let profile = Profile.get(uid, char.id) + let uid = ds.uid || ds.value + let profile = Profile.get(uid, ds.charId || char.id) + if (profile) { let profileRank = await ProfileRank.create({ groupId, uid }) let data = await profileRank.getRank(profile, true) @@ -132,6 +137,7 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) { let avatar = new Avatar(profile, uid) let tmp = { uid, + isMax: true, ...avatar.getData('id,star,name,sName,level,fetter,cons,weapon,elem,talent,artisSet,imgs'), artisMark: Data.getData(mark, 'mark,markClass') } @@ -161,7 +167,12 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) { list.push(tmp) } } - let title = `#${char.name}${mode === 'mark' ? '圣遗物' : ''}排行` + let title + if (char) { + title = `#${char.name}${mode === 'mark' ? '圣遗物' : ''}排行` + } else { + title = `#${mode === 'mark' ? '最高分' : '最强'}排行` + } const rankCfg = await ProfileRank.getGroupCfg(groupId) // 渲染图像 return await Common.render('character/rank-profile-list', { diff --git a/models/ProfileRank.js b/models/ProfileRank.js index f0872c46..e7c913e6 100644 --- a/models/ProfileRank.js +++ b/models/ProfileRank.js @@ -118,6 +118,25 @@ export default class ProfileRank { return uids ? uids[0] : false } + static async getGroupMaxUidList (groupId, type = 'mark') { + let keys = await redis.keys(`miao:rank:${groupId}:${type}:*`) + let ret = [] + for (let key of keys) { + let keyRet = /^miao:rank:\d+:(?:mark|dmg):(\d{8})$/.exec(key) + if (keyRet && keyRet[1]) { + let charId = keyRet[1] + let uid = await ProfileRank.getGroupMaxUid(groupId, charId, type) + if (uid) { + ret.push({ + uid, + charId + }) + } + } + } + return ret + } + /** * 获取排行榜 * @param groupId diff --git a/resources/character/rank-profile-list.html b/resources/character/rank-profile-list.html index 5cac8c33..7d766b87 100644 --- a/resources/character/rank-profile-list.html +++ b/resources/character/rank-profile-list.html @@ -41,7 +41,7 @@ {{each list ds idx}}
- {{idx+1}} + {{idx+1}}
{{if ds.qqFace}}