feat: 添加练度的计算公式

This commit is contained in:
bietiaop 2024-07-31 17:11:30 +08:00
parent 2c745c256e
commit 8a420e8fe1
3 changed files with 51 additions and 2 deletions

View file

@ -19,6 +19,10 @@ export class Panel extends ZZZPlugin {
reg: `${rulePrefix}(.*)面板(.*)$`, reg: `${rulePrefix}(.*)面板(.*)$`,
fnc: 'handleRule', fnc: 'handleRule',
}, },
{
reg: `${rulePrefix}练度(统计)?$`,
fnc: 'proficiency',
},
], ],
}); });
} }
@ -104,4 +108,24 @@ export class Panel extends ZZZPlugin {
}; };
await render(this.e, 'panel/card.html', finalData); await render(this.e, 'panel/card.html', finalData);
} }
async proficiency() {
const uid = await this.getUID();
if (!uid) return false;
const result = getPanelList(uid);
result.sort((a, b) => {
return b.proficiency_score - a.proficiency_score;
});
result.forEach(item => {
logger.debug(item.proficiency_score, item);
});
const finalData = {
count: result?.length || 0,
list: result,
};
// await render(this.e, 'panel/proficiency.html', finalData);
}
} }

View file

@ -29,7 +29,9 @@ export class ZZZPlugin extends plugin {
const uid = this.User?.getUid('zzz'); const uid = this.User?.getUid('zzz');
// 如果 UID 不存在,说明没有绑定 cookie // 如果 UID 不存在,说明没有绑定 cookie
if (!uid) { if (!uid) {
await this.reply('uid为空米游社查询请先绑定cookie其他查询请携带uid'); await this.reply(
'uid为空需要CK的功能请先绑定CK或者#扫码登录需要SK的功能请#扫码登录若不清楚需要CK或SK请查看%帮助'
);
return false; return false;
} }
// 返回 UID // 返回 UID
@ -47,7 +49,7 @@ export class ZZZPlugin extends plugin {
const ck = await getCk(this.e); const ck = await getCk(this.e);
// 如果 cookie 不存在或者 cookie 为空,说明没有绑定 cookie // 如果 cookie 不存在或者 cookie 为空,说明没有绑定 cookie
if (!ck || Object.keys(ck).filter(k => ck[k].ck).length === 0) { if (!ck || Object.keys(ck).filter(k => ck[k].ck).length === 0) {
await this.reply('尚未绑定cookie请先绑定cookie'); await this.reply('尚未绑定cookie请先绑定cookie,或者#扫码登录');
return { api: null, uid: null, deviceFp: null }; return { api: null, uid: null, deviceFp: null };
} }
try { try {

View file

@ -438,6 +438,29 @@ export class ZZZAvatarInfo {
return false; return false;
} }
/** @type {number} 练度分数 */
get proficiency_score() {
let score = 0;
if (this.rarity === 'S') {
score += 30;
} else {
score += 10;
}
if (this.equip_score !== false) {
score += this.equip_score * 3;
}
for (const skill of this.skills) {
score += skill.level * 5;
}
score += this.level * 2;
score += this.rank * 10;
if (this.weapon) {
score += this.weapon.level * 2;
score += this.weapon.star * 10;
}
return score;
}
async get_basic_assets() { async get_basic_assets() {
const result = await getSquareAvatar(this.id); const result = await getSquareAvatar(this.id);
/** @type {string} */ /** @type {string} */