mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
增加命令 #最强排行
、#最高分排行
查看群排行
This commit is contained in:
parent
6720eba0ba
commit
ead88813f0
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
* 角色面板彩蛋图(满命/三皇冠/ACE 任一触发)支持自定义
|
* 角色面板彩蛋图(满命/三皇冠/ACE 任一触发)支持自定义
|
||||||
* 自定义图像可放置在 **resources/profile/super-character/** 目录下
|
* 自定义图像可放置在 **resources/profile/super-character/** 目录下
|
||||||
|
* 增加命令 `#最强排行`、`#最高分排行` 查看群排行
|
||||||
|
|
||||||
# 2.0.1~2.0.9
|
# 2.0.1~2.0.9
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export async function groupRank (e) {
|
|||||||
let mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'mark' : 'dmg'
|
let mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'mark' : 'dmg'
|
||||||
let name = msg.replace(/(#|最强|最高分|第一|最高|最牛|圣遗物|评分|群内|群|排名|排行|面板|面版|详情|榜)/g, '')
|
let name = msg.replace(/(#|最强|最高分|第一|最高|最牛|圣遗物|评分|群内|群|排名|排行|面板|面版|详情|榜)/g, '')
|
||||||
let char = Character.get(name)
|
let char = Character.get(name)
|
||||||
if (!char) {
|
if (!char && type !== 'list') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (!groupRank) {
|
if (!groupRank) {
|
||||||
@ -41,10 +41,15 @@ export async function groupRank (e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type === 'list') {
|
} else if (type === 'list') {
|
||||||
if (mode === 'dmg' && !ProfileDmg.dmgRulePath(char.name)) {
|
if (mode === 'dmg' && char && !ProfileDmg.dmgRulePath(char.name)) {
|
||||||
e.reply(`暂无排名:${char.name}暂不支持伤害计算,无法进行排名..`)
|
e.reply(`暂无排名:${char.name}暂不支持伤害计算,无法进行排名..`)
|
||||||
} else {
|
} 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) {
|
if (uids.length > 0) {
|
||||||
return renderCharRankList({ e, uids, char, mode, groupId })
|
return renderCharRankList({ e, uids, char, mode, groupId })
|
||||||
} else {
|
} else {
|
||||||
@ -121,10 +126,10 @@ export async function refreshRank (e) {
|
|||||||
|
|
||||||
async function renderCharRankList ({ e, uids, char, mode, groupId }) {
|
async function renderCharRankList ({ e, uids, char, mode, groupId }) {
|
||||||
let list = []
|
let list = []
|
||||||
|
|
||||||
for (let ds of uids) {
|
for (let ds of uids) {
|
||||||
let uid = ds.value
|
let uid = ds.uid || ds.value
|
||||||
let profile = Profile.get(uid, char.id)
|
let profile = Profile.get(uid, ds.charId || char.id)
|
||||||
|
|
||||||
if (profile) {
|
if (profile) {
|
||||||
let profileRank = await ProfileRank.create({ groupId, uid })
|
let profileRank = await ProfileRank.create({ groupId, uid })
|
||||||
let data = await profileRank.getRank(profile, true)
|
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 avatar = new Avatar(profile, uid)
|
||||||
let tmp = {
|
let tmp = {
|
||||||
uid,
|
uid,
|
||||||
|
isMax: true,
|
||||||
...avatar.getData('id,star,name,sName,level,fetter,cons,weapon,elem,talent,artisSet,imgs'),
|
...avatar.getData('id,star,name,sName,level,fetter,cons,weapon,elem,talent,artisSet,imgs'),
|
||||||
artisMark: Data.getData(mark, 'mark,markClass')
|
artisMark: Data.getData(mark, 'mark,markClass')
|
||||||
}
|
}
|
||||||
@ -161,7 +167,12 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) {
|
|||||||
list.push(tmp)
|
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)
|
const rankCfg = await ProfileRank.getGroupCfg(groupId)
|
||||||
// 渲染图像
|
// 渲染图像
|
||||||
return await Common.render('character/rank-profile-list', {
|
return await Common.render('character/rank-profile-list', {
|
||||||
|
@ -118,6 +118,25 @@ export default class ProfileRank {
|
|||||||
return uids ? uids[0] : false
|
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
|
* @param groupId
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
{{each list ds idx}}
|
{{each list ds idx}}
|
||||||
<div class="cont char-list-item">
|
<div class="cont char-list-item">
|
||||||
<div class="char-idx">
|
<div class="char-idx">
|
||||||
<span class="idx-{{idx+1}} mode-{{mode}}">{{idx+1}}</span>
|
<span class="idx-{{ds.isMax ? 1 : idx+1}} mode-{{mode}}">{{idx+1}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-icon char-icon star{{ds.star}}">
|
<div class="item-icon char-icon star{{ds.star}}">
|
||||||
{{if ds.qqFace}}
|
{{if ds.qqFace}}
|
||||||
|
Loading…
Reference in New Issue
Block a user