koishi-plugin-ggcevo-game 0.4.4 → 0.4.6
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.js +24 -29
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -103,7 +103,6 @@ function apply(ctx, config) {
|
|
|
103
103
|
// 复合主键
|
|
104
104
|
});
|
|
105
105
|
ctx.model.extend("ggcevo_Punishment", {
|
|
106
|
-
// 各字段定义
|
|
107
106
|
id: "unsigned",
|
|
108
107
|
// 自增序号
|
|
109
108
|
name: "string",
|
|
@@ -123,13 +122,11 @@ function apply(ctx, config) {
|
|
|
123
122
|
comment: "text"
|
|
124
123
|
// 备注信息(可选)
|
|
125
124
|
}, {
|
|
126
|
-
// 额外配置
|
|
127
125
|
primary: "id",
|
|
128
126
|
autoInc: true
|
|
129
127
|
// 启用自增ID
|
|
130
128
|
});
|
|
131
129
|
ctx.model.extend("ggcevo_exchange", {
|
|
132
|
-
// 各字段定义
|
|
133
130
|
userId: "string",
|
|
134
131
|
handle: "string",
|
|
135
132
|
// 句柄
|
|
@@ -139,26 +136,20 @@ function apply(ctx, config) {
|
|
|
139
136
|
date: "timestamp",
|
|
140
137
|
GlobalLimit: "boolean"
|
|
141
138
|
}, {
|
|
142
|
-
// 额外配置
|
|
143
139
|
primary: ["handle", "item"]
|
|
144
140
|
});
|
|
145
141
|
ctx.model.extend("ggcevo_adminbenefit", {
|
|
146
|
-
// 各字段定义
|
|
147
142
|
userId: "string",
|
|
148
143
|
handle: "string",
|
|
149
|
-
// 句柄
|
|
150
144
|
signmonth: "unsigned",
|
|
151
145
|
lastSign: "timestamp"
|
|
152
146
|
}, {
|
|
153
|
-
// 额外配置
|
|
154
147
|
primary: "userId"
|
|
155
148
|
});
|
|
156
149
|
ctx.model.extend("ggcevo_blacklist", {
|
|
157
|
-
// 各字段定义
|
|
158
150
|
handle: "string",
|
|
159
151
|
createdAt: "timestamp"
|
|
160
152
|
}, {
|
|
161
|
-
// 额外配置
|
|
162
153
|
primary: "handle"
|
|
163
154
|
});
|
|
164
155
|
const initDefaultItems = {
|
|
@@ -677,7 +668,7 @@ ID:${activity.id}
|
|
|
677
668
|
hour12: false
|
|
678
669
|
}), "formatTime");
|
|
679
670
|
const output = activities.map((activity) => [
|
|
680
|
-
|
|
671
|
+
`活动: ${activity.name}`,
|
|
681
672
|
`时间:${formatTime(activity.startTime)} ~ ${formatTime(activity.endTime)}`,
|
|
682
673
|
`描述:${activity.description}`,
|
|
683
674
|
`奖励:${activity.quantity} 枚咕咕币`,
|
|
@@ -831,27 +822,29 @@ ID:${activity.id}
|
|
|
831
822
|
const pageNum = parseInt(page) || 1;
|
|
832
823
|
if (pageNum < 1) return "请输入有效的页码。";
|
|
833
824
|
const offset = (pageNum - 1) * 10;
|
|
834
|
-
const records = await
|
|
835
|
-
|
|
825
|
+
const [records, total] = await Promise.all([
|
|
826
|
+
ctx.database.select("ggcevo_rank").orderBy("rank", "desc").limit(10).offset(offset).execute(),
|
|
827
|
+
ctx.database.select("ggcevo_rank").execute((row) => import_koishi.$.count(row.profileId))
|
|
828
|
+
]);
|
|
829
|
+
const pageSize = 10;
|
|
830
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
831
|
+
if (pageNum > totalPages) return `最多有 ${totalPages} 页`;
|
|
836
832
|
const processedRecords = await Promise.all(
|
|
837
|
-
records.map(async (item) => {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
displayName: isSafe ? item.name : (item.name[0] || "") + "***"
|
|
842
|
-
// 处理空名字的情况
|
|
843
|
-
};
|
|
844
|
-
})
|
|
833
|
+
records.map(async (item) => ({
|
|
834
|
+
...item,
|
|
835
|
+
displayName: await checkSensitiveWord(item.name) ? item.name : (item.name[0] || "") + "***"
|
|
836
|
+
}))
|
|
845
837
|
);
|
|
846
|
-
const rankingText = processedRecords.map(
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
------------------------------
|
|
852
|
-
|
|
853
|
-
------------------------------
|
|
854
|
-
|
|
838
|
+
const rankingText = processedRecords.map(
|
|
839
|
+
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} | 参赛: ${item.matches} 次`
|
|
840
|
+
).join("\n");
|
|
841
|
+
return [
|
|
842
|
+
`🏆 GGCEvo 胜点榜 第 ${pageNum} 页 / 共 ${totalPages} 页 🏆`,
|
|
843
|
+
"------------------------------",
|
|
844
|
+
rankingText,
|
|
845
|
+
"------------------------------",
|
|
846
|
+
pageNum < totalPages ? `输入“胜点榜 ${pageNum + 1}”查看下一页` : "已是最后一页"
|
|
847
|
+
].join("\n");
|
|
855
848
|
});
|
|
856
849
|
ctx.command("ggcevo/排名 [player]", "查询个人排名").alias("rank").usage("输入“排名”查看自己的排名信息").action(async (argv, player) => {
|
|
857
850
|
const session = argv.session;
|
|
@@ -876,6 +869,7 @@ ID:${activity.id}
|
|
|
876
869
|
return `🎮 您的 GGCEvo 排名信息 🎮
|
|
877
870
|
------------------------------
|
|
878
871
|
昵称:${displayName}
|
|
872
|
+
句柄:${user.regionId}-S2-${user.realmId}-${user.profileId}
|
|
879
873
|
当前积分:${user.rank}
|
|
880
874
|
参赛次数:${user.matches} 次
|
|
881
875
|
全服排名:第 ${userRank} 位
|
|
@@ -907,6 +901,7 @@ ID:${activity.id}
|
|
|
907
901
|
return `🎮 他/她的 GGCEvo 排名信息 🎮
|
|
908
902
|
------------------------------
|
|
909
903
|
昵称:${displayName}
|
|
904
|
+
句柄:${user.regionId}-S2-${user.realmId}-${user.profileId}
|
|
910
905
|
当前积分:${user.rank}
|
|
911
906
|
参赛次数:${user.matches} 次
|
|
912
907
|
全服排名:第 ${userRank} 位
|