koishi-plugin-ggcevo-game 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +27 -26
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -93,6 +93,8 @@ function apply(ctx, config) {
|
|
|
93
93
|
// 玩家名称
|
|
94
94
|
rank: "integer",
|
|
95
95
|
// rank分数(带正负)
|
|
96
|
+
wins: "unsigned",
|
|
97
|
+
// 胜场
|
|
96
98
|
matches: "unsigned",
|
|
97
99
|
// 比赛次数
|
|
98
100
|
Blacklist: {
|
|
@@ -411,7 +413,7 @@ ${itemDetails.join("\n")}`;
|
|
|
411
413
|
}
|
|
412
414
|
if (!latestTime) return "您还没有游玩过 咕咕虫-evolved 地图";
|
|
413
415
|
const targetDateChina = new Date(latestTime);
|
|
414
|
-
targetDateChina.
|
|
416
|
+
targetDateChina.setUTCDate(targetDateChina.getUTCDate() + 1);
|
|
415
417
|
if (!isSameDate(latestTime, currentChinaTime) && !isSameDate(targetDateChina, currentChinaTime)) {
|
|
416
418
|
return "暂未查询到您最近两天内游玩过 咕咕虫-evolved 地图,请游玩1次后签到(对局记录上传有延迟)";
|
|
417
419
|
}
|
|
@@ -419,14 +421,14 @@ ${itemDetails.join("\n")}`;
|
|
|
419
421
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
420
422
|
if (record) {
|
|
421
423
|
const lastSignChina = convertUTCtoChinaTime(record.lastSign);
|
|
422
|
-
if (lastSignChina.
|
|
424
|
+
if (lastSignChina.getUTCDate() === currentChinaTime.getUTCDate()) {
|
|
423
425
|
return `您今天已经签到过了!本月累计签到 ${record.monthlyDays} 天`;
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
let monthlyDays = 1;
|
|
427
429
|
if (record) {
|
|
428
430
|
const lastSignChina = convertUTCtoChinaTime(record.lastSign);
|
|
429
|
-
if (currentChinaTime.
|
|
431
|
+
if (currentChinaTime.getUTCFullYear() !== lastSignChina.getUTCFullYear() || currentChinaTime.getUTCMonth() !== lastSignChina.getUTCMonth()) {
|
|
430
432
|
monthlyDays = 1;
|
|
431
433
|
} else {
|
|
432
434
|
monthlyDays = record.monthlyDays + 1;
|
|
@@ -478,10 +480,10 @@ ${itemDetails.join("\n")}`;
|
|
|
478
480
|
const lastSignChina = convertUTCtoChinaTime(record.lastSign);
|
|
479
481
|
const targetDateChina = new Date(lastSignChina);
|
|
480
482
|
const nowChina = convertUTCtoChinaTime(/* @__PURE__ */ new Date());
|
|
481
|
-
const currentYear = nowChina.
|
|
482
|
-
const currentMonth = nowChina.
|
|
483
|
-
const yesterday = new Date(targetDateChina).
|
|
484
|
-
if (targetDateChina.
|
|
483
|
+
const currentYear = nowChina.getUTCFullYear();
|
|
484
|
+
const currentMonth = nowChina.getUTCMonth();
|
|
485
|
+
const yesterday = new Date(targetDateChina).getUTCDate() - 1;
|
|
486
|
+
if (targetDateChina.getUTCFullYear() !== currentYear || targetDateChina.getUTCMonth() !== currentMonth || // 必须当月
|
|
485
487
|
record.monthlyDays > yesterday) {
|
|
486
488
|
return "暂时没有可补签的日期。";
|
|
487
489
|
}
|
|
@@ -572,15 +574,15 @@ ${itemDetails.join("\n")}`;
|
|
|
572
574
|
}
|
|
573
575
|
const now = /* @__PURE__ */ new Date();
|
|
574
576
|
const chinatime = convertUTCtoChinaTime(now);
|
|
575
|
-
const currentYear = chinatime.
|
|
576
|
-
const currentMonth = chinatime.
|
|
577
|
+
const currentYear = chinatime.getUTCFullYear();
|
|
578
|
+
const currentMonth = chinatime.getUTCMonth();
|
|
577
579
|
const [adminRecord] = await ctx.database.get("ggcevo_adminbenefit", {
|
|
578
580
|
userId: session.userId
|
|
579
581
|
});
|
|
580
582
|
if (adminRecord) {
|
|
581
583
|
const lastSignTime = convertUTCtoChinaTime(adminRecord.lastSign);
|
|
582
|
-
const lastYear = lastSignTime.
|
|
583
|
-
const lastMonth = lastSignTime.
|
|
584
|
+
const lastYear = lastSignTime.getUTCFullYear();
|
|
585
|
+
const lastMonth = lastSignTime.getUTCMonth();
|
|
584
586
|
if (lastYear === currentYear && lastMonth === currentMonth) {
|
|
585
587
|
return `本月管理津贴已领取,${currentMonth + 2} 月1日可再次领取`;
|
|
586
588
|
}
|
|
@@ -767,6 +769,7 @@ ID:${activity.id}
|
|
|
767
769
|
handle,
|
|
768
770
|
name: record.profile.name,
|
|
769
771
|
rank: record.decision === "win" ? (ggcrank?.rank || 0) + 150 : (ggcrank?.rank || 0) - 50,
|
|
772
|
+
wins: (ggcrank?.wins || 0) + (record.decision === "win" ? 1 : 0),
|
|
770
773
|
matches: (ggcrank?.matches || 0) + 1
|
|
771
774
|
}]);
|
|
772
775
|
}
|
|
@@ -826,6 +829,7 @@ ID:${activity.id}
|
|
|
826
829
|
handle,
|
|
827
830
|
name: record.profile.name,
|
|
828
831
|
rank: record.decision === "win" ? (ggcrank?.rank || 0) + 150 : (ggcrank?.rank || 0) - 50,
|
|
832
|
+
wins: (ggcrank?.wins || 0) + (record.decision === "win" ? 1 : 0),
|
|
829
833
|
matches: (ggcrank?.matches || 0) + 1
|
|
830
834
|
}]);
|
|
831
835
|
}
|
|
@@ -851,8 +855,7 @@ ID:${activity.id}
|
|
|
851
855
|
ctx.database.select("ggcevo_rank").where({ Blacklist: false }).orderBy("rank", "desc").limit(10).offset(offset).execute(),
|
|
852
856
|
ctx.database.select("ggcevo_rank").where({ Blacklist: false }).execute((row) => import_koishi.$.count(row.handle))
|
|
853
857
|
]);
|
|
854
|
-
const
|
|
855
|
-
const totalPages = Math.ceil(total / pageSize);
|
|
858
|
+
const totalPages = Math.ceil(total / 10);
|
|
856
859
|
if (pageNum > totalPages) return `最多有 ${totalPages} 页`;
|
|
857
860
|
const processedRecords = await Promise.all(
|
|
858
861
|
records.map(async (item) => ({
|
|
@@ -861,11 +864,11 @@ ID:${activity.id}
|
|
|
861
864
|
}))
|
|
862
865
|
);
|
|
863
866
|
const rankingText = processedRecords.map(
|
|
864
|
-
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} |
|
|
867
|
+
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} | 胜率: ${item.matches === 0 ? "0.00%" : (item.wins / item.matches * 100).toFixed(2) + "%"}`
|
|
865
868
|
).join("\n");
|
|
866
869
|
return [
|
|
867
870
|
`🏆 GGCEvo S1赛季胜点榜 🏆`,
|
|
868
|
-
|
|
871
|
+
`本赛季从4月1日至5月15日23点结算`,
|
|
869
872
|
`第 ${pageNum} 页 共 ${totalPages} 页`,
|
|
870
873
|
"------------------------------",
|
|
871
874
|
rankingText,
|
|
@@ -899,6 +902,7 @@ ID:${activity.id}
|
|
|
899
902
|
句柄:${user.handle}
|
|
900
903
|
当前积分:${user.rank}
|
|
901
904
|
参赛次数:${user.matches} 次
|
|
905
|
+
胜率: ${user.matches === 0 ? "0.00%" : (user.wins / user.matches * 100).toFixed(2) + "%"}
|
|
902
906
|
全服排名:第 ${userRank} 位
|
|
903
907
|
------------------------------`;
|
|
904
908
|
} else {
|
|
@@ -1316,19 +1320,16 @@ ${achievementList.join("\n")}`;
|
|
|
1316
1320
|
"──────────────"
|
|
1317
1321
|
);
|
|
1318
1322
|
}
|
|
1319
|
-
const achievements = await ctx.database.get("ggcevo_achievements", { handle });
|
|
1320
|
-
if (achievements
|
|
1323
|
+
const [achievements] = await ctx.database.get("ggcevo_achievements", { handle });
|
|
1324
|
+
if (achievements) {
|
|
1321
1325
|
output.push(
|
|
1322
1326
|
"🏆 已获成就:",
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
});
|
|
1330
|
-
return `${a.achievementname} (${date})`;
|
|
1331
|
-
}),
|
|
1327
|
+
`${achievements.achievementname} (${achievements.gaintime.toLocaleDateString("zh-CN", {
|
|
1328
|
+
timeZone: "Asia/Shanghai",
|
|
1329
|
+
year: "numeric",
|
|
1330
|
+
month: "2-digit",
|
|
1331
|
+
day: "2-digit"
|
|
1332
|
+
})})`,
|
|
1332
1333
|
"──────────────"
|
|
1333
1334
|
);
|
|
1334
1335
|
}
|