koishi-plugin-game-mini 0.2.5 → 0.2.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.d.ts +90 -7
- package/lib/index.js +314 -362
- package/package.json +2 -4
- package/readme.md +17 -35
package/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export interface Config {
|
|
|
8
8
|
enableChengyuImage: boolean;
|
|
9
9
|
enableChengyuJielong: boolean;
|
|
10
10
|
enableCalc24: boolean;
|
|
11
|
-
enablePasswordLock: boolean;
|
|
12
11
|
enablePrivateGame: boolean;
|
|
13
12
|
guessNumber: {
|
|
14
13
|
min: number;
|
|
@@ -19,18 +18,67 @@ export interface Config {
|
|
|
19
18
|
autoPlayDelay: number;
|
|
20
19
|
autoPlayMaxCount: number;
|
|
21
20
|
autoStopInactiveTime: number;
|
|
21
|
+
messages: {
|
|
22
|
+
usage: string;
|
|
23
|
+
start: string;
|
|
24
|
+
stop: string;
|
|
25
|
+
outOfRange: string;
|
|
26
|
+
tooSmall: string;
|
|
27
|
+
tooBig: string;
|
|
28
|
+
correct: string;
|
|
29
|
+
roundEnd: string;
|
|
30
|
+
gameEnd: string;
|
|
31
|
+
rankTitle: string;
|
|
32
|
+
rankEmpty: string;
|
|
33
|
+
disabled: string;
|
|
34
|
+
autoStop: string;
|
|
35
|
+
};
|
|
22
36
|
};
|
|
23
37
|
wzHero: {
|
|
24
38
|
totalRounds: number;
|
|
25
39
|
showRank: boolean;
|
|
26
40
|
defaultDifficulty: '简单' | '中等' | '困难';
|
|
27
41
|
autoStopInactiveTime: number;
|
|
42
|
+
messages: {
|
|
43
|
+
start: string;
|
|
44
|
+
startUsage: string;
|
|
45
|
+
stop: string;
|
|
46
|
+
notStarted: string;
|
|
47
|
+
hint: string;
|
|
48
|
+
apiError: string;
|
|
49
|
+
correct: string;
|
|
50
|
+
wrong: string;
|
|
51
|
+
roundEnd: string;
|
|
52
|
+
gameEnd: string;
|
|
53
|
+
rankTitle: string;
|
|
54
|
+
rankEmpty: string;
|
|
55
|
+
disabled: string;
|
|
56
|
+
autoStop: string;
|
|
57
|
+
};
|
|
28
58
|
};
|
|
29
59
|
chengyuImage: {
|
|
30
60
|
totalRounds: number;
|
|
31
61
|
showRank: boolean;
|
|
32
62
|
defaultHintLevel: 1 | 2 | 3 | 4 | 5;
|
|
33
63
|
autoStopInactiveTime: number;
|
|
64
|
+
messages: {
|
|
65
|
+
start: string;
|
|
66
|
+
stop: string;
|
|
67
|
+
submitUsage: string;
|
|
68
|
+
notStarted: string;
|
|
69
|
+
next: string;
|
|
70
|
+
hintGet: string;
|
|
71
|
+
hintError: string;
|
|
72
|
+
apiError: string;
|
|
73
|
+
correct: string;
|
|
74
|
+
wrong: string;
|
|
75
|
+
roundEnd: string;
|
|
76
|
+
gameEnd: string;
|
|
77
|
+
rankTitle: string;
|
|
78
|
+
rankEmpty: string;
|
|
79
|
+
disabled: string;
|
|
80
|
+
autoStop: string;
|
|
81
|
+
};
|
|
34
82
|
};
|
|
35
83
|
chengyuJielong: {
|
|
36
84
|
botParticipateInGroup: boolean;
|
|
@@ -39,6 +87,26 @@ export interface Config {
|
|
|
39
87
|
autoPlayDelay: number;
|
|
40
88
|
autoPlayMaxCount: number;
|
|
41
89
|
autoStopInactiveTime: number;
|
|
90
|
+
messages: {
|
|
91
|
+
start: string;
|
|
92
|
+
stop: string;
|
|
93
|
+
notStarted: string;
|
|
94
|
+
joinUsage: string;
|
|
95
|
+
apiError: string;
|
|
96
|
+
botTurn: string;
|
|
97
|
+
botWin: string;
|
|
98
|
+
autoPlayTooMany: string;
|
|
99
|
+
gameInactiveStop: string;
|
|
100
|
+
notIdiom: string;
|
|
101
|
+
correct: string;
|
|
102
|
+
wrong: string;
|
|
103
|
+
roundEnd: string;
|
|
104
|
+
gameEnd: string;
|
|
105
|
+
rankTitle: string;
|
|
106
|
+
rankEmpty: string;
|
|
107
|
+
disabled: string;
|
|
108
|
+
autoStop: string;
|
|
109
|
+
};
|
|
42
110
|
};
|
|
43
111
|
calc24: {
|
|
44
112
|
totalRounds: number;
|
|
@@ -59,16 +127,31 @@ export interface Config {
|
|
|
59
127
|
};
|
|
60
128
|
};
|
|
61
129
|
autoStopInactiveTime: number;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
130
|
+
messages: {
|
|
131
|
+
start: string;
|
|
132
|
+
stop: string;
|
|
133
|
+
notStarted: string;
|
|
134
|
+
generate: string;
|
|
135
|
+
correct: string;
|
|
136
|
+
wrong: string;
|
|
137
|
+
impossible: string;
|
|
138
|
+
solved: string;
|
|
139
|
+
roundEnd: string;
|
|
140
|
+
gameEnd: string;
|
|
141
|
+
rankTitle: string;
|
|
142
|
+
rankEmpty: string;
|
|
143
|
+
disabled: string;
|
|
144
|
+
autoStop: string;
|
|
145
|
+
};
|
|
68
146
|
};
|
|
69
147
|
apiConfig: {
|
|
70
148
|
timeout: number;
|
|
71
149
|
};
|
|
150
|
+
commonMessages: {
|
|
151
|
+
gameRunning: string;
|
|
152
|
+
gameStoppedByInactive: string;
|
|
153
|
+
paramError: string;
|
|
154
|
+
};
|
|
72
155
|
}
|
|
73
156
|
export declare const Config: Schema<Config>;
|
|
74
157
|
export declare function apply(ctx: Context, cfg: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -13,74 +13,263 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
13
13
|
exports.name = 'game-mini';
|
|
14
14
|
exports.using = ['i18n'];
|
|
15
15
|
exports.inject = ['console'];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
16
|
+
const defaultMessages = {
|
|
17
|
+
guessNumber: {
|
|
18
|
+
usage: "用法错误!正确用法:猜数字 开始 | 猜数字 [数字] | 猜数字 结束",
|
|
19
|
+
start: "猜数字比赛开始!本次共 {0} 回合~",
|
|
20
|
+
stop: "猜数字比赛已停止",
|
|
21
|
+
outOfRange: "数字超出当前范围 [{0}-{1}],请重新输入!",
|
|
22
|
+
tooSmall: "猜小啦!当前范围更新为 [{0}-{1}]",
|
|
23
|
+
tooBig: "猜大啦!当前范围更新为 [{0}-{1}]",
|
|
24
|
+
correct: "恭喜你猜中数字!本轮你不得分,其他参与者各得1分~",
|
|
25
|
+
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
26
|
+
gameEnd: "🎉 猜数字比赛结束!🎉",
|
|
27
|
+
rankTitle: "🏆 排行榜 🏆",
|
|
28
|
+
rankEmpty: "暂无参与记录~",
|
|
29
|
+
disabled: "猜数字功能已关闭,请联系管理员开启",
|
|
30
|
+
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
31
|
+
},
|
|
32
|
+
wzHero: {
|
|
33
|
+
start: "猜王者英雄开始!本次共 {0} 回合~当前难度:{1}",
|
|
34
|
+
startUsage: "用法错误!正确用法:猜王者英雄 开始 | 猜王者英雄 [答案] | 猜王者英雄 提示 | 猜王者英雄 结束",
|
|
35
|
+
stop: "猜王者英雄比赛已停止",
|
|
36
|
+
notStarted: "猜王者英雄比赛尚未开始,请输入 猜王者英雄 开始 开始游戏",
|
|
37
|
+
hint: "提示",
|
|
38
|
+
apiError: "API请求失败,请稍后再试",
|
|
39
|
+
correct: "答对啦!你获得1分~",
|
|
40
|
+
wrong: "答错啦~正确答案是:{0},你不得分",
|
|
41
|
+
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
42
|
+
gameEnd: "🎉 猜王者英雄比赛结束!🎉",
|
|
43
|
+
rankTitle: "🏆 排行榜 🏆",
|
|
44
|
+
rankEmpty: "暂无参与记录~",
|
|
45
|
+
disabled: "猜王者英雄功能已关闭,请联系管理员开启",
|
|
46
|
+
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
47
|
+
},
|
|
48
|
+
chengyuImage: {
|
|
49
|
+
start: "看图猜成语比赛开始!本次共 {0} 回合~当前提示级别:{1}",
|
|
50
|
+
stop: "看图猜成语比赛已停止",
|
|
51
|
+
submitUsage: "请直接输入 看图猜成语 [答案],或输入 看图猜成语 提示 获取线索",
|
|
52
|
+
notStarted: "看图猜成语比赛尚未开始,请输入 看图猜成语 开始 开始游戏",
|
|
53
|
+
next: "第 {0} 题来啦!",
|
|
54
|
+
hintGet: "【提示】{0}",
|
|
55
|
+
hintError: "获取提示失败,请稍后再试",
|
|
56
|
+
apiError: "API请求失败,请稍后再试",
|
|
57
|
+
correct: "答对啦!你获得1分~",
|
|
58
|
+
wrong: "答错啦~正确答案是:{0},你不得分",
|
|
59
|
+
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
60
|
+
gameEnd: "🎉 看图猜成语比赛结束!🎉",
|
|
61
|
+
rankTitle: "🏆 排行榜 🏆",
|
|
62
|
+
rankEmpty: "暂无参与记录~",
|
|
63
|
+
disabled: "看图猜成语功能已关闭,请联系管理员开启",
|
|
64
|
+
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
65
|
+
},
|
|
66
|
+
chengyuJielong: {
|
|
67
|
+
start: "成语接龙比赛开始!本次共 {0} 回合~我先来~",
|
|
68
|
+
stop: "成语接龙比赛已停止",
|
|
69
|
+
notStarted: "成语接龙比赛尚未开始,请输入 成语接龙 开始 开始游戏",
|
|
70
|
+
joinUsage: "请直接发送 成语接龙 [成语] 参与接龙",
|
|
71
|
+
apiError: "API请求失败,请稍后再试",
|
|
72
|
+
botTurn: "该我了!我接:{0}({1})\n释义:{2}",
|
|
73
|
+
botWin: "哈哈我接不上了!本轮结束~",
|
|
74
|
+
autoPlayTooMany: "我已经主动参与 {0} 次啦,不再主动接啦~",
|
|
75
|
+
gameInactiveStop: "太久没人玩啦,比赛自动结束~",
|
|
76
|
+
notIdiom: "请发送四字成语参与游戏~",
|
|
77
|
+
correct: "接龙成功!你获得1分~",
|
|
78
|
+
wrong: "接龙失败!你不得分,其他参与者各得1分~",
|
|
79
|
+
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
80
|
+
gameEnd: "🎉 成语接龙比赛结束!🎉",
|
|
81
|
+
rankTitle: "🏆 排行榜 🏆",
|
|
82
|
+
rankEmpty: "暂无参与记录~",
|
|
83
|
+
disabled: "成语接龙功能已关闭,请联系管理员开启",
|
|
84
|
+
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
85
|
+
},
|
|
86
|
+
calc24: {
|
|
87
|
+
start: "算24点游戏开始!本次共 {0} 回合~当前难度:{1}",
|
|
88
|
+
stop: "算24点游戏已停止",
|
|
89
|
+
notStarted: "算24点游戏尚未开始,请输入 算24点 开始 开始游戏",
|
|
90
|
+
generate: "📝 第 {0} 题({1}):用 {2} 通过加减乘除和括号算出24!",
|
|
91
|
+
correct: "答对啦!你获得1分~",
|
|
92
|
+
wrong: "答错啦~",
|
|
93
|
+
impossible: "这组数无法算出24!本题作废,换一组数字~",
|
|
94
|
+
solved: "这组数已经被答对啦,换一组数字~",
|
|
95
|
+
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
96
|
+
gameEnd: "🎉 算24点游戏结束!🎉",
|
|
97
|
+
rankTitle: "🏆 排行榜 🏆",
|
|
98
|
+
rankEmpty: "暂无参与记录~",
|
|
99
|
+
disabled: "算24点功能已关闭,请联系管理员开启",
|
|
100
|
+
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
101
|
+
},
|
|
102
|
+
common: {
|
|
103
|
+
gameRunning: "当前已有游戏在运行中,请先结束当前游戏后再开始新游戏!",
|
|
104
|
+
gameStoppedByInactive: "游戏因长时间无人操作,已自动结束",
|
|
105
|
+
paramError: "参数错误!请检查输入格式"
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.Config = koishi_1.Schema.intersect([
|
|
109
|
+
koishi_1.Schema.object({
|
|
110
|
+
enableNumberGuess: koishi_1.Schema.boolean().default(true).description('启用猜数字游戏'),
|
|
111
|
+
enableWzHero: koishi_1.Schema.boolean().default(true).description('启用王者英雄猜谜游戏'),
|
|
112
|
+
enableChengyuImage: koishi_1.Schema.boolean().default(true).description('启用看图猜成语游戏'),
|
|
113
|
+
enableChengyuJielong: koishi_1.Schema.boolean().default(true).description('启用成语接龙游戏'),
|
|
114
|
+
enableCalc24: koishi_1.Schema.boolean().default(true).description('启用算24点游戏'),
|
|
115
|
+
enablePrivateGame: koishi_1.Schema.boolean().default(true).description('允许私聊玩游戏'),
|
|
116
|
+
}).description('基础功能开关'),
|
|
117
|
+
koishi_1.Schema.object({
|
|
118
|
+
guessNumber: koishi_1.Schema.object({
|
|
119
|
+
min: koishi_1.Schema.number().min(0).default(0).description('猜数字最小值'),
|
|
120
|
+
max: koishi_1.Schema.number().min(1).default(100).description('猜数字最大值'),
|
|
121
|
+
botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中机器人参与猜数字'),
|
|
122
|
+
totalRounds: koishi_1.Schema.number().min(1).default(10).description('猜数字总回合数'),
|
|
123
|
+
showRank: koishi_1.Schema.boolean().default(true).description('显示排行榜'),
|
|
124
|
+
autoPlayDelay: koishi_1.Schema.number().min(0).default(10).description('机器人自动操作延迟(秒)'),
|
|
125
|
+
autoPlayMaxCount: koishi_1.Schema.number().min(1).default(5).description('机器人最大自动操作次数'),
|
|
126
|
+
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
127
|
+
messages: koishi_1.Schema.object({
|
|
128
|
+
usage: koishi_1.Schema.string().default(defaultMessages.guessNumber.usage).description('用法错误提示'),
|
|
129
|
+
start: koishi_1.Schema.string().default(defaultMessages.guessNumber.start).description('游戏开始提示'),
|
|
130
|
+
stop: koishi_1.Schema.string().default(defaultMessages.guessNumber.stop).description('游戏停止提示'),
|
|
131
|
+
outOfRange: koishi_1.Schema.string().default(defaultMessages.guessNumber.outOfRange).description('数字超出范围提示'),
|
|
132
|
+
tooSmall: koishi_1.Schema.string().default(defaultMessages.guessNumber.tooSmall).description('猜小了提示'),
|
|
133
|
+
tooBig: koishi_1.Schema.string().default(defaultMessages.guessNumber.tooBig).description('猜大了提示'),
|
|
134
|
+
correct: koishi_1.Schema.string().default(defaultMessages.guessNumber.correct).description('猜中提示'),
|
|
135
|
+
roundEnd: koishi_1.Schema.string().default(defaultMessages.guessNumber.roundEnd).description('回合结束提示'),
|
|
136
|
+
gameEnd: koishi_1.Schema.string().default(defaultMessages.guessNumber.gameEnd).description('游戏结束提示'),
|
|
137
|
+
rankTitle: koishi_1.Schema.string().default(defaultMessages.guessNumber.rankTitle).description('排行榜标题'),
|
|
138
|
+
rankEmpty: koishi_1.Schema.string().default(defaultMessages.guessNumber.rankEmpty).description('排行榜为空提示'),
|
|
139
|
+
disabled: koishi_1.Schema.string().default(defaultMessages.guessNumber.disabled).description('功能禁用提示'),
|
|
140
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.guessNumber.autoStop).description('自动停止提示'),
|
|
141
|
+
}).description('猜数字消息配置'),
|
|
142
|
+
}).description('猜数字游戏配置'),
|
|
143
|
+
}),
|
|
144
|
+
koishi_1.Schema.object({
|
|
145
|
+
wzHero: koishi_1.Schema.object({
|
|
146
|
+
totalRounds: koishi_1.Schema.number().min(1).default(10).description('王者英雄猜谜总回合数'),
|
|
147
|
+
showRank: koishi_1.Schema.boolean().default(true).description('显示排行榜'),
|
|
148
|
+
defaultDifficulty: koishi_1.Schema.union(['简单', '中等', '困难']).default('简单').description('默认难度'),
|
|
149
|
+
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
150
|
+
messages: koishi_1.Schema.object({
|
|
151
|
+
start: koishi_1.Schema.string().default(defaultMessages.wzHero.start).description('游戏开始提示'),
|
|
152
|
+
startUsage: koishi_1.Schema.string().default(defaultMessages.wzHero.startUsage).description('开始用法提示'),
|
|
153
|
+
stop: koishi_1.Schema.string().default(defaultMessages.wzHero.stop).description('游戏停止提示'),
|
|
154
|
+
notStarted: koishi_1.Schema.string().default(defaultMessages.wzHero.notStarted).description('游戏未开始提示'),
|
|
155
|
+
hint: koishi_1.Schema.string().default(defaultMessages.wzHero.hint).description('提示命令'),
|
|
156
|
+
apiError: koishi_1.Schema.string().default(defaultMessages.wzHero.apiError).description('API错误提示'),
|
|
157
|
+
correct: koishi_1.Schema.string().default(defaultMessages.wzHero.correct).description('答对提示'),
|
|
158
|
+
wrong: koishi_1.Schema.string().default(defaultMessages.wzHero.wrong).description('答错提示'),
|
|
159
|
+
roundEnd: koishi_1.Schema.string().default(defaultMessages.wzHero.roundEnd).description('回合结束提示'),
|
|
160
|
+
gameEnd: koishi_1.Schema.string().default(defaultMessages.wzHero.gameEnd).description('游戏结束提示'),
|
|
161
|
+
rankTitle: koishi_1.Schema.string().default(defaultMessages.wzHero.rankTitle).description('排行榜标题'),
|
|
162
|
+
rankEmpty: koishi_1.Schema.string().default(defaultMessages.wzHero.rankEmpty).description('排行榜为空提示'),
|
|
163
|
+
disabled: koishi_1.Schema.string().default(defaultMessages.wzHero.disabled).description('功能禁用提示'),
|
|
164
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.wzHero.autoStop).description('自动停止提示'),
|
|
165
|
+
}).description('王者英雄猜谜消息配置'),
|
|
166
|
+
}).description('王者英雄猜谜游戏配置'),
|
|
167
|
+
}),
|
|
168
|
+
koishi_1.Schema.object({
|
|
169
|
+
chengyuImage: koishi_1.Schema.object({
|
|
170
|
+
totalRounds: koishi_1.Schema.number().min(1).default(10).description('看图猜成语总回合数'),
|
|
171
|
+
showRank: koishi_1.Schema.boolean().default(true).description('显示排行榜'),
|
|
172
|
+
defaultHintLevel: koishi_1.Schema.union([1, 2, 3, 4, 5]).default(1).description('默认提示级别(1-5)'),
|
|
173
|
+
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
174
|
+
messages: koishi_1.Schema.object({
|
|
175
|
+
start: koishi_1.Schema.string().default(defaultMessages.chengyuImage.start).description('游戏开始提示'),
|
|
176
|
+
stop: koishi_1.Schema.string().default(defaultMessages.chengyuImage.stop).description('游戏停止提示'),
|
|
177
|
+
submitUsage: koishi_1.Schema.string().default(defaultMessages.chengyuImage.submitUsage).description('提交答案用法提示'),
|
|
178
|
+
notStarted: koishi_1.Schema.string().default(defaultMessages.chengyuImage.notStarted).description('游戏未开始提示'),
|
|
179
|
+
next: koishi_1.Schema.string().default(defaultMessages.chengyuImage.next).description('下一题提示'),
|
|
180
|
+
hintGet: koishi_1.Schema.string().default(defaultMessages.chengyuImage.hintGet).description('获取提示成功'),
|
|
181
|
+
hintError: koishi_1.Schema.string().default(defaultMessages.chengyuImage.hintError).description('获取提示失败'),
|
|
182
|
+
apiError: koishi_1.Schema.string().default(defaultMessages.chengyuImage.apiError).description('API错误提示'),
|
|
183
|
+
correct: koishi_1.Schema.string().default(defaultMessages.chengyuImage.correct).description('答对提示'),
|
|
184
|
+
wrong: koishi_1.Schema.string().default(defaultMessages.chengyuImage.wrong).description('答错提示'),
|
|
185
|
+
roundEnd: koishi_1.Schema.string().default(defaultMessages.chengyuImage.roundEnd).description('回合结束提示'),
|
|
186
|
+
gameEnd: koishi_1.Schema.string().default(defaultMessages.chengyuImage.gameEnd).description('游戏结束提示'),
|
|
187
|
+
rankTitle: koishi_1.Schema.string().default(defaultMessages.chengyuImage.rankTitle).description('排行榜标题'),
|
|
188
|
+
rankEmpty: koishi_1.Schema.string().default(defaultMessages.chengyuImage.rankEmpty).description('排行榜为空提示'),
|
|
189
|
+
disabled: koishi_1.Schema.string().default(defaultMessages.chengyuImage.disabled).description('功能禁用提示'),
|
|
190
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.chengyuImage.autoStop).description('自动停止提示'),
|
|
191
|
+
}).description('看图猜成语消息配置'),
|
|
192
|
+
}).description('看图猜成语游戏配置'),
|
|
193
|
+
}),
|
|
194
|
+
koishi_1.Schema.object({
|
|
195
|
+
chengyuJielong: koishi_1.Schema.object({
|
|
196
|
+
botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中机器人参与成语接龙'),
|
|
197
|
+
totalRounds: koishi_1.Schema.number().min(1).default(10).description('成语接龙总回合数'),
|
|
198
|
+
showRank: koishi_1.Schema.boolean().default(true).description('显示排行榜'),
|
|
199
|
+
autoPlayDelay: koishi_1.Schema.number().min(0).default(10).description('机器人自动操作延迟(秒)'),
|
|
200
|
+
autoPlayMaxCount: koishi_1.Schema.number().min(1).default(5).description('机器人最大自动操作次数'),
|
|
201
|
+
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
202
|
+
messages: koishi_1.Schema.object({
|
|
203
|
+
start: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.start).description('游戏开始提示'),
|
|
204
|
+
stop: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.stop).description('游戏停止提示'),
|
|
205
|
+
notStarted: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.notStarted).description('游戏未开始提示'),
|
|
206
|
+
joinUsage: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.joinUsage).description('参与用法提示'),
|
|
207
|
+
apiError: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.apiError).description('API错误提示'),
|
|
208
|
+
botTurn: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.botTurn).description('机器人回合提示'),
|
|
209
|
+
botWin: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.botWin).description('机器人赢提示'),
|
|
210
|
+
autoPlayTooMany: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.autoPlayTooMany).description('自动参与次数过多提示'),
|
|
211
|
+
gameInactiveStop: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.gameInactiveStop).description('游戏无操作停止提示'),
|
|
212
|
+
notIdiom: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.notIdiom).description('非成语提示'),
|
|
213
|
+
correct: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.correct).description('接龙成功提示'),
|
|
214
|
+
wrong: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.wrong).description('接龙失败提示'),
|
|
215
|
+
roundEnd: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.roundEnd).description('回合结束提示'),
|
|
216
|
+
gameEnd: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.gameEnd).description('游戏结束提示'),
|
|
217
|
+
rankTitle: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.rankTitle).description('排行榜标题'),
|
|
218
|
+
rankEmpty: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.rankEmpty).description('排行榜为空提示'),
|
|
219
|
+
disabled: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.disabled).description('功能禁用提示'),
|
|
220
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.chengyuJielong.autoStop).description('自动停止提示'),
|
|
221
|
+
}).description('成语接龙消息配置'),
|
|
222
|
+
}).description('成语接龙游戏配置'),
|
|
223
|
+
}),
|
|
224
|
+
koishi_1.Schema.object({
|
|
225
|
+
calc24: koishi_1.Schema.object({
|
|
226
|
+
totalRounds: koishi_1.Schema.number().min(1).default(5).description('算24点总回合数'),
|
|
227
|
+
showRank: koishi_1.Schema.boolean().default(true).description('显示排行榜'),
|
|
228
|
+
defaultDifficulty: koishi_1.Schema.union(['简单', '中等', '困难']).default('中等').description('默认难度'),
|
|
229
|
+
difficultyLevels: koishi_1.Schema.object({
|
|
230
|
+
easy: koishi_1.Schema.object({
|
|
231
|
+
min: koishi_1.Schema.number().default(1).description('最小值'),
|
|
232
|
+
max: koishi_1.Schema.number().default(8).description('最大值'),
|
|
233
|
+
}).description('简单难度'),
|
|
234
|
+
medium: koishi_1.Schema.object({
|
|
235
|
+
min: koishi_1.Schema.number().default(1).description('最小值'),
|
|
236
|
+
max: koishi_1.Schema.number().default(10).description('最大值'),
|
|
237
|
+
}).description('中等难度'),
|
|
238
|
+
hard: koishi_1.Schema.object({
|
|
239
|
+
min: koishi_1.Schema.number().default(1).description('最小值'),
|
|
240
|
+
max: koishi_1.Schema.number().default(13).description('最大值'),
|
|
241
|
+
}).description('困难难度'),
|
|
242
|
+
}).description('难度等级配置'),
|
|
243
|
+
autoStopInactiveTime: koishi_1.Schema.number().min(0).default(60).description('游戏无操作自动停止时间(秒)'),
|
|
244
|
+
messages: koishi_1.Schema.object({
|
|
245
|
+
start: koishi_1.Schema.string().default(defaultMessages.calc24.start).description('游戏开始提示'),
|
|
246
|
+
stop: koishi_1.Schema.string().default(defaultMessages.calc24.stop).description('游戏停止提示'),
|
|
247
|
+
notStarted: koishi_1.Schema.string().default(defaultMessages.calc24.notStarted).description('游戏未开始提示'),
|
|
248
|
+
generate: koishi_1.Schema.string().default(defaultMessages.calc24.generate).description('生成题目提示'),
|
|
249
|
+
correct: koishi_1.Schema.string().default(defaultMessages.calc24.correct).description('答对提示'),
|
|
250
|
+
wrong: koishi_1.Schema.string().default(defaultMessages.calc24.wrong).description('答错提示'),
|
|
251
|
+
impossible: koishi_1.Schema.string().default(defaultMessages.calc24.impossible).description('无解提示'),
|
|
252
|
+
solved: koishi_1.Schema.string().default(defaultMessages.calc24.solved).description('已解决提示'),
|
|
253
|
+
roundEnd: koishi_1.Schema.string().default(defaultMessages.calc24.roundEnd).description('回合结束提示'),
|
|
254
|
+
gameEnd: koishi_1.Schema.string().default(defaultMessages.calc24.gameEnd).description('游戏结束提示'),
|
|
255
|
+
rankTitle: koishi_1.Schema.string().default(defaultMessages.calc24.rankTitle).description('排行榜标题'),
|
|
256
|
+
rankEmpty: koishi_1.Schema.string().default(defaultMessages.calc24.rankEmpty).description('排行榜为空提示'),
|
|
257
|
+
disabled: koishi_1.Schema.string().default(defaultMessages.calc24.disabled).description('功能禁用提示'),
|
|
258
|
+
autoStop: koishi_1.Schema.string().default(defaultMessages.calc24.autoStop).description('自动停止提示'),
|
|
259
|
+
}).description('算24点消息配置'),
|
|
260
|
+
}).description('算24点游戏配置'),
|
|
261
|
+
}),
|
|
262
|
+
koishi_1.Schema.object({
|
|
263
|
+
apiConfig: koishi_1.Schema.object({
|
|
264
|
+
timeout: koishi_1.Schema.number().default(5000).description('API请求超时时间(毫秒)'),
|
|
265
|
+
}).description('API接口配置'),
|
|
266
|
+
commonMessages: koishi_1.Schema.object({
|
|
267
|
+
gameRunning: koishi_1.Schema.string().default(defaultMessages.common.gameRunning).description('游戏运行中提示'),
|
|
268
|
+
gameStoppedByInactive: koishi_1.Schema.string().default(defaultMessages.common.gameStoppedByInactive).description('无操作停止提示'),
|
|
269
|
+
paramError: koishi_1.Schema.string().default(defaultMessages.common.paramError).description('参数错误提示'),
|
|
270
|
+
}).description('通用消息配置'),
|
|
271
|
+
}),
|
|
272
|
+
]);
|
|
84
273
|
const logger = new koishi_1.Logger('game-mini');
|
|
85
274
|
const gameStates = new Map();
|
|
86
275
|
const getSessionKey = (s) => s.channelId ? `g:${s.channelId}` : `p:${s.userId}`;
|
|
@@ -110,8 +299,6 @@ const checkGameRunning = (s, t) => {
|
|
|
110
299
|
return true;
|
|
111
300
|
if (t !== 'calc24' && s.calc24.started)
|
|
112
301
|
return true;
|
|
113
|
-
if (t !== 'passwordLock' && s.passwordLock.started)
|
|
114
|
-
return true;
|
|
115
302
|
return false;
|
|
116
303
|
};
|
|
117
304
|
const clearGameTimer = (state) => {
|
|
@@ -126,7 +313,6 @@ const clearAllTimers = (st) => {
|
|
|
126
313
|
clearGameTimer(st.chengyuImage);
|
|
127
314
|
clearGameTimer(st.chengyuJielong);
|
|
128
315
|
clearGameTimer(st.calc24);
|
|
129
|
-
clearGameTimer(st.passwordLock);
|
|
130
316
|
};
|
|
131
317
|
const initState = (key, c) => {
|
|
132
318
|
const s = {
|
|
@@ -187,19 +373,6 @@ const initState = (key, c) => {
|
|
|
187
373
|
playerAnswer: '',
|
|
188
374
|
solved: false,
|
|
189
375
|
availableNumbers: []
|
|
190
|
-
},
|
|
191
|
-
passwordLock: {
|
|
192
|
-
started: false,
|
|
193
|
-
totalRounds: 1,
|
|
194
|
-
currentRound: 0,
|
|
195
|
-
players: {},
|
|
196
|
-
participants: [],
|
|
197
|
-
password: '',
|
|
198
|
-
playerGuess: '',
|
|
199
|
-
guessTimes: 0,
|
|
200
|
-
maxGuessTimes: c.passwordLock.maxGuessTimes,
|
|
201
|
-
hints: [],
|
|
202
|
-
solved: false
|
|
203
376
|
}
|
|
204
377
|
};
|
|
205
378
|
gameStates.set(key, s);
|
|
@@ -209,19 +382,22 @@ const isFourCharIdiom = (text) => {
|
|
|
209
382
|
const t = text.trim();
|
|
210
383
|
return /^[\u4e00-\u9fa5]{4}$/.test(t);
|
|
211
384
|
};
|
|
212
|
-
const generateRankText = (players) => {
|
|
385
|
+
const generateRankText = (players, rankTitle, rankEmpty) => {
|
|
213
386
|
const playerList = Object.values(players);
|
|
214
387
|
if (playerList.length === 0) {
|
|
215
|
-
return
|
|
388
|
+
return `${rankTitle}\n${rankEmpty}`;
|
|
216
389
|
}
|
|
217
390
|
const sortedPlayers = playerList.sort((a, b) => b.score - a.score);
|
|
218
|
-
let rankText =
|
|
391
|
+
let rankText = `${rankTitle}\n`;
|
|
219
392
|
sortedPlayers.forEach((player, index) => {
|
|
220
393
|
rankText += `${index + 1}. ${player.name} - 得分:${player.score}分(答对${player.correctCount}题)\n`;
|
|
221
394
|
});
|
|
222
395
|
return rankText.trim();
|
|
223
396
|
};
|
|
224
|
-
const clearGameData = (gameState) => {
|
|
397
|
+
const clearGameData = (gameState, showRank = false, session, rankTitle, rankEmpty) => {
|
|
398
|
+
if (showRank && session && session.channelId && rankTitle && rankEmpty) {
|
|
399
|
+
session.send(generateRankText(gameState.players, rankTitle, rankEmpty));
|
|
400
|
+
}
|
|
225
401
|
gameState.players = {};
|
|
226
402
|
gameState.participants = [];
|
|
227
403
|
gameState.currentRound = 0;
|
|
@@ -235,9 +411,9 @@ const addScoreToOthers = (players, excludePlayerKey) => {
|
|
|
235
411
|
}
|
|
236
412
|
});
|
|
237
413
|
};
|
|
238
|
-
const setupAutoStop = (session, state, cfg, gameType, endMsg, showRank) => {
|
|
414
|
+
const setupAutoStop = (session, state, cfg, gameType, endMsg, showRank, rankTitle, rankEmpty) => {
|
|
239
415
|
clearGameTimer(state);
|
|
240
|
-
let inactiveTime =
|
|
416
|
+
let inactiveTime = 60;
|
|
241
417
|
if (gameType === 'guessNumber')
|
|
242
418
|
inactiveTime = cfg.guessNumber.autoStopInactiveTime;
|
|
243
419
|
else if (gameType === 'wzHero')
|
|
@@ -248,16 +424,11 @@ const setupAutoStop = (session, state, cfg, gameType, endMsg, showRank) => {
|
|
|
248
424
|
inactiveTime = cfg.chengyuJielong.autoStopInactiveTime;
|
|
249
425
|
else if (gameType === 'calc24')
|
|
250
426
|
inactiveTime = cfg.calc24.autoStopInactiveTime;
|
|
251
|
-
else if (gameType === 'passwordLock')
|
|
252
|
-
inactiveTime = cfg.passwordLock.autoStopInactiveTime;
|
|
253
427
|
if (inactiveTime <= 0)
|
|
254
428
|
return;
|
|
255
429
|
state.stopTimer = setTimeout(() => {
|
|
256
|
-
clearGameData(state);
|
|
430
|
+
clearGameData(state, showRank, session, rankTitle, rankEmpty);
|
|
257
431
|
session.send(endMsg);
|
|
258
|
-
if (showRank && session.channelId) {
|
|
259
|
-
session.send(generateRankText(state.players));
|
|
260
|
-
}
|
|
261
432
|
}, inactiveTime * 1000);
|
|
262
433
|
};
|
|
263
434
|
const calculate24 = (numbers) => {
|
|
@@ -305,36 +476,15 @@ const generateSolvable24Numbers = (min, max) => {
|
|
|
305
476
|
}
|
|
306
477
|
return [6, 4, 3, 1];
|
|
307
478
|
};
|
|
308
|
-
const generatePasswordHint = (password, guess) => {
|
|
309
|
-
let correctPos = 0;
|
|
310
|
-
let correctNum = 0;
|
|
311
|
-
const passwordArr = password.split('');
|
|
312
|
-
const guessArr = guess.split('');
|
|
313
|
-
const passwordUsed = [false, false, false, false];
|
|
314
|
-
const guessUsed = [false, false, false, false];
|
|
315
|
-
for (let i = 0; i < 4; i++) {
|
|
316
|
-
if (passwordArr[i] === guessArr[i]) {
|
|
317
|
-
correctPos++;
|
|
318
|
-
passwordUsed[i] = true;
|
|
319
|
-
guessUsed[i] = true;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
for (let i = 0; i < 4; i++) {
|
|
323
|
-
if (guessUsed[i])
|
|
324
|
-
continue;
|
|
325
|
-
for (let j = 0; j < 4; j++) {
|
|
326
|
-
if (!passwordUsed[j] && passwordArr[j] === guessArr[i]) {
|
|
327
|
-
correctNum++;
|
|
328
|
-
passwordUsed[j] = true;
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return `提示:${correctPos}个数字位置正确,${correctNum}个数字正确但位置错误`;
|
|
334
|
-
};
|
|
335
479
|
const evaluateExpression = (expr) => {
|
|
336
480
|
try {
|
|
337
|
-
|
|
481
|
+
let cleanExpr = expr.replace(/\s+/g, '');
|
|
482
|
+
cleanExpr = cleanExpr.replace(/[×xX]/g, '*');
|
|
483
|
+
cleanExpr = cleanExpr.replace(/[÷/]/g, '/');
|
|
484
|
+
cleanExpr = cleanExpr.replace(/\/\//g, '/');
|
|
485
|
+
if (!/^[\d\+\-\*\/\(\)\[\]\{\}]+$/.test(cleanExpr)) {
|
|
486
|
+
return null;
|
|
487
|
+
}
|
|
338
488
|
const normalizedExpr = cleanExpr.replace(/[\[\{]/g, '(').replace(/[\]\}]/g, ')');
|
|
339
489
|
const func = new Function('return ' + normalizedExpr);
|
|
340
490
|
const result = func();
|
|
@@ -349,112 +499,12 @@ const evaluateExpression = (expr) => {
|
|
|
349
499
|
};
|
|
350
500
|
function apply(ctx, cfg) {
|
|
351
501
|
const d = {
|
|
352
|
-
guessNumber:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
tooBig: "猜大啦!当前范围更新为 [{0}-{1}]",
|
|
359
|
-
correct: "恭喜你猜中数字!本轮你不得分,其他参与者各得1分~",
|
|
360
|
-
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
361
|
-
gameEnd: "🎉 猜数字比赛结束!🎉",
|
|
362
|
-
rankTitle: "🏆 排行榜 🏆",
|
|
363
|
-
rankEmpty: "暂无参与记录~",
|
|
364
|
-
disabled: "猜数字功能已关闭,请联系管理员开启",
|
|
365
|
-
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
366
|
-
},
|
|
367
|
-
wzHero: {
|
|
368
|
-
start: "猜王者英雄开始!本次共 {0} 回合~当前难度:{1}",
|
|
369
|
-
startUsage: "用法错误!正确用法:猜王者英雄 开始 | 猜王者英雄 [答案] | 猜王者英雄 提示 | 猜王者英雄 结束",
|
|
370
|
-
stop: "猜王者英雄比赛已停止",
|
|
371
|
-
notStarted: "猜王者英雄比赛尚未开始,请输入 猜王者英雄 开始 开始游戏",
|
|
372
|
-
hint: "提示",
|
|
373
|
-
apiError: "API请求失败,请稍后再试",
|
|
374
|
-
correct: "答对啦!你获得1分~",
|
|
375
|
-
wrong: "答错啦~正确答案是:{0},你不得分",
|
|
376
|
-
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
377
|
-
gameEnd: "🎉 猜王者英雄比赛结束!🎉",
|
|
378
|
-
rankTitle: "🏆 排行榜 🏆",
|
|
379
|
-
rankEmpty: "暂无参与记录~",
|
|
380
|
-
disabled: "猜王者英雄功能已关闭,请联系管理员开启",
|
|
381
|
-
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
382
|
-
},
|
|
383
|
-
chengyuImage: {
|
|
384
|
-
start: "看图猜成语比赛开始!本次共 {0} 回合~当前提示级别:{1}",
|
|
385
|
-
stop: "看图猜成语比赛已停止",
|
|
386
|
-
submitUsage: "请直接输入 看图猜成语 [答案],或输入 看图猜成语 提示 获取线索",
|
|
387
|
-
notStarted: "看图猜成语比赛尚未开始,请输入 看图猜成语 开始 开始游戏",
|
|
388
|
-
next: "第 {0} 题来啦!",
|
|
389
|
-
hintGet: "【提示】{0}",
|
|
390
|
-
hintError: "获取提示失败,请稍后再试",
|
|
391
|
-
apiError: "API请求失败,请稍后再试",
|
|
392
|
-
correct: "答对啦!你获得1分~",
|
|
393
|
-
wrong: "答错啦~正确答案是:{0},你不得分",
|
|
394
|
-
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
395
|
-
gameEnd: "🎉 看图猜成语比赛结束!🎉",
|
|
396
|
-
rankTitle: "🏆 排行榜 🏆",
|
|
397
|
-
rankEmpty: "暂无参与记录~",
|
|
398
|
-
disabled: "看图猜成语功能已关闭,请联系管理员开启",
|
|
399
|
-
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
400
|
-
},
|
|
401
|
-
chengyuJielong: {
|
|
402
|
-
start: "成语接龙比赛开始!本次共 {0} 回合~我先来~",
|
|
403
|
-
stop: "成语接龙比赛已停止",
|
|
404
|
-
notStarted: "成语接龙比赛尚未开始,请输入 成语接龙 开始 开始游戏",
|
|
405
|
-
joinUsage: "请直接发送 成语接龙 [成语] 参与接龙",
|
|
406
|
-
apiError: "API请求失败,请稍后再试",
|
|
407
|
-
botTurn: "该我了!我接:{0}({1})\n释义:{2}",
|
|
408
|
-
botWin: "哈哈我接不上了!本轮结束~",
|
|
409
|
-
autoPlayTooMany: "我已经主动参与 {0} 次啦,不再主动接啦~",
|
|
410
|
-
gameInactiveStop: "太久没人玩啦,比赛自动结束~",
|
|
411
|
-
notIdiom: "请发送四字成语参与游戏~",
|
|
412
|
-
correct: "接龙成功!你获得1分~",
|
|
413
|
-
wrong: "接龙失败!你不得分,其他参与者各得1分~",
|
|
414
|
-
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
415
|
-
gameEnd: "🎉 成语接龙比赛结束!🎉",
|
|
416
|
-
rankTitle: "🏆 排行榜 🏆",
|
|
417
|
-
rankEmpty: "暂无参与记录~",
|
|
418
|
-
disabled: "成语接龙功能已关闭,请联系管理员开启",
|
|
419
|
-
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
420
|
-
},
|
|
421
|
-
calc24: {
|
|
422
|
-
start: "算24点游戏开始!本次共 {0} 回合~当前难度:{1}",
|
|
423
|
-
stop: "算24点游戏已停止",
|
|
424
|
-
notStarted: "算24点游戏尚未开始,请输入 算24点 开始 开始游戏",
|
|
425
|
-
generate: "📝 第 {0} 题({1}):用 {2} 通过加减乘除和括号算出24!",
|
|
426
|
-
correct: "答对啦!你获得1分~",
|
|
427
|
-
wrong: "答错啦~",
|
|
428
|
-
impossible: "这组数无法算出24!本题作废,换一组数字~",
|
|
429
|
-
solved: "这组数已经被答对啦,换一组数字~",
|
|
430
|
-
roundEnd: "第 {0} 回合结束!剩余回合:{1}",
|
|
431
|
-
gameEnd: "🎉 算24点游戏结束!🎉",
|
|
432
|
-
rankTitle: "🏆 排行榜 🏆",
|
|
433
|
-
rankEmpty: "暂无参与记录~",
|
|
434
|
-
disabled: "算24点功能已关闭,请联系管理员开启",
|
|
435
|
-
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
436
|
-
},
|
|
437
|
-
passwordLock: {
|
|
438
|
-
start: "猜密码游戏开始!密码为4位数字,你有 {0} 次猜测机会~",
|
|
439
|
-
stop: "猜密码游戏已停止",
|
|
440
|
-
notStarted: "猜密码游戏尚未开始,请输入 猜密码 开始 开始游戏",
|
|
441
|
-
guess: "你猜测的密码是:{0},这是第 {1} 次猜测",
|
|
442
|
-
correct: "🎉 恭喜!你猜对了密码 {0}!总共猜测了 {1} 次,获得10分~",
|
|
443
|
-
wrong: "密码错误!{0}",
|
|
444
|
-
solved: "密码已经被猜出来啦,游戏结束~",
|
|
445
|
-
noChance: "❌ 没有猜测机会了!正确密码是:{0}~",
|
|
446
|
-
invalidPassword: "无效的密码!请输入4位数字",
|
|
447
|
-
gameEnd: "🎉 猜密码游戏结束!🎉",
|
|
448
|
-
rankTitle: "🏆 排行榜 🏆",
|
|
449
|
-
rankEmpty: "暂无参与记录~",
|
|
450
|
-
disabled: "猜密码功能已关闭,请联系管理员开启",
|
|
451
|
-
autoStop: "游戏因长时间无人操作,已自动结束"
|
|
452
|
-
},
|
|
453
|
-
common: {
|
|
454
|
-
gameRunning: "当前已有游戏在运行中,请先结束当前游戏后再开始新游戏!",
|
|
455
|
-
gameStoppedByInactive: "游戏因长时间无人操作,已自动结束",
|
|
456
|
-
paramError: "参数错误!请检查输入格式"
|
|
457
|
-
}
|
|
502
|
+
guessNumber: cfg.guessNumber.messages,
|
|
503
|
+
wzHero: cfg.wzHero.messages,
|
|
504
|
+
chengyuImage: cfg.chengyuImage.messages,
|
|
505
|
+
chengyuJielong: cfg.chengyuJielong.messages,
|
|
506
|
+
calc24: cfg.calc24.messages,
|
|
507
|
+
common: cfg.commonMessages
|
|
458
508
|
};
|
|
459
509
|
try {
|
|
460
510
|
const p = path_1.default.join(__dirname, './locales/zh-CN.yml');
|
|
@@ -494,7 +544,7 @@ function apply(ctx, cfg) {
|
|
|
494
544
|
session.send(d.chengyuJielong.autoPlayTooMany.replace('{0}', String(cfg.chengyuJielong.autoPlayMaxCount)));
|
|
495
545
|
st.chengyuJielong.hasTriggeredAutoPlay = true;
|
|
496
546
|
gameStates.set(key, st);
|
|
497
|
-
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank);
|
|
547
|
+
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
498
548
|
return;
|
|
499
549
|
}
|
|
500
550
|
st.chengyuJielong.hasTriggeredAutoPlay = true;
|
|
@@ -528,7 +578,7 @@ function apply(ctx, cfg) {
|
|
|
528
578
|
await session.send(m);
|
|
529
579
|
await session.send(d.chengyuJielong.gameEnd);
|
|
530
580
|
if (cfg.chengyuJielong.showRank && !isPrivate(session)) {
|
|
531
|
-
const rankText = generateRankText(st.chengyuJielong.players);
|
|
581
|
+
const rankText = generateRankText(st.chengyuJielong.players, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
532
582
|
await session.send(rankText);
|
|
533
583
|
}
|
|
534
584
|
clearGameData(st.chengyuJielong);
|
|
@@ -545,7 +595,7 @@ function apply(ctx, cfg) {
|
|
|
545
595
|
await session.send(d.chengyuJielong.apiError);
|
|
546
596
|
}
|
|
547
597
|
gameStates.set(key, st);
|
|
548
|
-
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank);
|
|
598
|
+
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
549
599
|
};
|
|
550
600
|
ctx.middleware(async (session, next) => {
|
|
551
601
|
if (!session.content)
|
|
@@ -564,7 +614,7 @@ function apply(ctx, cfg) {
|
|
|
564
614
|
st.chengyuJielong.participants.push(playerKey);
|
|
565
615
|
}
|
|
566
616
|
if (!isFourCharIdiom(content)) {
|
|
567
|
-
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank);
|
|
617
|
+
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
568
618
|
scheduleAutoPlay(session, key, st);
|
|
569
619
|
return next();
|
|
570
620
|
}
|
|
@@ -605,7 +655,7 @@ function apply(ctx, cfg) {
|
|
|
605
655
|
await session.send(m);
|
|
606
656
|
await session.send(d.chengyuJielong.gameEnd);
|
|
607
657
|
if (cfg.chengyuJielong.showRank && !isPrivate(session)) {
|
|
608
|
-
const rankText = generateRankText(st.chengyuJielong.players);
|
|
658
|
+
const rankText = generateRankText(st.chengyuJielong.players, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
609
659
|
await session.send(rankText);
|
|
610
660
|
}
|
|
611
661
|
clearGameData(st.chengyuJielong);
|
|
@@ -614,7 +664,7 @@ function apply(ctx, cfg) {
|
|
|
614
664
|
m += '\n' + d.chengyuJielong.roundEnd.replace('{0}', st.chengyuJielong.currentRound.toString()).replace('{1}', (st.chengyuJielong.totalRounds - st.chengyuJielong.currentRound).toString());
|
|
615
665
|
await session.send(m);
|
|
616
666
|
st.chengyuJielong.hasTriggeredAutoPlay = false;
|
|
617
|
-
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank);
|
|
667
|
+
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
618
668
|
scheduleAutoPlay(session, key, st);
|
|
619
669
|
}
|
|
620
670
|
}
|
|
@@ -627,7 +677,7 @@ function apply(ctx, cfg) {
|
|
|
627
677
|
}
|
|
628
678
|
catch (error) {
|
|
629
679
|
await session.send(d.chengyuJielong.apiError);
|
|
630
|
-
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank);
|
|
680
|
+
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
631
681
|
scheduleAutoPlay(session, key, st);
|
|
632
682
|
}
|
|
633
683
|
gameStates.set(key, st);
|
|
@@ -660,11 +710,11 @@ function apply(ctx, cfg) {
|
|
|
660
710
|
catch (error) {
|
|
661
711
|
await session.send(d.chengyuImage.hintError);
|
|
662
712
|
}
|
|
663
|
-
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank);
|
|
713
|
+
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
664
714
|
return;
|
|
665
715
|
}
|
|
666
716
|
if (!isFourCharIdiom(content)) {
|
|
667
|
-
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank);
|
|
717
|
+
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
668
718
|
return next();
|
|
669
719
|
}
|
|
670
720
|
try {
|
|
@@ -690,7 +740,7 @@ function apply(ctx, cfg) {
|
|
|
690
740
|
await session.send(reply);
|
|
691
741
|
await session.send(d.chengyuImage.gameEnd);
|
|
692
742
|
if (cfg.chengyuImage.showRank && !isPrivate(session)) {
|
|
693
|
-
const rankText = generateRankText(st.chengyuImage.players);
|
|
743
|
+
const rankText = generateRankText(st.chengyuImage.players, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
694
744
|
await session.send(rankText);
|
|
695
745
|
}
|
|
696
746
|
clearGameData(st.chengyuImage);
|
|
@@ -720,7 +770,7 @@ function apply(ctx, cfg) {
|
|
|
720
770
|
st.chengyuImage.started = false;
|
|
721
771
|
clearGameTimer(st.chengyuImage);
|
|
722
772
|
if (cfg.chengyuImage.showRank && !isPrivate(session)) {
|
|
723
|
-
const rankText = generateRankText(st.chengyuImage.players);
|
|
773
|
+
const rankText = generateRankText(st.chengyuImage.players, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
724
774
|
await session.send(rankText);
|
|
725
775
|
}
|
|
726
776
|
clearGameData(st.chengyuImage);
|
|
@@ -740,7 +790,7 @@ function apply(ctx, cfg) {
|
|
|
740
790
|
catch (error) {
|
|
741
791
|
await session.send(d.chengyuImage.apiError);
|
|
742
792
|
}
|
|
743
|
-
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank);
|
|
793
|
+
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
744
794
|
gameStates.set(key, st);
|
|
745
795
|
return;
|
|
746
796
|
}
|
|
@@ -751,7 +801,7 @@ function apply(ctx, cfg) {
|
|
|
751
801
|
st.wzHero.participants.push(playerKey);
|
|
752
802
|
}
|
|
753
803
|
if (content === '结束') {
|
|
754
|
-
clearGameData(st.wzHero);
|
|
804
|
+
clearGameData(st.wzHero, cfg.wzHero.showRank && !isPrivate(session), session, d.wzHero.rankTitle, d.wzHero.rankEmpty);
|
|
755
805
|
await session.send(d.wzHero.stop);
|
|
756
806
|
gameStates.set(key, st);
|
|
757
807
|
return;
|
|
@@ -775,7 +825,7 @@ function apply(ctx, cfg) {
|
|
|
775
825
|
await session.send(text);
|
|
776
826
|
await session.send(d.wzHero.gameEnd);
|
|
777
827
|
if (cfg.wzHero.showRank && !isPrivate(session)) {
|
|
778
|
-
const rankText = generateRankText(st.wzHero.players);
|
|
828
|
+
const rankText = generateRankText(st.wzHero.players, d.wzHero.rankTitle, d.wzHero.rankEmpty);
|
|
779
829
|
await session.send(rankText);
|
|
780
830
|
}
|
|
781
831
|
clearGameData(st.wzHero);
|
|
@@ -808,7 +858,7 @@ function apply(ctx, cfg) {
|
|
|
808
858
|
catch (error) {
|
|
809
859
|
await session.send(d.wzHero.apiError);
|
|
810
860
|
}
|
|
811
|
-
setupAutoStop(session, st.wzHero, cfg, 'wzHero', d.wzHero.autoStop, cfg.wzHero.showRank);
|
|
861
|
+
setupAutoStop(session, st.wzHero, cfg, 'wzHero', d.wzHero.autoStop, cfg.wzHero.showRank, d.wzHero.rankTitle, d.wzHero.rankEmpty);
|
|
812
862
|
gameStates.set(key, st);
|
|
813
863
|
return;
|
|
814
864
|
}
|
|
@@ -819,14 +869,14 @@ function apply(ctx, cfg) {
|
|
|
819
869
|
st.guessNumber.participants.push(playerKey);
|
|
820
870
|
}
|
|
821
871
|
if (content === '结束') {
|
|
822
|
-
clearGameData(st.guessNumber);
|
|
872
|
+
clearGameData(st.guessNumber, cfg.guessNumber.showRank && !isPrivate(session), session, d.guessNumber.rankTitle, d.guessNumber.rankEmpty);
|
|
823
873
|
await session.send(d.guessNumber.stop);
|
|
824
874
|
gameStates.set(key, st);
|
|
825
875
|
return;
|
|
826
876
|
}
|
|
827
877
|
const num = parseInt(content);
|
|
828
878
|
if (isNaN(num)) {
|
|
829
|
-
setupAutoStop(session, st.guessNumber, cfg, 'guessNumber', d.guessNumber.autoStop, cfg.guessNumber.showRank);
|
|
879
|
+
setupAutoStop(session, st.guessNumber, cfg, 'guessNumber', d.guessNumber.autoStop, cfg.guessNumber.showRank, d.guessNumber.rankTitle, d.guessNumber.rankEmpty);
|
|
830
880
|
return next();
|
|
831
881
|
}
|
|
832
882
|
if (num === st.guessNumber.target) {
|
|
@@ -838,7 +888,7 @@ function apply(ctx, cfg) {
|
|
|
838
888
|
clearGameTimer(st.guessNumber);
|
|
839
889
|
await session.send(d.guessNumber.gameEnd);
|
|
840
890
|
if (cfg.guessNumber.showRank && !isPrivate(session)) {
|
|
841
|
-
const rankText = generateRankText(st.guessNumber.players);
|
|
891
|
+
const rankText = generateRankText(st.guessNumber.players, d.guessNumber.rankTitle, d.guessNumber.rankEmpty);
|
|
842
892
|
await session.send(rankText);
|
|
843
893
|
}
|
|
844
894
|
clearGameData(st.guessNumber);
|
|
@@ -857,7 +907,7 @@ function apply(ctx, cfg) {
|
|
|
857
907
|
st.guessNumber.currentMax = num - 1;
|
|
858
908
|
await session.send(d.guessNumber.tooBig.replace('{0}', st.guessNumber.currentMin.toString()).replace('{1}', st.guessNumber.currentMax.toString()));
|
|
859
909
|
}
|
|
860
|
-
setupAutoStop(session, st.guessNumber, cfg, 'guessNumber', d.guessNumber.autoStop, cfg.guessNumber.showRank);
|
|
910
|
+
setupAutoStop(session, st.guessNumber, cfg, 'guessNumber', d.guessNumber.autoStop, cfg.guessNumber.showRank, d.guessNumber.rankTitle, d.guessNumber.rankEmpty);
|
|
861
911
|
gameStates.set(key, st);
|
|
862
912
|
return;
|
|
863
913
|
}
|
|
@@ -868,7 +918,7 @@ function apply(ctx, cfg) {
|
|
|
868
918
|
st.calc24.participants.push(playerKey);
|
|
869
919
|
}
|
|
870
920
|
if (content === '结束') {
|
|
871
|
-
clearGameData(st.calc24);
|
|
921
|
+
clearGameData(st.calc24, cfg.calc24.showRank && !isPrivate(session), session, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
872
922
|
await session.send(d.calc24.stop);
|
|
873
923
|
gameStates.set(key, st);
|
|
874
924
|
return;
|
|
@@ -883,12 +933,12 @@ function apply(ctx, cfg) {
|
|
|
883
933
|
.replace('{1}', st.calc24.difficulty)
|
|
884
934
|
.replace('{2}', st.calc24.numbers.join('、')));
|
|
885
935
|
}
|
|
886
|
-
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank);
|
|
936
|
+
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
887
937
|
return;
|
|
888
938
|
}
|
|
889
939
|
if (st.calc24.solved) {
|
|
890
940
|
await session.send(d.calc24.solved);
|
|
891
|
-
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank);
|
|
941
|
+
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
892
942
|
return;
|
|
893
943
|
}
|
|
894
944
|
const result = evaluateExpression(content);
|
|
@@ -903,7 +953,7 @@ function apply(ctx, cfg) {
|
|
|
903
953
|
clearGameTimer(st.calc24);
|
|
904
954
|
await session.send(d.calc24.gameEnd);
|
|
905
955
|
if (cfg.calc24.showRank && !isPrivate(session)) {
|
|
906
|
-
const rankText = generateRankText(st.calc24.players);
|
|
956
|
+
const rankText = generateRankText(st.calc24.players, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
907
957
|
await session.send(rankText);
|
|
908
958
|
}
|
|
909
959
|
clearGameData(st.calc24);
|
|
@@ -922,75 +972,7 @@ function apply(ctx, cfg) {
|
|
|
922
972
|
else {
|
|
923
973
|
await session.send(d.calc24.wrong);
|
|
924
974
|
}
|
|
925
|
-
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank);
|
|
926
|
-
gameStates.set(key, st);
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
if (cfg.enablePasswordLock && st.passwordLock.started) {
|
|
930
|
-
clearGameTimer(st.passwordLock);
|
|
931
|
-
if (!st.passwordLock.players[playerKey]) {
|
|
932
|
-
st.passwordLock.players[playerKey] = getPlayerData(session);
|
|
933
|
-
st.passwordLock.participants.push(playerKey);
|
|
934
|
-
}
|
|
935
|
-
if (content === '结束') {
|
|
936
|
-
clearGameData(st.passwordLock);
|
|
937
|
-
await session.send(d.passwordLock.stop);
|
|
938
|
-
gameStates.set(key, st);
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
if (st.passwordLock.solved) {
|
|
942
|
-
await session.send(d.passwordLock.solved);
|
|
943
|
-
setupAutoStop(session, st.passwordLock, cfg, 'passwordLock', d.passwordLock.autoStop, cfg.passwordLock.showRank);
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
if (!/^\d{4}$/.test(content)) {
|
|
947
|
-
await session.send(d.passwordLock.invalidPassword);
|
|
948
|
-
setupAutoStop(session, st.passwordLock, cfg, 'passwordLock', d.passwordLock.autoStop, cfg.passwordLock.showRank);
|
|
949
|
-
return;
|
|
950
|
-
}
|
|
951
|
-
st.passwordLock.playerGuess = content;
|
|
952
|
-
st.passwordLock.guessTimes += 1;
|
|
953
|
-
await session.send(d.passwordLock.guess.replace('{0}', content).replace('{1}', st.passwordLock.guessTimes.toString()));
|
|
954
|
-
if (content === st.passwordLock.password) {
|
|
955
|
-
const score = 10 - (st.passwordLock.guessTimes - 1);
|
|
956
|
-
await session.send(d.passwordLock.correct.replace('{0}', content).replace('{1}', st.passwordLock.guessTimes.toString()));
|
|
957
|
-
st.passwordLock.players[playerKey].score += score > 0 ? score : 1;
|
|
958
|
-
st.passwordLock.players[playerKey].correctCount += 1;
|
|
959
|
-
st.passwordLock.solved = true;
|
|
960
|
-
st.passwordLock.started = false;
|
|
961
|
-
clearGameTimer(st.passwordLock);
|
|
962
|
-
await session.send(d.passwordLock.gameEnd);
|
|
963
|
-
if (cfg.passwordLock.showRank && !isPrivate(session)) {
|
|
964
|
-
const rankText = generateRankText(st.passwordLock.players);
|
|
965
|
-
await session.send(rankText);
|
|
966
|
-
}
|
|
967
|
-
clearGameData(st.passwordLock);
|
|
968
|
-
}
|
|
969
|
-
else {
|
|
970
|
-
let hint = '';
|
|
971
|
-
if (cfg.passwordLock.showHint) {
|
|
972
|
-
hint = generatePasswordHint(st.passwordLock.password, content);
|
|
973
|
-
await session.send(d.passwordLock.wrong.replace('{0}', hint));
|
|
974
|
-
}
|
|
975
|
-
else {
|
|
976
|
-
await session.send(d.passwordLock.wrong.replace('{0}', ''));
|
|
977
|
-
}
|
|
978
|
-
if (st.passwordLock.guessTimes >= st.passwordLock.maxGuessTimes) {
|
|
979
|
-
await session.send(d.passwordLock.noChance.replace('{0}', st.passwordLock.password));
|
|
980
|
-
st.passwordLock.started = false;
|
|
981
|
-
clearGameTimer(st.passwordLock);
|
|
982
|
-
await session.send(d.passwordLock.gameEnd);
|
|
983
|
-
if (cfg.passwordLock.showRank && !isPrivate(session)) {
|
|
984
|
-
const rankText = generateRankText(st.passwordLock.players);
|
|
985
|
-
await session.send(rankText);
|
|
986
|
-
}
|
|
987
|
-
clearGameData(st.passwordLock);
|
|
988
|
-
}
|
|
989
|
-
else {
|
|
990
|
-
await session.send(`剩余猜测次数:${st.passwordLock.maxGuessTimes - st.passwordLock.guessTimes}`);
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
setupAutoStop(session, st.passwordLock, cfg, 'passwordLock', d.passwordLock.autoStop, cfg.passwordLock.showRank);
|
|
975
|
+
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
994
976
|
gameStates.set(key, st);
|
|
995
977
|
return;
|
|
996
978
|
}
|
|
@@ -1016,10 +998,10 @@ function apply(ctx, cfg) {
|
|
|
1016
998
|
await session.send(d.guessNumber.start.replace('{0}', st.guessNumber.totalRounds.toString()));
|
|
1017
999
|
await session.send(`猜数字范围:${st.guessNumber.currentMin} - ${st.guessNumber.currentMax}`);
|
|
1018
1000
|
gameStates.set(key, st);
|
|
1019
|
-
setupAutoStop(session, st.guessNumber, cfg, 'guessNumber', d.guessNumber.autoStop, cfg.guessNumber.showRank);
|
|
1001
|
+
setupAutoStop(session, st.guessNumber, cfg, 'guessNumber', d.guessNumber.autoStop, cfg.guessNumber.showRank, d.guessNumber.rankTitle, d.guessNumber.rankEmpty);
|
|
1020
1002
|
}
|
|
1021
1003
|
else if (action === '结束') {
|
|
1022
|
-
clearGameData(st.guessNumber);
|
|
1004
|
+
clearGameData(st.guessNumber, cfg.guessNumber.showRank && !isPrivate(session), session, d.guessNumber.rankTitle, d.guessNumber.rankEmpty);
|
|
1023
1005
|
await session.send(d.guessNumber.stop);
|
|
1024
1006
|
gameStates.set(key, st);
|
|
1025
1007
|
}
|
|
@@ -1058,10 +1040,10 @@ function apply(ctx, cfg) {
|
|
|
1058
1040
|
await session.send(d.wzHero.apiError);
|
|
1059
1041
|
}
|
|
1060
1042
|
gameStates.set(key, st);
|
|
1061
|
-
setupAutoStop(session, st.wzHero, cfg, 'wzHero', d.wzHero.autoStop, cfg.wzHero.showRank);
|
|
1043
|
+
setupAutoStop(session, st.wzHero, cfg, 'wzHero', d.wzHero.autoStop, cfg.wzHero.showRank, d.wzHero.rankTitle, d.wzHero.rankEmpty);
|
|
1062
1044
|
}
|
|
1063
1045
|
else if (action === '结束') {
|
|
1064
|
-
clearGameData(st.wzHero);
|
|
1046
|
+
clearGameData(st.wzHero, cfg.wzHero.showRank && !isPrivate(session), session, d.wzHero.rankTitle, d.wzHero.rankEmpty);
|
|
1065
1047
|
await session.send(d.wzHero.stop);
|
|
1066
1048
|
gameStates.set(key, st);
|
|
1067
1049
|
}
|
|
@@ -1106,10 +1088,10 @@ function apply(ctx, cfg) {
|
|
|
1106
1088
|
await session.send(d.chengyuImage.apiError);
|
|
1107
1089
|
}
|
|
1108
1090
|
gameStates.set(key, st);
|
|
1109
|
-
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank);
|
|
1091
|
+
setupAutoStop(session, st.chengyuImage, cfg, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
1110
1092
|
}
|
|
1111
1093
|
else if (action === '结束') {
|
|
1112
|
-
clearGameData(st.chengyuImage);
|
|
1094
|
+
clearGameData(st.chengyuImage, cfg.chengyuImage.showRank && !isPrivate(session), session, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
|
|
1113
1095
|
await session.send(d.chengyuImage.stop);
|
|
1114
1096
|
gameStates.set(key, st);
|
|
1115
1097
|
}
|
|
@@ -1136,10 +1118,10 @@ function apply(ctx, cfg) {
|
|
|
1136
1118
|
await session.send(d.chengyuJielong.start.replace('{0}', st.chengyuJielong.totalRounds.toString()));
|
|
1137
1119
|
gameStates.set(key, st);
|
|
1138
1120
|
scheduleAutoPlay(session, key, st);
|
|
1139
|
-
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank);
|
|
1121
|
+
setupAutoStop(session, st.chengyuJielong, cfg, 'chengyuJielong', d.chengyuJielong.autoStop, cfg.chengyuJielong.showRank, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
1140
1122
|
}
|
|
1141
1123
|
else if (action === '结束') {
|
|
1142
|
-
clearGameData(st.chengyuJielong);
|
|
1124
|
+
clearGameData(st.chengyuJielong, cfg.chengyuJielong.showRank && !isPrivate(session), session, d.chengyuJielong.rankTitle, d.chengyuJielong.rankEmpty);
|
|
1143
1125
|
await session.send(d.chengyuJielong.stop);
|
|
1144
1126
|
gameStates.set(key, st);
|
|
1145
1127
|
}
|
|
@@ -1171,10 +1153,10 @@ function apply(ctx, cfg) {
|
|
|
1171
1153
|
.replace('{1}', st.calc24.difficulty)
|
|
1172
1154
|
.replace('{2}', st.calc24.numbers.join('、')));
|
|
1173
1155
|
gameStates.set(key, st);
|
|
1174
|
-
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank);
|
|
1156
|
+
setupAutoStop(session, st.calc24, cfg, 'calc24', d.calc24.autoStop, cfg.calc24.showRank, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
1175
1157
|
}
|
|
1176
1158
|
else if (action === '结束') {
|
|
1177
|
-
clearGameData(st.calc24);
|
|
1159
|
+
clearGameData(st.calc24, cfg.calc24.showRank && !isPrivate(session), session, d.calc24.rankTitle, d.calc24.rankEmpty);
|
|
1178
1160
|
await session.send(d.calc24.stop);
|
|
1179
1161
|
gameStates.set(key, st);
|
|
1180
1162
|
}
|
|
@@ -1182,34 +1164,4 @@ function apply(ctx, cfg) {
|
|
|
1182
1164
|
await session.send('请输入:算24点 开始 或 算24点 结束');
|
|
1183
1165
|
}
|
|
1184
1166
|
});
|
|
1185
|
-
ctx.command('猜密码 <action>', '猜密码游戏')
|
|
1186
|
-
.action(async (argv, action) => {
|
|
1187
|
-
const session = argv.session;
|
|
1188
|
-
if (!session)
|
|
1189
|
-
return;
|
|
1190
|
-
const key = getSessionKey(session);
|
|
1191
|
-
const st = gameStates.get(key) || initState(key, cfg);
|
|
1192
|
-
if (checkGameRunning(st, 'passwordLock')) {
|
|
1193
|
-
await session.send(d.common.gameRunning);
|
|
1194
|
-
return;
|
|
1195
|
-
}
|
|
1196
|
-
if (action === '开始') {
|
|
1197
|
-
st.passwordLock.started = true;
|
|
1198
|
-
st.passwordLock.currentRound = 1;
|
|
1199
|
-
st.passwordLock.guessTimes = 0;
|
|
1200
|
-
st.passwordLock.solved = false;
|
|
1201
|
-
st.passwordLock.password = koishi_1.Random.int(1000, 9999).toString();
|
|
1202
|
-
await session.send(d.passwordLock.start.replace('{0}', st.passwordLock.maxGuessTimes.toString()));
|
|
1203
|
-
gameStates.set(key, st);
|
|
1204
|
-
setupAutoStop(session, st.passwordLock, cfg, 'passwordLock', d.passwordLock.autoStop, cfg.passwordLock.showRank);
|
|
1205
|
-
}
|
|
1206
|
-
else if (action === '结束') {
|
|
1207
|
-
clearGameData(st.passwordLock);
|
|
1208
|
-
await session.send(d.passwordLock.stop);
|
|
1209
|
-
gameStates.set(key, st);
|
|
1210
|
-
}
|
|
1211
|
-
else {
|
|
1212
|
-
await session.send('请输入:猜密码 开始 或 猜密码 结束');
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
1167
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-game-mini",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Koishi多功能小游戏合集:猜数字、猜王者英雄、看图猜成语、成语接龙、算24
|
|
3
|
+
"version": "0.2.6",
|
|
4
|
+
"description": "Koishi多功能小游戏合集:猜数字、猜王者英雄、看图猜成语、成语接龙、算24点",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -23,8 +23,6 @@
|
|
|
23
23
|
"成语接龙",
|
|
24
24
|
"算24点",
|
|
25
25
|
"24点",
|
|
26
|
-
"猜密码",
|
|
27
|
-
"密码锁",
|
|
28
26
|
"小游戏"
|
|
29
27
|
],
|
|
30
28
|
"author": "Minecraft-1314",
|
package/readme.md
CHANGED
|
@@ -3,22 +3,21 @@
|
|
|
3
3
|
## 项目介绍 (Project Introduction)
|
|
4
4
|
|
|
5
5
|
### 中文
|
|
6
|
-
这是一款为 Koishi 聊天机器人框架开发的轻量级多功能小游戏插件,包含经典猜数字、猜王者荣耀英雄、看图猜成语、成语接龙、算24
|
|
6
|
+
这是一款为 Koishi 聊天机器人框架开发的轻量级多功能小游戏插件,包含经典猜数字、猜王者荣耀英雄、看图猜成语、成语接龙、算24点五款趣味游戏,兼具易用性与可配置性:
|
|
7
7
|
- **猜数字**:支持自定义数值范围,群聊/私聊模式独立配置自动操作相关参数
|
|
8
8
|
- **猜王者英雄**:基于诗词/提示猜王者荣耀英雄
|
|
9
9
|
- **看图猜成语**:根据图片和备选字猜成语,支持提示功能
|
|
10
10
|
- **成语接龙**:与 Bot 进行成语接龙对战
|
|
11
11
|
- **算24点**:用四个数字通过加减乘除和括号算出24
|
|
12
|
-
- **猜密码**:破解4位数字密码,每次猜测获得位置提示
|
|
13
12
|
|
|
14
13
|
### English
|
|
15
|
-
This is a lightweight, multi-functional mini-game plugin developed for the Koishi chatbot framework. It includes
|
|
14
|
+
This is a lightweight, multi-functional mini-game plugin developed for the Koishi chatbot framework. It includes five fun games: Guess the Number, Guess the King of Glory Hero, Guess the Idiom from the Picture, Idiom Chain, and 24 Points. It boasts ease of use and configurability:
|
|
16
15
|
- **Guess the Number**: Supports customizable numerical ranges; group chat/private chat modes allow independent configuration of automatic operation parameters.
|
|
17
16
|
- **Guess the King of Glory Hero**: Guess the King of Glory hero based on poems/hints.
|
|
18
17
|
- **Guess the Idiom from the Picture**: Guess the idiom based on an image and suggested characters; hints are supported.
|
|
19
18
|
- **Idiom Chain**: Engage in an idiom chain battle with the bot.
|
|
20
19
|
- **24 Points**: Calculate 24 using four numbers through addition, subtraction, multiplication, division, and parentheses.
|
|
21
|
-
|
|
20
|
+
|
|
22
21
|
## 使用说明 (Usage)
|
|
23
22
|
|
|
24
23
|
### 中文
|
|
@@ -47,10 +46,6 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
47
46
|
| 输入算式 | 输入算式如 `(6-2)*(8-2)`,支持小括号、中括号、大括号 |
|
|
48
47
|
| 输入“换题” | 更换当前题目 |
|
|
49
48
|
| `算24点 结束` | 停止当前算24点游戏 |
|
|
50
|
-
| **猜密码** | |
|
|
51
|
-
| `猜密码 开始` | 启动猜密码游戏,生成4位随机密码 |
|
|
52
|
-
| 输入4位数字 | 输入猜测的4位数字 |
|
|
53
|
-
| `猜密码 结束` | 停止当前猜密码游戏 |
|
|
54
49
|
|
|
55
50
|
### English
|
|
56
51
|
| Command | Description |
|
|
@@ -78,10 +73,6 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
78
73
|
| Enter formula | Enter formula like `(6-2)*(8-2)`, supports parentheses, square brackets, curly braces |
|
|
79
74
|
| Enter "换题" | Change current question |
|
|
80
75
|
| `算24点 结束` | Stop the current 24-point calculation game |
|
|
81
|
-
| **Password Guessing** | |
|
|
82
|
-
| `猜密码 开始` | Start the password guessing game, generate a random 4-digit password |
|
|
83
|
-
| Enter 4-digit number | Enter the guessed 4-digit number |
|
|
84
|
-
| `猜密码 结束` | Stop the current password guessing game |
|
|
85
76
|
|
|
86
77
|
## 配置说明 (Configuration)
|
|
87
78
|
|
|
@@ -94,7 +85,6 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
94
85
|
| `enableChengyuImage` | 是否开启看图猜成语游戏功能 | true |
|
|
95
86
|
| `enableChengyuJielong` | 是否开启成语接龙游戏功能 | true |
|
|
96
87
|
| `enableCalc24` | 是否开启算24点游戏功能 | true |
|
|
97
|
-
| `enablePasswordLock` | 是否开启猜密码游戏功能 | true |
|
|
98
88
|
| `enablePrivateGame` | 是否允许私聊玩游戏 | true |
|
|
99
89
|
| **猜数字配置** | | |
|
|
100
90
|
| `guessNumber.min` | 猜数字最小值 | 0 |
|
|
@@ -104,24 +94,24 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
104
94
|
| `guessNumber.showRank` | 是否显示排行榜 | true |
|
|
105
95
|
| `guessNumber.autoPlayDelay` | 机器人自动操作延迟(秒) | 10 |
|
|
106
96
|
| `guessNumber.autoPlayMaxCount` | 机器人最大自动操作次数 | 5 |
|
|
107
|
-
| `guessNumber.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) |
|
|
97
|
+
| `guessNumber.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
108
98
|
| **王者英雄猜谜配置** | | |
|
|
109
99
|
| `wzHero.totalRounds` | 王者英雄猜谜总回合数 | 10 |
|
|
110
100
|
| `wzHero.showRank` | 是否显示排行榜 | true |
|
|
111
101
|
| `wzHero.defaultDifficulty` | 默认难度(简单/中等/困难) | 简单 |
|
|
112
|
-
| `wzHero.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) |
|
|
102
|
+
| `wzHero.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
113
103
|
| **看图猜成语配置** | | |
|
|
114
104
|
| `chengyuImage.totalRounds` | 看图猜成语总回合数 | 10 |
|
|
115
105
|
| `chengyuImage.showRank` | 是否显示排行榜 | true |
|
|
116
106
|
| `chengyuImage.defaultHintLevel` | 默认提示级别(1-5) | 1 |
|
|
117
|
-
| `chengyuImage.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) |
|
|
107
|
+
| `chengyuImage.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
118
108
|
| **成语接龙配置** | | |
|
|
119
109
|
| `chengyuJielong.botParticipateInGroup` | 群聊中机器人是否参与成语接龙 | true |
|
|
120
110
|
| `chengyuJielong.totalRounds` | 成语接龙总回合数 | 10 |
|
|
121
111
|
| `chengyuJielong.showRank` | 是否显示排行榜 | true |
|
|
122
112
|
| `chengyuJielong.autoPlayDelay` | 机器人自动操作延迟(秒) | 10 |
|
|
123
113
|
| `chengyuJielong.autoPlayMaxCount` | 机器人最大自动操作次数 | 5 |
|
|
124
|
-
| `chengyuJielong.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) |
|
|
114
|
+
| `chengyuJielong.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
125
115
|
| **算24点配置** | | |
|
|
126
116
|
| `calc24.totalRounds` | 算24点总回合数 | 5 |
|
|
127
117
|
| `calc24.showRank` | 是否显示排行榜 | true |
|
|
@@ -129,12 +119,7 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
129
119
|
| `calc24.difficultyLevels.easy` | 简单难度数字范围 | min:1, max:8 |
|
|
130
120
|
| `calc24.difficultyLevels.medium` | 中等难度数字范围 | min:1, max:10 |
|
|
131
121
|
| `calc24.difficultyLevels.hard` | 困难难度数字范围 | min:1, max:13 |
|
|
132
|
-
| `calc24.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) |
|
|
133
|
-
| **猜密码配置** | | |
|
|
134
|
-
| `passwordLock.maxGuessTimes` | 密码锁最大猜测次数 | 10 |
|
|
135
|
-
| `passwordLock.showHint` | 是否显示提示 | true |
|
|
136
|
-
| `passwordLock.showRank` | 是否显示排行榜 | true |
|
|
137
|
-
| `passwordLock.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 30 |
|
|
122
|
+
| `calc24.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
|
|
138
123
|
| **API配置** | | |
|
|
139
124
|
| `apiConfig.timeout` | API请求超时时间(毫秒) | 5000 |
|
|
140
125
|
|
|
@@ -147,7 +132,6 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
147
132
|
| `enableChengyuImage` | Whether to enable the idiom guessing from pictures game function | true |
|
|
148
133
|
| `enableChengyuJielong` | Whether to enable the idiom solitaire game function | true |
|
|
149
134
|
| `enableCalc24` | Whether to enable the 24-point calculation game function | true |
|
|
150
|
-
| `enablePasswordLock` | Whether to enable the password guessing game function | true |
|
|
151
135
|
| `enablePrivateGame` | Whether to allow playing games in private chat | true |
|
|
152
136
|
| **Number Guessing Configuration** | | |
|
|
153
137
|
| `guessNumber.min` | Minimum value for number guessing | 0 |
|
|
@@ -157,24 +141,24 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
157
141
|
| `guessNumber.showRank` | Whether to show the ranking | true |
|
|
158
142
|
| `guessNumber.autoPlayDelay` | Bot auto operation delay (seconds) | 10 |
|
|
159
143
|
| `guessNumber.autoPlayMaxCount` | Bot maximum auto operation count | 5 |
|
|
160
|
-
| `guessNumber.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) |
|
|
144
|
+
| `guessNumber.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) | 60 |
|
|
161
145
|
| **King of Glory Hero Guessing Configuration** | | |
|
|
162
146
|
| `wzHero.totalRounds` | Total rounds for King of Glory hero guessing | 10 |
|
|
163
147
|
| `wzHero.showRank` | Whether to show the ranking | true |
|
|
164
148
|
| `wzHero.defaultDifficulty` | Default difficulty (easy/medium/hard) | easy |
|
|
165
|
-
| `wzHero.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) |
|
|
149
|
+
| `wzHero.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) | 60 |
|
|
166
150
|
| **Idiom Guessing from Pictures Configuration** | | |
|
|
167
151
|
| `chengyuImage.totalRounds` | Total rounds for idiom guessing from pictures | 10 |
|
|
168
152
|
| `chengyuImage.showRank` | Whether to show the ranking | true |
|
|
169
153
|
| `chengyuImage.defaultHintLevel` | Default hint level (1-5) | 1 |
|
|
170
|
-
| `chengyuImage.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) |
|
|
154
|
+
| `chengyuImage.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) | 60 |
|
|
171
155
|
| **Idiom Solitaire Configuration** | | |
|
|
172
156
|
| `chengyuJielong.botParticipateInGroup` | Whether the Bot participates in idiom solitaire in group chats | true |
|
|
173
157
|
| `chengyuJielong.totalRounds` | Total rounds for idiom solitaire | 10 |
|
|
174
158
|
| `chengyuJielong.showRank` | Whether to show the ranking | true |
|
|
175
159
|
| `chengyuJielong.autoPlayDelay` | Bot auto operation delay (seconds) | 10 |
|
|
176
160
|
| `chengyuJielong.autoPlayMaxCount` | Bot maximum auto operation count | 5 |
|
|
177
|
-
| `chengyuJielong.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) |
|
|
161
|
+
| `chengyuJielong.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) | 60 |
|
|
178
162
|
| **24-Point Calculation Configuration** | | |
|
|
179
163
|
| `calc24.totalRounds` | Total rounds for 24-point calculation | 5 |
|
|
180
164
|
| `calc24.showRank` | Whether to show the ranking | true |
|
|
@@ -182,19 +166,17 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
|
|
|
182
166
|
| `calc24.difficultyLevels.easy` | Easy difficulty number range | min:1, max:8 |
|
|
183
167
|
| `calc24.difficultyLevels.medium` | Medium difficulty number range | min:1, max:10 |
|
|
184
168
|
| `calc24.difficultyLevels.hard` | Hard difficulty number range | min:1, max:13 |
|
|
185
|
-
| `calc24.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) |
|
|
186
|
-
| **Password Guessing Configuration** | | |
|
|
187
|
-
| `passwordLock.maxGuessTimes` | Maximum guess times for password lock | 10 |
|
|
188
|
-
| `passwordLock.showHint` | Whether to show hints | true |
|
|
189
|
-
| `passwordLock.showRank` | Whether to show the ranking | true |
|
|
190
|
-
| `passwordLock.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) | 30 |
|
|
169
|
+
| `calc24.autoStopInactiveTime` | Game auto stop time due to inactivity (seconds) | 60 |
|
|
191
170
|
| **API Configuration** | | |
|
|
192
171
|
| `apiConfig.timeout` | Timeout time for third-party API requests (milliseconds) | 5000 |
|
|
193
172
|
|
|
194
173
|
## 项目贡献者 (Contributors)
|
|
195
174
|
| 贡献者 | 贡献内容 |
|
|
196
175
|
| --- | --- |
|
|
197
|
-
| Minecraft-1314 |
|
|
176
|
+
| Minecraft-1314 | 插件完整开发 |
|
|
177
|
+
| 慕名API | 慕名API 支持 |
|
|
178
|
+
| 月下独酌API | 月下独酌API 支持 |
|
|
179
|
+
| Minecraft-1314 | 插件完整开发 |
|
|
198
180
|
| (欢迎提交 PR 加入贡献者列表) | |
|
|
199
181
|
|
|
200
182
|
## 许可协议 (License)
|