Skip to content

Commit

Permalink
feat:新增练度统计
Browse files Browse the repository at this point in the history
Co-Authored-By: 二枣子 <[email protected]>
  • Loading branch information
CikeyQi and erzaozi committed Oct 24, 2024
1 parent 135e2ce commit 95788da
Show file tree
Hide file tree
Showing 70 changed files with 488 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pnpm install --filter=waves-plugin
- [x] 探索度查询
- [x] 挑战数据查询
- [x] 逆境深塔数据查询
- [x] 练度统计
- [x] 抽卡记录查询分析
- [x] 抽卡记录导入导出
- [x] 游戏内所有物品图鉴
Expand Down
3 changes: 2 additions & 1 deletion apps/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export class Calendar extends plugin {
const endTime = endDate ? `${endDate.toISOString().slice(5, 10).replace('-', '.')} ${endDate.toTimeString().slice(0, 5)}` : '';

const activeStatus = item.countDown
? (startDate && currentDate >= startDate ? '进行中' : '未开始')
? (startDate && currentDate >= endDate ? '已结束' :
(startDate && currentDate >= startDate ? '进行中' : '未开始'))
: '';

const remain = activeStatus === '进行中' && endDate
Expand Down
5 changes: 5 additions & 0 deletions apps/Help.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export class Help extends plugin {
"title": "~探索度",
"desc": "查看地图探索度"
},
{
"icon": 64,
"title": "~练度统计",
"desc": "查看所有角色练度"
},
{
"icon": 35,
"title": "~开启自动签到",
Expand Down
2 changes: 0 additions & 2 deletions apps/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export class Setting extends plugin {
};

const index = config.waves_auto_signin_list.findIndex(user =>
user.botId === newUser.botId &&
user.groupId === newUser.groupId &&
user.userId === newUser.userId
);

Expand Down
107 changes: 107 additions & 0 deletions apps/Training.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import plugin from '../../../lib/plugins/plugin.js'
import WeightCalculator from '../utils/Calculate.js'
import Waves from "../components/Code.js";
import Config from "../components/Config.js";
import Render from '../model/render.js'

export class Training extends plugin {
constructor() {
super({
name: "鸣潮-练度统计",
event: "message",
priority: 1009,
rule: [
{
reg: "^(~|~|鸣潮)练度(统计)?(\\d{9})?$",
fnc: "training"
}
]
})
}

async training(e) {

if (e.at) e.user_id = e.at;
let accountList = JSON.parse(await redis.get(`Yunzai:waves:users:${e.user_id}`)) || await Config.getUserConfig(e.user_id);
const waves = new Waves();

const match = e.msg.match(/\d{9}$/);

if (!accountList.length) {
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
let publicCookie = await waves.pubCookie();
if (!publicCookie) {
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行登录');
} else {
if (match) {
publicCookie.roleId = match[0];
await redis.set(`Yunzai:waves:bind:${e.user_id}`, publicCookie.roleId);
} else if (await redis.get(`Yunzai:waves:bind:${e.user_id}`)) {
publicCookie.roleId = await redis.get(`Yunzai:waves:bind:${e.user_id}`);
}
accountList.push(publicCookie);
}
} else {
return await e.reply('当前没有登录任何账号,请使用[~登录]进行登录');
}
}

let data = [];
let deleteroleId = [];

await Promise.all(accountList.map(async (account) => {
const usability = await waves.isAvailable(account.token);

if (!usability) {
data.push({ message: `账号 ${account.roleId} 的Token已失效\n请重新登录Token` });
deleteroleId.push(account.roleId);
return;
}

if (match) {
account.roleId = match[0];
await redis.set(`Yunzai:waves:bind:${e.user_id}`, account.roleId);
}

const [baseData, roleData] = await Promise.all([
waves.getBaseData(account.serverId, account.roleId, account.token),
waves.getRoleData(account.serverId, account.roleId, account.token)
]);

if (!baseData.status || !roleData.status) {
data.push({ message: baseData.msg || roleData.msg });
return;
}

const Promises = roleData.data.roleList.map(role =>
waves.getRoleDetail(account.serverId, account.roleId, role.roleId, account.token).then(data =>
data.status && data.data.role ? { ...role, ...data.data } : null
)
);

const roleList = (await Promise.all(Promises)).filter(Boolean).map(role => {
const calculatedRole = new WeightCalculator(role).calculate();
calculatedRole.chainCount = calculatedRole.chainList.filter(chain => chain.unlocked).length;
return calculatedRole;
});

roleList.sort((a, b) => b.starLevel - a.starLevel || b.phantomData.statistic.totalScore - a.phantomData.statistic.totalScore);

const imageCard = await Render.Training(baseData.data, roleList);
data.push({ message: imageCard });
}));

if (deleteroleId.length) {
let newAccountList = accountList.filter(account => !deleteroleId.includes(account.roleId));
Config.setUserConfig(e.user_id, newAccountList);
}

if (data.length === 1) {
await e.reply(data[0].message);
return true;
}

await e.reply(Bot.makeForwardMsg([{ message: `用户 ${e.user_id}` }, ...data]));
return true;
}
}
13 changes: 13 additions & 0 deletions model/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,19 @@ class Render {
return base64
}

async Training(baseData, roleList) {
const base64 = await puppeteer.screenshot('waves-plugin', {
saveId: this.getsaveId('training'),
imgType: 'png',
tplFile: `${pluginResources}/Template/training/training.html`,
pluginResources,
baseData,
roleList
})

return base64
}

getsaveId(name) {
if (!this.time[name]) this.time[name] = 0;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "waves-plugin",
"version": "1.4.20",
"version": "1.5.0",
"description": "基于 Yunzai 的鸣潮游戏数据查询插件",
"main": "index.js",
"scripts": {
Expand Down
Binary file modified resources/Strategy/Linn/今汐.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/凌阳.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/卡卡罗.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/吟霖.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/守岸人.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/安可.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/忌炎.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/折枝.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/漂泊者-女-湮灭.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/漂泊者-男-湮灭.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/相里要.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/Linn/长离.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/丹瑾.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/今汐.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/凌阳.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/卡卡罗.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/吟霖.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/安可.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/忌炎.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/折枝.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/散华.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/桃祈.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/漂泊者-女-湮灭.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/漂泊者-男-湮灭.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/白芷.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/Strategy/XMu/相里要.jpg
Binary file modified resources/Strategy/XMu/秧秧.jpg
Binary file modified resources/Strategy/XMu/维里奈.jpg
Binary file modified resources/Strategy/XMu/莫特斐.jpg
Binary file modified resources/Strategy/XMu/鉴心.jpg
Binary file modified resources/Strategy/XMu/长离.jpg
Binary file modified resources/Strategy/moealkyne/丹瑾.jpg
Binary file modified resources/Strategy/moealkyne/今汐.jpg
Binary file modified resources/Strategy/moealkyne/凌阳.jpg
Binary file modified resources/Strategy/moealkyne/卡卡罗.jpg
Binary file modified resources/Strategy/moealkyne/吟霖.jpg
Binary file modified resources/Strategy/moealkyne/守岸人.jpg
Binary file modified resources/Strategy/moealkyne/安可.jpg
Binary file modified resources/Strategy/moealkyne/忌炎.jpg
Binary file modified resources/Strategy/moealkyne/折枝.jpg
Binary file modified resources/Strategy/moealkyne/散华.jpg
Binary file modified resources/Strategy/moealkyne/桃祈.jpg
Binary file modified resources/Strategy/moealkyne/渊武.jpg
Binary file modified resources/Strategy/moealkyne/漂泊者-女-湮灭.jpg
Binary file modified resources/Strategy/moealkyne/漂泊者-女-衍射.jpg
Binary file modified resources/Strategy/moealkyne/漂泊者-男-湮灭.jpg
Binary file modified resources/Strategy/moealkyne/漂泊者-男-衍射.jpg
Binary file modified resources/Strategy/moealkyne/炽霞.jpg
Binary file modified resources/Strategy/moealkyne/白芷.jpg
Binary file modified resources/Strategy/moealkyne/相里要.jpg
Binary file modified resources/Strategy/moealkyne/秋水.jpg
Binary file modified resources/Strategy/moealkyne/秧秧.jpg
Binary file modified resources/Strategy/moealkyne/维里奈.jpg
Binary file modified resources/Strategy/moealkyne/莫特斐.jpg
Binary file modified resources/Strategy/moealkyne/釉瑚.jpg
Binary file modified resources/Strategy/moealkyne/鉴心.jpg
Binary file modified resources/Strategy/moealkyne/长离.jpg
1 change: 0 additions & 1 deletion resources/Template/calendar/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ li>div>img {
}

.progress-bar {
background: #cdb56b;
height: 100%;
width: var(--width);
}
6 changes: 5 additions & 1 deletion resources/Template/calendar/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@
</div>
</div>
<div class="progress">
<div class="progress-bar" style="--width: {{activity.progress}}%;">
{{if activity.progress < 100}}
<div class="progress-bar" style="--width: {{activity.progress}}%;background: #cdb56b;">
{{else}}
<div class="progress-bar" style="--width: 100%;background: #eb8e93;">
{{/if}}
</div>
</div>
</li>
Expand Down
Binary file added resources/Template/training/imgs/bg.jpg
Binary file added resources/Template/training/imgs/no_phantom.png
Loading

0 comments on commit 95788da

Please sign in to comment.