mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-22 06:58:24 +00:00
喵喵设置中增加排名限制门槛,支持限制 超过14个角色数据/包含御三家角色 才能参与排名,防止被随意刷榜
This commit is contained in:
parent
dfd729af1d
commit
6fdea5e4e0
@ -11,6 +11,7 @@
|
||||
* `#喵喵设置` 部分配置项及功能改进
|
||||
* 删除一些无效或暂不支持的配置项
|
||||
* 配置存储位置变更为**config/cfg.js**。原设置会自动迁移
|
||||
* 喵喵设置中增加排名限制门槛,支持限制 超过14个角色数据/包含御三家角色 才能参与排名,防止被随意刷榜
|
||||
|
||||
# 2.0.1~2.0.7
|
||||
|
||||
|
@ -62,7 +62,7 @@ async function sysCfg (e) {
|
||||
if (cfgSchema.input) {
|
||||
val = cfgSchema.input(val)
|
||||
} else {
|
||||
val = !/关闭/.test(val)
|
||||
val = cfgSchema.type === 'num' ? (val * 1 || cfgSchema.def) : !/关闭/.test(val)
|
||||
}
|
||||
Cfg.set(cfgSchema.cfgKey, val)
|
||||
}
|
||||
|
@ -9,10 +9,7 @@ export async function profileList (e) {
|
||||
return true
|
||||
}
|
||||
let rank = false
|
||||
let groupId = e.group_id
|
||||
if (groupId) {
|
||||
rank = await ProfileRank.create({ groupId, uid, qq: e.user_id })
|
||||
}
|
||||
|
||||
let servName = Profile.getServName(uid)
|
||||
let hasNew = false
|
||||
let newCount = 0
|
||||
@ -25,6 +22,15 @@ export async function profileList (e) {
|
||||
newChar = e.newChar
|
||||
}
|
||||
const cfg = await Data.importCfg('cfg')
|
||||
// 获取面板数据
|
||||
let profiles = Profile.getAll(uid)
|
||||
// 检测标志位
|
||||
await ProfileRank.setRankLimit(uid, profiles)
|
||||
|
||||
let groupId = e.group_id
|
||||
if (groupId) {
|
||||
rank = await ProfileRank.create({ groupId, uid, qq: e.user_id })
|
||||
}
|
||||
const groupRank = rank && (cfg?.diyCfg?.groupRank || false)
|
||||
const rankCfg = await ProfileRank.getGroupCfg(groupId)
|
||||
await Profile.forEach(uid, async function (profile) {
|
||||
@ -74,6 +80,7 @@ export async function profileList (e) {
|
||||
hasNew,
|
||||
msg,
|
||||
groupRank,
|
||||
allowRank: rank && rank.allowRank,
|
||||
rankCfg
|
||||
}, { e, scale: 1.6 })
|
||||
}
|
||||
|
@ -22,6 +22,13 @@ export const cfgSchema = {
|
||||
def: false,
|
||||
desc: '群内的面板伤害及圣遗物排名与查看功能,默认关闭。请根据群友心理素质自行决定是否开启'
|
||||
},
|
||||
groupRankLimit: {
|
||||
title: '排名限制',
|
||||
key: '限制',
|
||||
def: 1,
|
||||
type: 'num',
|
||||
desc: '参与排名的限制条件:1:无限制/ 2:有超过14个角色/ 3:有御三家/ 4:有14个角色+御三家。若改变设置请根据情况决定是否需要【#重置排名】'
|
||||
},
|
||||
uploadAbyssData: {
|
||||
title: '上传深渊',
|
||||
key: '深渊',
|
||||
|
@ -1,15 +1,22 @@
|
||||
import lodash from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { Common } from '../components/index.js'
|
||||
|
||||
export default class ProfileRank {
|
||||
constructor (data) {
|
||||
this.groupId = data.groupId || data.groupId
|
||||
this.groupId = data.groupId || data.groupId || ''
|
||||
if (!this.groupId || this.groupId === 'undefined') {
|
||||
return false
|
||||
}
|
||||
this.qq = data.qq
|
||||
this.uid = data.uid + ''
|
||||
this.allowRank = false
|
||||
}
|
||||
|
||||
static async create (data) {
|
||||
return new ProfileRank(data)
|
||||
let rank = new ProfileRank(data)
|
||||
rank.allowRank = await ProfileRank.checkRankLimit(rank.uid)
|
||||
return rank
|
||||
}
|
||||
|
||||
key (profile, type) {
|
||||
@ -23,7 +30,7 @@ export default class ProfileRank {
|
||||
* @returns {Promise<{}|boolean>}
|
||||
*/
|
||||
async getRank (profile, force = false) {
|
||||
if (!profile.hasData) {
|
||||
if (!this.groupId || !this.allowRank || !profile.hasData) {
|
||||
return false
|
||||
}
|
||||
let ret = {}
|
||||
@ -56,7 +63,7 @@ export default class ProfileRank {
|
||||
value = await this.getTypeValue(profile, type)
|
||||
}
|
||||
}
|
||||
if (value && value.score) {
|
||||
if (value && !lodash.isUndefined(value.score)) {
|
||||
await redis.zAdd(typeKey, { score: value.score, value: this.uid })
|
||||
}
|
||||
if (!lodash.isNumber(rank)) {
|
||||
@ -142,8 +149,16 @@ export default class ProfileRank {
|
||||
}
|
||||
|
||||
static async getGroupCfg (groupId) {
|
||||
const rankLimitTxt = {
|
||||
1: '无限制',
|
||||
2: '有超过14个角色数据',
|
||||
3: '有御三家数据',
|
||||
4: '有超过14个角色数据且有御三家'
|
||||
}
|
||||
let rankLimit = Common.cfg('groupRankLimit') * 1 || 1
|
||||
let ret = {
|
||||
timestamp: (new Date()) * 1,
|
||||
limitTxt: rankLimitTxt[rankLimit],
|
||||
status: 0
|
||||
}
|
||||
try {
|
||||
@ -158,4 +173,49 @@ export default class ProfileRank {
|
||||
ret.time = moment(new Date(ret.timestamp)).format('MM-DD HH:mm')
|
||||
return ret
|
||||
}
|
||||
|
||||
static async setRankLimit (uid, profiles) {
|
||||
if (!uid) {
|
||||
return false
|
||||
}
|
||||
let basicCount = 0
|
||||
let totalCount = 0
|
||||
for (let charId in profiles) {
|
||||
let profile = profiles[charId]
|
||||
if (!profile || !profile.hasData) {
|
||||
continue
|
||||
}
|
||||
if (['安柏', '凯亚', '丽莎'].includes(profile.name)) {
|
||||
basicCount++
|
||||
}
|
||||
totalCount++
|
||||
}
|
||||
await redis.set(`miao:rank:uid-info:${uid}`, JSON.stringify({
|
||||
totalCount,
|
||||
basicCount
|
||||
}), { EX: 3600 * 24 * 365 })
|
||||
}
|
||||
|
||||
static async checkRankLimit (uid) {
|
||||
if (!uid) {
|
||||
return false
|
||||
}
|
||||
try {
|
||||
let rankLimit = Common.cfg('groupRankLimit') * 1 || 1
|
||||
if (rankLimit === 1) {
|
||||
return true
|
||||
}
|
||||
let data = await redis.get(`miao:rank:uid-info:${uid}`)
|
||||
data = JSON.parse(data)
|
||||
if ((data.totalCount || 0) < 14 && [2, 4].includes(rankLimit)) {
|
||||
return false
|
||||
}
|
||||
if ((data.basicCount || 0) < 3 && [3, 4].includes(rankLimit)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,17 @@
|
||||
</div>
|
||||
<div class="cont group-rank-tip {{groupRank?'has-rank':'no-rank'}}">
|
||||
<div class="cont-title">
|
||||
<span>
|
||||
{{if !allowRank}}
|
||||
<i class="group-rank-icon dmg-icon"></i> <span>本面板暂未参与排名,参与要求:{{rankCfg.limitTxt}} </span>
|
||||
{{else}}
|
||||
<span>
|
||||
<i class="group-rank-icon dmg-icon"></i>综合练度排名
|
||||
<i class="group-rank-icon mark-icon"></i>圣遗物评分排名
|
||||
</span>
|
||||
<span class="rank-time">
|
||||
排名:本群内 {{rankCfg.time}} 后,通过 #面板 命令查看过的角色数据
|
||||
</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="cont {{groupRank?'has-rank':'no-rank'}}">
|
||||
@ -37,7 +41,7 @@
|
||||
<span class="name">{{char.abbr}}<span class="cons cons-{{char.cons}}">{{char.cons}}</span></span>
|
||||
{{if char.groupRank}}
|
||||
{{set gr = char.groupRank}}
|
||||
{{set rank = gr.rank > 9 ? 10:(gr.rank <=3 ? gr.rank : 4)}}
|
||||
{{set rank = gr.rank >= 15 ? 10:(gr.rank <=3 ? gr.rank : 4)}}
|
||||
<div class="group-rank rank-{{rank}} rank-type-{{gr.rankType}}">
|
||||
<span>{{gr.rank}}</span>
|
||||
</div>
|
||||
|
@ -29,6 +29,11 @@
|
||||
<strong>排名范围:</strong>
|
||||
本群内 / 时间点:{{rankCfg.time}} 后 / 在群内主动通过 #面板 命令查看过的面板数据
|
||||
</li>
|
||||
{{if rankCfg?.limitTxt !== '无限制'}}
|
||||
<li>
|
||||
<strong>排名参与条件:</strong> {{rankCfg.limitTxt}}
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -47,9 +52,7 @@
|
||||
<span class="cons cons-{{ds.cons}}">{{ds.cons}}</span>
|
||||
<strong>{{ds.sName}}</strong>
|
||||
</div>
|
||||
<div class="info">
|
||||
Uid: {{ds.uid}}
|
||||
</div>
|
||||
<div class="info"> {{ds.uid}}</div>
|
||||
</div>
|
||||
|
||||
<div class="char-talent">
|
||||
|
@ -10,6 +10,7 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['放电伤害'], 'q')
|
||||
}]
|
||||
|
||||
export const defDmgIdx = 1
|
||||
export const mainAttr = 'atk,cpct,cdmg'
|
||||
|
||||
export const buffs = [{
|
||||
|
@ -3,7 +3,6 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.e['技能伤害'], 'e')
|
||||
}, {
|
||||
title: 'E每跳治疗',
|
||||
showDetail: true,
|
||||
dmg: ({ talent, calc, attr }, { heal }) => {
|
||||
let ec = talent.e['越祓草轮治疗量2']
|
||||
return heal(calc(attr.hp) * ec[0] / 100 + ec[1] * 1 + calc(attr.mastery) * 0.75)
|
||||
@ -13,6 +12,7 @@ export const details = [{
|
||||
dmg: ({ talent, calc, attr }, { basic }) => basic(talent.q['单次伤害'] * calc(attr.hp) / 100, 'q')
|
||||
}]
|
||||
|
||||
export const defDmgIdx = 1
|
||||
export const mainAttr = 'hp,atk,cpct,cdmg,mastery'
|
||||
|
||||
export const buffs = [{
|
||||
|
@ -4,7 +4,6 @@ export const details = [{
|
||||
}, {
|
||||
title: 'Q单段伤害',
|
||||
params: { q: true },
|
||||
dmgKey: 'q',
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['持续伤害'], 'q')
|
||||
}, {
|
||||
title: 'Q含转化单段',
|
||||
@ -23,7 +22,7 @@ export const details = [{
|
||||
dmg: ({}, { reaction }) => reaction('swirl')
|
||||
}]
|
||||
|
||||
export const defDmgKey = 'q'
|
||||
export const defDmgIdx = 1
|
||||
export const mainAttr = 'atk,cpct,cdmg,mastery'
|
||||
|
||||
export const buffs = [{
|
||||
|
@ -7,7 +7,6 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['爆发伤害'], 'q')
|
||||
}, {
|
||||
title: 'Q爆发治疗',
|
||||
dmgKey: 'qHeal',
|
||||
dmg: ({ talent, calc, attr }, { heal }) =>
|
||||
heal(talent.q['领域发动治疗量2'][0] * calc(attr.atk) / 100 + talent.q['领域发动治疗量2'][1] * 1)
|
||||
}, {
|
||||
@ -17,7 +16,7 @@ export const details = [{
|
||||
}]
|
||||
|
||||
export const mainAttr = 'atk,cpct,cdmg'
|
||||
export const defDmgKey = 'qHeal'
|
||||
export const defDmgIdx = 2
|
||||
|
||||
export const buffs = [{
|
||||
cons: 1,
|
||||
|
@ -6,12 +6,11 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.e['技能伤害'], 'e')
|
||||
}, {
|
||||
title: '神里流·霜灭 单段伤害',
|
||||
dmgKey: 'q',
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['切割伤害'], 'q')
|
||||
}]
|
||||
|
||||
export const mainAttr = 'atk,cpct,cdmg'
|
||||
export const defDmgKey = 'q'
|
||||
export const defDmgIdx = 2
|
||||
|
||||
export const buffs = [{
|
||||
passive: 1,
|
||||
|
@ -14,6 +14,7 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['泡影破裂伤害'], 'q', 'vaporize')
|
||||
}]
|
||||
|
||||
export const defDmgIdx = 3
|
||||
export const mainAttr = 'atk,cpct,cdmg,recharge'
|
||||
|
||||
export const buffs = [{
|
||||
|
@ -3,7 +3,6 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.e['三段伤害'], 'e')
|
||||
}, {
|
||||
title: 'E三段蒸发',
|
||||
dmgKey: 'e',
|
||||
dmg: ({ talent }, dmg) => dmg(talent.e['三段伤害'], 'e', 'vaporize')
|
||||
}, {
|
||||
title: 'Q爆发伤害',
|
||||
@ -16,8 +15,8 @@ export const details = [{
|
||||
}]
|
||||
|
||||
export const defParams = { monv: 3 }
|
||||
export const defDmgKey = 'e'
|
||||
export const mainAttr = 'atk,cpct,cdmg,mastery'
|
||||
export const defDmgIdx = 1
|
||||
|
||||
export const buffs = [{
|
||||
title: '迪卢克天赋:释放元素爆发后获得20%火伤加成',
|
||||
|
@ -1,21 +1,21 @@
|
||||
export const details = [{
|
||||
title: "重云E伤害",
|
||||
title: '重云E伤害',
|
||||
dmg: ({ talent }, dmg) => dmg(talent.e['技能伤害'], 'e')
|
||||
}, ({ cons }) => {
|
||||
let count = cons === 6 ? 4 : 3;
|
||||
let count = cons === 6 ? 4 : 3
|
||||
return {
|
||||
title: `Q ${count}柄灵刃总伤害`,
|
||||
dmg: ({ talent, cons }, dmg) => dmg(talent.q['技能伤害'] * count, 'q')
|
||||
}
|
||||
}];
|
||||
}]
|
||||
|
||||
export const defDmgIdx = 2;
|
||||
export const mainAttr = "atk,cpct,cdmg";
|
||||
export const defDmgIdx = 1
|
||||
export const mainAttr = 'atk,cpct,cdmg'
|
||||
|
||||
export const buffs = [{
|
||||
title: "重云6命:对于生命百分比低于重云的敌人伤害提升15%,同时额外多一柄灵刃",
|
||||
title: '重云6命:对于生命百分比低于重云的敌人伤害提升15%,同时额外多一柄灵刃',
|
||||
cons: 6,
|
||||
data: {
|
||||
qDmg: 15
|
||||
}
|
||||
}];
|
||||
}]
|
||||
|
@ -9,11 +9,10 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['旋火轮伤害'], 'q')
|
||||
}, {
|
||||
title: '旋火轮单次蒸发',
|
||||
dmgKey: 'q',
|
||||
dmg: ({ talent }, dmg) => dmg(talent.q['旋火轮伤害'], 'q', 'vaporize')
|
||||
}]
|
||||
|
||||
export const defDmgKey = 'q'
|
||||
export const defDmgIdx = 3
|
||||
export const mainAttr = 'atk,cpct,cdmg'
|
||||
|
||||
export const buffs = [{
|
||||
|
Loading…
Reference in New Issue
Block a user