koishi-plugin-game-mini 0.2.7 → 0.2.9
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 +5 -2
- package/lib/index.js +56 -83
- package/package.json +1 -1
- package/readme.md +9 -11
package/lib/index.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ export interface Config {
|
|
|
55
55
|
autoPlayMaxCount: number;
|
|
56
56
|
autoStopInactiveTime: number;
|
|
57
57
|
enablePenalty: boolean;
|
|
58
|
-
rewardScore: number;
|
|
59
58
|
penaltyScore: number;
|
|
59
|
+
rewardScore: number;
|
|
60
60
|
messages: {
|
|
61
61
|
usage: string;
|
|
62
62
|
start: string;
|
|
@@ -80,6 +80,7 @@ export interface Config {
|
|
|
80
80
|
autoStopInactiveTime: number;
|
|
81
81
|
rewardScore: number;
|
|
82
82
|
messages: {
|
|
83
|
+
usage: string;
|
|
83
84
|
start: string;
|
|
84
85
|
startUsage: string;
|
|
85
86
|
stop: string;
|
|
@@ -103,6 +104,7 @@ export interface Config {
|
|
|
103
104
|
autoStopInactiveTime: number;
|
|
104
105
|
rewardScore: number;
|
|
105
106
|
messages: {
|
|
107
|
+
usage: string;
|
|
106
108
|
start: string;
|
|
107
109
|
stop: string;
|
|
108
110
|
submitUsage: string;
|
|
@@ -129,8 +131,8 @@ export interface Config {
|
|
|
129
131
|
autoStopInactiveTime: number;
|
|
130
132
|
maxRounds: number;
|
|
131
133
|
botParticipate: boolean;
|
|
132
|
-
rewardScore: number;
|
|
133
134
|
messages: {
|
|
135
|
+
usage: string;
|
|
134
136
|
start: string;
|
|
135
137
|
stop: string;
|
|
136
138
|
notStarted: string;
|
|
@@ -171,6 +173,7 @@ export interface Config {
|
|
|
171
173
|
autoStopInactiveTime: number;
|
|
172
174
|
rewardScore: number;
|
|
173
175
|
messages: {
|
|
176
|
+
usage: string;
|
|
174
177
|
start: string;
|
|
175
178
|
stop: string;
|
|
176
179
|
notStarted: string;
|
package/lib/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const defaultMessages = {
|
|
|
30
30
|
autoStop: "太久没人玩啦,比赛自动结束~"
|
|
31
31
|
},
|
|
32
32
|
wzHero: {
|
|
33
|
+
usage: "用法错误!正确用法:猜王者英雄 开始 | [答案] | 提示 | 结束",
|
|
33
34
|
start: "猜王者英雄开始!本次共 {0} 回合~当前难度:{1}",
|
|
34
35
|
startUsage: "用法错误!正确用法:猜王者英雄 开始 | [答案] | 提示 | 结束",
|
|
35
36
|
stop: "猜王者英雄比赛已停止",
|
|
@@ -46,9 +47,10 @@ const defaultMessages = {
|
|
|
46
47
|
autoStop: "太久没人玩啦,比赛自动结束~"
|
|
47
48
|
},
|
|
48
49
|
chengyuImage: {
|
|
50
|
+
usage: "用法错误!正确用法:看图猜成语 开始 | [答案] | 提示 | 结束",
|
|
49
51
|
start: "看图猜成语比赛开始!本次共 {0} 回合~当前提示级别:{1}",
|
|
50
52
|
stop: "看图猜成语比赛已停止",
|
|
51
|
-
submitUsage: "
|
|
53
|
+
submitUsage: "用法错误!正确用法:看图猜成语 开始 | [答案] | 提示 | 结束",
|
|
52
54
|
notStarted: "看图猜成语比赛尚未开始,请输入 看图猜成语 开始 开始游戏",
|
|
53
55
|
next: "第 {0} 题来啦!",
|
|
54
56
|
hintGet: "【提示】{0}",
|
|
@@ -64,10 +66,11 @@ const defaultMessages = {
|
|
|
64
66
|
autoStop: "太久没人玩啦,比赛自动结束~"
|
|
65
67
|
},
|
|
66
68
|
chengyuJielong: {
|
|
69
|
+
usage: "用法错误!正确用法:成语接龙 开始 | [成语] | 结束",
|
|
67
70
|
start: "成语接龙比赛开始!本次共 {0} 回合~我先来~",
|
|
68
71
|
stop: "成语接龙比赛已停止",
|
|
69
72
|
notStarted: "成语接龙比赛尚未开始,请输入 成语接龙 开始 开始游戏",
|
|
70
|
-
joinUsage: "
|
|
73
|
+
joinUsage: "用法错误!正确用法:成语接龙 开始 | [成语] | 结束",
|
|
71
74
|
apiError: "API请求失败,请稍后再试",
|
|
72
75
|
botTurn: "该我了!我接:{0}",
|
|
73
76
|
botWin: "哈哈我接不上了!本轮结束~",
|
|
@@ -83,6 +86,7 @@ const defaultMessages = {
|
|
|
83
86
|
autoStop: "太久没人玩啦,比赛自动结束~"
|
|
84
87
|
},
|
|
85
88
|
calc24: {
|
|
89
|
+
usage: "用法错误!正确用法:算24点 开始 | [算式] | 换题 | 结束",
|
|
86
90
|
start: "算24点游戏开始!本次共 {0} 回合~当前难度:{1}",
|
|
87
91
|
stop: "算24点游戏已停止",
|
|
88
92
|
notStarted: "算24点游戏尚未开始,请输入 算24点 开始 开始游戏",
|
|
@@ -154,9 +158,9 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
154
158
|
autoPlayDelay: koishi_1.Schema.number().min(0).default(10).description('机器人自动操作延迟(秒)'),
|
|
155
159
|
autoPlayMaxCount: koishi_1.Schema.number().min(1).default(5).description('机器人最大自动操作次数'),
|
|
156
160
|
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
157
|
-
enablePenalty: koishi_1.Schema.boolean().default(true).description('
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
enablePenalty: koishi_1.Schema.boolean().default(true).description('启用惩罚机制(猜中者扣分,其他人加分)'),
|
|
162
|
+
penaltyScore: koishi_1.Schema.number().max(0).default(-1).description('猜中者扣除分数(负数)'),
|
|
163
|
+
rewardScore: koishi_1.Schema.number().min(0).default(1).description('其他人奖励分数'),
|
|
160
164
|
messages: koishi_1.Schema.object({
|
|
161
165
|
usage: koishi_1.Schema.string().default(defaultMessages.guessNumber.usage).description('用法错误提示\n{0}-最小值, {1}-最大值'),
|
|
162
166
|
start: koishi_1.Schema.string().default(defaultMessages.guessNumber.start).description('游戏开始提示\n{0}-总回合数'),
|
|
@@ -170,7 +174,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
170
174
|
rankTitle: koishi_1.Schema.string().default(defaultMessages.guessNumber.rankTitle).description('本局排行榜标题'),
|
|
171
175
|
rankEmpty: koishi_1.Schema.string().default(defaultMessages.guessNumber.rankEmpty).description('本局排行榜为空提示'),
|
|
172
176
|
disabled: koishi_1.Schema.string().default(defaultMessages.guessNumber.disabled).description('功能禁用提示'),
|
|
173
|
-
autoStop: koishi_1.Schema.string().default(
|
|
177
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.guessNumber.autoStop).description('自动停止提示'),
|
|
174
178
|
}).description('💬 猜数字消息配置'),
|
|
175
179
|
}).description('🎲 猜数字游戏配置'),
|
|
176
180
|
}),
|
|
@@ -182,6 +186,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
182
186
|
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
183
187
|
rewardScore: koishi_1.Schema.number().min(0).default(1).description('答对奖励分数'),
|
|
184
188
|
messages: koishi_1.Schema.object({
|
|
189
|
+
usage: koishi_1.Schema.string().default(defaultMessages.wzHero.usage).description('用法错误提示'),
|
|
185
190
|
start: koishi_1.Schema.string().default(defaultMessages.wzHero.start).description('游戏开始提示\n{0}-总回合数, {1}-难度'),
|
|
186
191
|
startUsage: koishi_1.Schema.string().default(defaultMessages.wzHero.startUsage).description('开始用法提示'),
|
|
187
192
|
stop: koishi_1.Schema.string().default(defaultMessages.wzHero.stop).description('游戏停止提示'),
|
|
@@ -195,7 +200,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
195
200
|
rankTitle: koishi_1.Schema.string().default(defaultMessages.wzHero.rankTitle).description('本局排行榜标题'),
|
|
196
201
|
rankEmpty: koishi_1.Schema.string().default(defaultMessages.wzHero.rankEmpty).description('本局排行榜为空提示'),
|
|
197
202
|
disabled: koishi_1.Schema.string().default(defaultMessages.wzHero.disabled).description('功能禁用提示'),
|
|
198
|
-
autoStop: koishi_1.Schema.string().default(
|
|
203
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.wzHero.autoStop).description('自动停止提示'),
|
|
199
204
|
}).description('💬 王者英雄猜谜消息配置'),
|
|
200
205
|
}).description('⚔️ 王者英雄猜谜配置'),
|
|
201
206
|
}),
|
|
@@ -207,6 +212,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
207
212
|
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
208
213
|
rewardScore: koishi_1.Schema.number().min(0).default(1).description('答对奖励分数'),
|
|
209
214
|
messages: koishi_1.Schema.object({
|
|
215
|
+
usage: koishi_1.Schema.string().default(defaultMessages.chengyuImage.usage).description('用法错误提示'),
|
|
210
216
|
start: koishi_1.Schema.string().default(defaultMessages.chengyuImage.start).description('游戏开始提示\n{0}-总回合数, {1}-提示级别'),
|
|
211
217
|
stop: koishi_1.Schema.string().default(defaultMessages.chengyuImage.stop).description('游戏停止提示'),
|
|
212
218
|
submitUsage: koishi_1.Schema.string().default(defaultMessages.chengyuImage.submitUsage).description('提交答案用法提示'),
|
|
@@ -222,7 +228,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
222
228
|
rankTitle: koishi_1.Schema.string().default(defaultMessages.chengyuImage.rankTitle).description('本局排行榜标题'),
|
|
223
229
|
rankEmpty: koishi_1.Schema.string().default(defaultMessages.chengyuImage.rankEmpty).description('本局排行榜为空提示'),
|
|
224
230
|
disabled: koishi_1.Schema.string().default(defaultMessages.chengyuImage.disabled).description('功能禁用提示'),
|
|
225
|
-
autoStop: koishi_1.Schema.string().default(
|
|
231
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.chengyuImage.autoStop).description('自动停止提示'),
|
|
226
232
|
}).description('💬 看图猜成语消息配置'),
|
|
227
233
|
}).description('🖼️ 看图猜成语配置'),
|
|
228
234
|
}),
|
|
@@ -235,8 +241,8 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
235
241
|
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
236
242
|
maxRounds: koishi_1.Schema.number().min(0).default(10).description('最大接龙回合数(0为无限)'),
|
|
237
243
|
botParticipate: koishi_1.Schema.boolean().default(false).description('机器人是否参与接龙'),
|
|
238
|
-
rewardScore: koishi_1.Schema.number().min(0).default(1).description('接龙成功奖励分数'),
|
|
239
244
|
messages: koishi_1.Schema.object({
|
|
245
|
+
usage: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.usage).description('用法错误提示'),
|
|
240
246
|
start: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.start).description('游戏开始提示\n{0}-总回合数'),
|
|
241
247
|
stop: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.stop).description('游戏停止提示'),
|
|
242
248
|
notStarted: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.notStarted).description('游戏未开始提示'),
|
|
@@ -253,7 +259,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
253
259
|
rankTitle: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.rankTitle).description('本局排行榜标题'),
|
|
254
260
|
rankEmpty: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.rankEmpty).description('本局排行榜为空提示'),
|
|
255
261
|
disabled: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.disabled).description('功能禁用提示'),
|
|
256
|
-
autoStop: koishi_1.Schema.string().default(
|
|
262
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.autoStop).description('自动停止提示'),
|
|
257
263
|
}).description('💬 成语接龙消息配置'),
|
|
258
264
|
}).description('🐉 成语接龙配置'),
|
|
259
265
|
}),
|
|
@@ -279,6 +285,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
279
285
|
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
280
286
|
rewardScore: koishi_1.Schema.number().min(0).default(1).description('答对奖励分数'),
|
|
281
287
|
messages: koishi_1.Schema.object({
|
|
288
|
+
usage: koishi_1.Schema.string().default(defaultMessages.calc24.usage).description('用法错误提示'),
|
|
282
289
|
start: koishi_1.Schema.string().default(defaultMessages.calc24.start).description('游戏开始提示\n{0}-总回合数, {1}-难度'),
|
|
283
290
|
stop: koishi_1.Schema.string().default(defaultMessages.calc24.stop).description('游戏停止提示'),
|
|
284
291
|
notStarted: koishi_1.Schema.string().default(defaultMessages.calc24.notStarted).description('游戏未开始提示'),
|
|
@@ -291,7 +298,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
291
298
|
rankTitle: koishi_1.Schema.string().default(defaultMessages.calc24.rankTitle).description('本局排行榜标题'),
|
|
292
299
|
rankEmpty: koishi_1.Schema.string().default(defaultMessages.calc24.rankEmpty).description('本局排行榜为空提示'),
|
|
293
300
|
disabled: koishi_1.Schema.string().default(defaultMessages.calc24.disabled).description('功能禁用提示'),
|
|
294
|
-
autoStop: koishi_1.Schema.string().default(
|
|
301
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.calc24.autoStop).description('自动停止提示'),
|
|
295
302
|
}).description('💬 算24点消息配置'),
|
|
296
303
|
}).description('🧮 算24点配置'),
|
|
297
304
|
}),
|
|
@@ -303,8 +310,8 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
303
310
|
koishi_1.Schema.object({
|
|
304
311
|
commonMessages: koishi_1.Schema.object({
|
|
305
312
|
gameRunning: koishi_1.Schema.string().default(defaultMessages.common.gameRunning).description('游戏运行中提示'),
|
|
306
|
-
gameStoppedByInactive: koishi_1.Schema.string().default(
|
|
307
|
-
paramError: koishi_1.Schema.string().default(
|
|
313
|
+
gameStoppedByInactive: koishi_1.Schema.string().default(defaultMessages.common.gameStoppedByInactive).description('无操作停止提示'),
|
|
314
|
+
paramError: koishi_1.Schema.string().default(defaultMessages.common.paramError).description('参数错误提示'),
|
|
308
315
|
}).description('💬 通用消息配置'),
|
|
309
316
|
}),
|
|
310
317
|
]);
|
|
@@ -397,7 +404,7 @@ async function apply(ctx, cfg) {
|
|
|
397
404
|
playCount: 0,
|
|
398
405
|
lastGameTime: 0
|
|
399
406
|
};
|
|
400
|
-
|
|
407
|
+
await ctx.database.create('game_mini_player', newPlayer);
|
|
401
408
|
return {
|
|
402
409
|
guildId,
|
|
403
410
|
platform,
|
|
@@ -669,33 +676,23 @@ async function apply(ctx, cfg) {
|
|
|
669
676
|
};
|
|
670
677
|
const scheduleAutoPlay = (session, key, st) => {
|
|
671
678
|
clearAllTimers(st);
|
|
672
|
-
if (
|
|
673
|
-
|
|
679
|
+
if (st.chengyuJielong.currentRound === 1 && st.chengyuJielong.jielongCount === 0) {
|
|
680
|
+
const delay = 100;
|
|
681
|
+
st.chengyuJielong.autoPlayTimer = setTimeout(() => {
|
|
682
|
+
doAutoPlay(session, key, st);
|
|
683
|
+
}, delay);
|
|
674
684
|
return;
|
|
675
685
|
}
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
doAutoPlay(session, key, st);
|
|
683
|
-
}, delay);
|
|
686
|
+
if (cfg.chengyuJielong.botParticipate && st.chengyuJielong.botTurn) {
|
|
687
|
+
const delay = cfg.chengyuJielong.autoPlayDelay * 1000;
|
|
688
|
+
st.chengyuJielong.autoPlayTimer = setTimeout(() => {
|
|
689
|
+
doAutoPlay(session, key, st);
|
|
690
|
+
}, delay);
|
|
691
|
+
}
|
|
684
692
|
};
|
|
685
693
|
const doAutoPlay = async (session, key, st) => {
|
|
686
694
|
if (!st.chengyuJielong.started)
|
|
687
695
|
return;
|
|
688
|
-
if (st.chengyuJielong.hasTriggeredAutoPlay)
|
|
689
|
-
return;
|
|
690
|
-
if (st.chengyuJielong.autoPlayCount >= cfg.chengyuJielong.autoPlayMaxCount) {
|
|
691
|
-
st.chengyuJielong.hasTriggeredAutoPlay = true;
|
|
692
|
-
gameStates.set(key, st);
|
|
693
|
-
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
st.chengyuJielong.hasTriggeredAutoPlay = true;
|
|
697
|
-
st.chengyuJielong.autoPlayCount += 1;
|
|
698
|
-
gameStates.set(key, st);
|
|
699
696
|
try {
|
|
700
697
|
const intUserId = getIntUserId(session);
|
|
701
698
|
const r = await axios_1.default.get('https://api.suol.cc/v1/game_cyjl.php', {
|
|
@@ -715,14 +712,17 @@ async function apply(ctx, cfg) {
|
|
|
715
712
|
m = d.chengyuJielong.botTurn.replace('{0}', sys.idiom);
|
|
716
713
|
st.chengyuJielong.lastChar = dt.data.current_char || '';
|
|
717
714
|
st.chengyuJielong.jielongCount += 1;
|
|
715
|
+
st.chengyuJielong.botTurn = false;
|
|
716
|
+
await session.send(m);
|
|
718
717
|
}
|
|
719
718
|
else {
|
|
720
719
|
m = dt.msg || d.chengyuJielong.botWin;
|
|
721
720
|
st.chengyuJielong.currentRound += 1;
|
|
721
|
+
st.chengyuJielong.botTurn = true;
|
|
722
|
+
await session.send(m);
|
|
722
723
|
if (st.chengyuJielong.currentRound > st.chengyuJielong.totalRounds) {
|
|
723
724
|
st.chengyuJielong.started = false;
|
|
724
725
|
clearAllTimers(st);
|
|
725
|
-
await session.send(m);
|
|
726
726
|
await session.send(d.chengyuJielong.gameEnd);
|
|
727
727
|
if (cfg.chengyuJielong.showRank && !isPrivate(session)) {
|
|
728
728
|
const rankText = generateGameRankText(st.chengyuJielong.players, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
@@ -733,13 +733,12 @@ async function apply(ctx, cfg) {
|
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
else {
|
|
736
|
-
|
|
736
|
+
await session.send(d.chengyuJielong.roundEnd.replace('{0}', st.chengyuJielong.currentRound.toString()).replace('{1}', (st.chengyuJielong.totalRounds - st.chengyuJielong.currentRound).toString()));
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
if (cfg.chengyuJielong.maxRounds > 0 && st.chengyuJielong.jielongCount >= cfg.chengyuJielong.maxRounds) {
|
|
740
740
|
st.chengyuJielong.started = false;
|
|
741
741
|
clearAllTimers(st);
|
|
742
|
-
await session.send(m);
|
|
743
742
|
await session.send(d.chengyuJielong.gameEnd);
|
|
744
743
|
if (cfg.chengyuJielong.showRank && !isPrivate(session)) {
|
|
745
744
|
const rankText = generateGameRankText(st.chengyuJielong.players, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
@@ -749,7 +748,6 @@ async function apply(ctx, cfg) {
|
|
|
749
748
|
gameStates.set(key, st);
|
|
750
749
|
return;
|
|
751
750
|
}
|
|
752
|
-
await session.send(m);
|
|
753
751
|
}
|
|
754
752
|
catch (error) {
|
|
755
753
|
await session.send(d.chengyuJielong.apiError);
|
|
@@ -788,10 +786,14 @@ async function apply(ctx, cfg) {
|
|
|
788
786
|
st.chengyuJielong.participants.push(playerKey);
|
|
789
787
|
await updatePlayerPlayCount(session);
|
|
790
788
|
}
|
|
789
|
+
if (st.chengyuJielong.botTurn) {
|
|
790
|
+
await session.send('现在是机器人的回合,请稍候...');
|
|
791
|
+
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
791
794
|
if (!isFourCharIdiom(content)) {
|
|
792
795
|
await session.send(d.chengyuJielong.notIdiom);
|
|
793
796
|
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
794
|
-
scheduleAutoPlay(session, key, st);
|
|
795
797
|
return;
|
|
796
798
|
}
|
|
797
799
|
try {
|
|
@@ -813,9 +815,7 @@ async function apply(ctx, cfg) {
|
|
|
813
815
|
if (dt.data?.user) {
|
|
814
816
|
m += d.chengyuJielong.correct + '\n';
|
|
815
817
|
m += `你的成语:${dt.data.user.idiom}\n`;
|
|
816
|
-
st.chengyuJielong.
|
|
817
|
-
st.chengyuJielong.players[playerKey].correctCount += 1;
|
|
818
|
-
await savePlayerData(session, st.chengyuJielong.players[playerKey]);
|
|
818
|
+
st.chengyuJielong.botTurn = true;
|
|
819
819
|
}
|
|
820
820
|
else {
|
|
821
821
|
m += d.chengyuJielong.wrong + '\n';
|
|
@@ -826,35 +826,8 @@ async function apply(ctx, cfg) {
|
|
|
826
826
|
st.chengyuJielong.jielongCount += 1;
|
|
827
827
|
}
|
|
828
828
|
st.chengyuJielong.currentRound += 1;
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
clearAllTimers(st);
|
|
832
|
-
await session.send(m);
|
|
833
|
-
await session.send(d.chengyuJielong.gameEnd);
|
|
834
|
-
if (cfg.chengyuJielong.showRank && !isPrivate(session)) {
|
|
835
|
-
const rankText = generateGameRankText(st.chengyuJielong.players, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
836
|
-
await session.send(rankText);
|
|
837
|
-
}
|
|
838
|
-
clearGameData(st.chengyuJielong);
|
|
839
|
-
gameStates.set(key, st);
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
if (st.chengyuJielong.currentRound > st.chengyuJielong.totalRounds) {
|
|
843
|
-
st.chengyuJielong.started = false;
|
|
844
|
-
clearAllTimers(st);
|
|
845
|
-
await session.send(m);
|
|
846
|
-
await session.send(d.chengyuJielong.gameEnd);
|
|
847
|
-
if (cfg.chengyuJielong.showRank && !isPrivate(session)) {
|
|
848
|
-
const rankText = generateGameRankText(st.chengyuJielong.players, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
849
|
-
await session.send(rankText);
|
|
850
|
-
}
|
|
851
|
-
clearGameData(st.chengyuJielong);
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
m += '\n' + d.chengyuJielong.roundEnd.replace('{0}', st.chengyuJielong.currentRound.toString()).replace('{1}', (st.chengyuJielong.totalRounds - st.chengyuJielong.currentRound).toString());
|
|
855
|
-
await session.send(m);
|
|
856
|
-
st.chengyuJielong.hasTriggeredAutoPlay = false;
|
|
857
|
-
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
829
|
+
await session.send(m);
|
|
830
|
+
if (cfg.chengyuJielong.botParticipate && st.chengyuJielong.botTurn) {
|
|
858
831
|
scheduleAutoPlay(session, key, st);
|
|
859
832
|
}
|
|
860
833
|
}
|
|
@@ -866,9 +839,8 @@ async function apply(ctx, cfg) {
|
|
|
866
839
|
}
|
|
867
840
|
catch (error) {
|
|
868
841
|
await session.send(d.chengyuJielong.apiError);
|
|
869
|
-
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
870
|
-
scheduleAutoPlay(session, key, st);
|
|
871
842
|
}
|
|
843
|
+
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
872
844
|
gameStates.set(key, st);
|
|
873
845
|
return;
|
|
874
846
|
}
|
|
@@ -1083,17 +1055,17 @@ async function apply(ctx, cfg) {
|
|
|
1083
1055
|
return;
|
|
1084
1056
|
}
|
|
1085
1057
|
if (num === st.guessNumber.target) {
|
|
1086
|
-
st.guessNumber.players[playerKey].score += cfg.guessNumber.
|
|
1087
|
-
st.guessNumber.players[playerKey].correctCount += 1;
|
|
1058
|
+
st.guessNumber.players[playerKey].score += cfg.guessNumber.penaltyScore;
|
|
1088
1059
|
await savePlayerData(session, st.guessNumber.players[playerKey]);
|
|
1089
1060
|
let message = d.guessNumber.correct;
|
|
1090
1061
|
if (cfg.guessNumber.enablePenalty) {
|
|
1091
1062
|
Object.keys(st.guessNumber.players).forEach(key => {
|
|
1092
1063
|
if (key !== playerKey) {
|
|
1093
|
-
st.guessNumber.players[key].score += cfg.guessNumber.
|
|
1064
|
+
st.guessNumber.players[key].score += cfg.guessNumber.rewardScore;
|
|
1094
1065
|
savePlayerData(session, st.guessNumber.players[key]);
|
|
1095
1066
|
}
|
|
1096
1067
|
});
|
|
1068
|
+
message += `\n猜中者被扣 ${-cfg.guessNumber.penaltyScore} 分,其他玩家各加 ${cfg.guessNumber.rewardScore} 分`;
|
|
1097
1069
|
}
|
|
1098
1070
|
await session.send(message);
|
|
1099
1071
|
st.guessNumber.currentRound += 1;
|
|
@@ -1273,7 +1245,7 @@ async function apply(ctx, cfg) {
|
|
|
1273
1245
|
gameStates.set(key, st);
|
|
1274
1246
|
}
|
|
1275
1247
|
else {
|
|
1276
|
-
await session.send(d.wzHero.
|
|
1248
|
+
await session.send(d.wzHero.usage);
|
|
1277
1249
|
}
|
|
1278
1250
|
});
|
|
1279
1251
|
ctx.command('看图猜成语 <action>', '看图猜成语')
|
|
@@ -1325,7 +1297,7 @@ async function apply(ctx, cfg) {
|
|
|
1325
1297
|
gameStates.set(key, st);
|
|
1326
1298
|
}
|
|
1327
1299
|
else {
|
|
1328
|
-
await session.send(
|
|
1300
|
+
await session.send(d.chengyuImage.usage);
|
|
1329
1301
|
}
|
|
1330
1302
|
});
|
|
1331
1303
|
ctx.command('成语接龙 <action>', '成语接龙')
|
|
@@ -1346,12 +1318,13 @@ async function apply(ctx, cfg) {
|
|
|
1346
1318
|
if (action === '开始') {
|
|
1347
1319
|
st.chengyuJielong.started = true;
|
|
1348
1320
|
st.chengyuJielong.currentRound = 1;
|
|
1349
|
-
st.chengyuJielong.hasTriggeredAutoPlay = false;
|
|
1350
1321
|
st.chengyuJielong.autoPlayCount = 0;
|
|
1351
1322
|
st.chengyuJielong.jielongCount = 0;
|
|
1323
|
+
st.chengyuJielong.botTurn = true;
|
|
1324
|
+
st.chengyuJielong.hasTriggeredAutoPlay = false;
|
|
1352
1325
|
await session.send(d.chengyuJielong.start.replace('{0}', st.chengyuJielong.totalRounds.toString()));
|
|
1353
|
-
gameStates.set(key, st);
|
|
1354
1326
|
scheduleAutoPlay(session, key, st);
|
|
1327
|
+
gameStates.set(key, st);
|
|
1355
1328
|
setupAutoStop(session, st.chengyuJielong, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
1356
1329
|
}
|
|
1357
1330
|
else if (action === '结束') {
|
|
@@ -1360,7 +1333,7 @@ async function apply(ctx, cfg) {
|
|
|
1360
1333
|
gameStates.set(key, st);
|
|
1361
1334
|
}
|
|
1362
1335
|
else {
|
|
1363
|
-
await session.send(
|
|
1336
|
+
await session.send(d.chengyuJielong.usage);
|
|
1364
1337
|
}
|
|
1365
1338
|
});
|
|
1366
1339
|
ctx.command('算24点 <action>', '算24点游戏')
|
|
@@ -1399,7 +1372,7 @@ async function apply(ctx, cfg) {
|
|
|
1399
1372
|
gameStates.set(key, st);
|
|
1400
1373
|
}
|
|
1401
1374
|
else {
|
|
1402
|
-
await session.send(
|
|
1375
|
+
await session.send(d.calc24.usage);
|
|
1403
1376
|
}
|
|
1404
1377
|
});
|
|
1405
1378
|
if (cfg.rank.enableCommand) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -95,9 +95,9 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
95
95
|
| `guessNumber.autoPlayDelay` | 机器人自动操作延迟(秒) | 10 |
|
|
96
96
|
| `guessNumber.autoPlayMaxCount` | 机器人最大自动操作次数 | 5 |
|
|
97
97
|
| `guessNumber.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
98
|
-
| `guessNumber.enablePenalty` |
|
|
99
|
-
| `guessNumber.
|
|
100
|
-
| `guessNumber.
|
|
98
|
+
| `guessNumber.enablePenalty` | 启用惩罚机制(猜中者扣分,其他人加分) | true |
|
|
99
|
+
| `guessNumber.penaltyScore` | 猜中者扣除分数(负数) | -1 |
|
|
100
|
+
| `guessNumber.rewardScore` | 其他人奖励分数 | 1 |
|
|
101
101
|
| **⚔️ 王者英雄猜谜配置** | | |
|
|
102
102
|
| `wzHero.totalRounds` | 总回合数 | 10 |
|
|
103
103
|
| `wzHero.showRank` | 游戏结束后显示本局排行榜 | true |
|
|
@@ -118,7 +118,6 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
118
118
|
| `chengyuJielong.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
119
119
|
| `chengyuJielong.maxRounds` | 最大接龙回合数(0为无限) | 10 |
|
|
120
120
|
| `chengyuJielong.botParticipate` | 机器人是否参与接龙 | false |
|
|
121
|
-
| `chengyuJielong.rewardScore` | 接龙成功奖励分数 | 1 |
|
|
122
121
|
| **🧮 算24点配置** | | |
|
|
123
122
|
| `calc24.totalRounds` | 总回合数 | 5 |
|
|
124
123
|
| `calc24.showRank` | 游戏结束后显示本局排行榜 | true |
|
|
@@ -131,7 +130,7 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
131
130
|
| **🌐 API接口配置** | | |
|
|
132
131
|
| `apiConfig.timeout` | API请求超时时间(毫秒) | 5000 |
|
|
133
132
|
| **💬 通用消息配置** | | |
|
|
134
|
-
| `commonMessages.gameRunning` | 游戏运行中提示 |
|
|
133
|
+
| `commonMessages.gameRunning` | 游戏运行中提示 | 当前已有游戏在运行中,请先结束当前游戏后再开始新游戏! |
|
|
135
134
|
| `commonMessages.gameStoppedByInactive` | 无操作停止提示 | 太久没人玩啦,比赛自动结束~ |
|
|
136
135
|
| `commonMessages.paramError` | 参数错误提示 | ❌ 参数错误!请检查输入格式 |
|
|
137
136
|
|
|
@@ -164,9 +163,9 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
164
163
|
| `guessNumber.autoPlayDelay` | Bot auto operation delay (seconds) | 10 |
|
|
165
164
|
| `guessNumber.autoPlayMaxCount` | Bot maximum auto operation count | 5 |
|
|
166
165
|
| `guessNumber.autoStopInactiveTime` | Auto stop time due to inactivity (seconds) | 60 |
|
|
167
|
-
| `guessNumber.enablePenalty` | Enable penalty mechanism | true |
|
|
168
|
-
| `guessNumber.
|
|
169
|
-
| `guessNumber.
|
|
166
|
+
| `guessNumber.enablePenalty` | Enable penalty mechanism (guesser loses points, others gain) | true |
|
|
167
|
+
| `guessNumber.penaltyScore` | Points deducted from guesser (negative number) | -1 |
|
|
168
|
+
| `guessNumber.rewardScore` | Points rewarded to others | 1 |
|
|
170
169
|
| **⚔️ King of Glory Hero Configuration** | | |
|
|
171
170
|
| `wzHero.totalRounds` | Total rounds | 10 |
|
|
172
171
|
| `wzHero.showRank` | Show rank after game ends | true |
|
|
@@ -187,7 +186,6 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
187
186
|
| `chengyuJielong.autoStopInactiveTime` | Auto stop time due to inactivity (seconds) | 60 |
|
|
188
187
|
| `chengyuJielong.maxRounds` | Maximum solitaire rounds (0 for unlimited) | 10 |
|
|
189
188
|
| `chengyuJielong.botParticipate` | Whether bot participates in solitaire | false |
|
|
190
|
-
| `chengyuJielong.rewardScore` | Reward score for successful solitaire | 1 |
|
|
191
189
|
| **🧮 24-Point Calculation Configuration** | | |
|
|
192
190
|
| `calc24.totalRounds` | Total rounds | 5 |
|
|
193
191
|
| `calc24.showRank` | Show rank after game ends | true |
|
|
@@ -200,8 +198,8 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
200
198
|
| **🌐 API Configuration** | | |
|
|
201
199
|
| `apiConfig.timeout` | API request timeout (milliseconds) | 5000 |
|
|
202
200
|
| **💬 Common Messages Configuration** | | |
|
|
203
|
-
| `commonMessages.gameRunning` | Game running prompt |
|
|
204
|
-
| `commonMessages.gameStoppedByInactive` | Inactivity stop prompt |
|
|
201
|
+
| `commonMessages.gameRunning` | Game running prompt | A game is already running, please end it first before starting a new one! |
|
|
202
|
+
| `commonMessages.gameStoppedByInactive` | Inactivity stop prompt | Too long no activity, game auto ended~ |
|
|
205
203
|
| `commonMessages.paramError` | Parameter error prompt | ❌ Parameter error! Please check input format |
|
|
206
204
|
|
|
207
205
|
## 项目贡献者 (Contributors)
|