koishi-plugin-game-mini 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -161,7 +161,7 @@ exports.Config = koishi_1.Schema.object({
161
161
  'enableDice': '启用掷骰子比大小游戏',
162
162
  'enableRps': '启用石头剪刀布游戏',
163
163
  'enableCalc24': '启用算24点游戏',
164
- 'enablePasswordLock': '启用密码锁破解游戏',
164
+ 'enablePasswordLock': '启用猜密码游戏',
165
165
  'enablePrivateGame': '允许私聊玩游戏',
166
166
  'autoPlayDelay': '机器人自动操作延迟(秒)',
167
167
  'autoPlayMaxCount': '机器人最大自动操作次数',
@@ -172,9 +172,9 @@ exports.Config = koishi_1.Schema.object({
172
172
  'guessNumber.botParticipateInGroup': '群聊中机器人参与猜数字',
173
173
  'guessNumber.totalRounds': '猜数字总回合数',
174
174
  'guessNumber.showRank': '猜数字显示排行榜',
175
- 'wzHero': '王者英雄猜谜配置',
176
- 'wzHero.totalRounds': '王者英雄猜谜总回合数',
177
- 'wzHero.showRank': '王者英雄猜谜显示排行榜',
175
+ 'wzHero': '猜王者英雄配置',
176
+ 'wzHero.totalRounds': '猜王者英雄总回合数',
177
+ 'wzHero.showRank': '猜王者英雄显示排行榜',
178
178
  'chengyuImage': '看图猜成语配置',
179
179
  'chengyuImage.totalRounds': '看图猜成语总回合数',
180
180
  'chengyuImage.showRank': '看图猜成语显示排行榜',
@@ -194,10 +194,10 @@ exports.Config = koishi_1.Schema.object({
194
194
  'calc24.totalRounds': '算24点总回合数',
195
195
  'calc24.showRank': '算24点显示排行榜',
196
196
  'calc24.numberRange': '算24点数字范围',
197
- 'passwordLock': '密码锁破解配置',
198
- 'passwordLock.maxGuessTimes': '密码锁最大猜测次数',
199
- 'passwordLock.showHint': '密码锁显示提示',
200
- 'passwordLock.showRank': '密码锁显示排行榜',
197
+ 'passwordLock': '猜密码配置',
198
+ 'passwordLock.maxGuessTimes': '猜密码最大猜测次数',
199
+ 'passwordLock.showHint': '猜密码显示提示',
200
+ 'passwordLock.showRank': '猜密码显示排行榜',
201
201
  'apiConfig': 'API接口配置',
202
202
  'apiConfig.timeout': '请求超时时间(毫秒)'
203
203
  }
@@ -330,7 +330,8 @@ const initState = (key, c) => {
330
330
  players: {},
331
331
  participants: [],
332
332
  numbers: [],
333
- playerAnswer: ''
333
+ playerAnswer: '',
334
+ solved: false
334
335
  },
335
336
  passwordLock: {
336
337
  started: false,
@@ -342,7 +343,8 @@ const initState = (key, c) => {
342
343
  playerGuess: '',
343
344
  guessTimes: 0,
344
345
  maxGuessTimes: c.passwordLock.maxGuessTimes,
345
- hints: []
346
+ hints: [],
347
+ solved: false
346
348
  }
347
349
  };
348
350
  gameStates.set(key, s);
@@ -465,19 +467,19 @@ function apply(ctx, cfg) {
465
467
  autoStop: "游戏因长时间无人操作,已自动结束"
466
468
  },
467
469
  wzHero: {
468
- start: "王者英雄猜谜开始!本次共 {0} 回合~",
469
- startUsage: "用法错误!正确用法:王者英雄 开始 [难度] | 王者英雄 [答案] | 王者英雄 提示 | 王者英雄 结束",
470
- stop: "王者英雄猜谜比赛已停止",
471
- notStarted: "王者英雄猜谜比赛尚未开始,请输入 王者英雄 开始 [难度] 开始游戏",
470
+ start: "猜王者英雄开始!本次共 {0} 回合~",
471
+ startUsage: "用法错误!正确用法:猜王者英雄 开始 [难度] | 猜王者英雄 [答案] | 猜王者英雄 提示 | 猜王者英雄 结束",
472
+ stop: "猜王者英雄比赛已停止",
473
+ notStarted: "猜王者英雄比赛尚未开始,请输入 猜王者英雄 开始 [难度] 开始游戏",
472
474
  hint: "提示",
473
475
  apiError: "API请求失败,请稍后再试",
474
476
  correct: "答对啦!你获得1分~",
475
477
  wrong: "答错啦~正确答案是:{0},你不得分",
476
478
  roundEnd: "第 {0} 回合结束!剩余回合:{1}",
477
- gameEnd: "🎉 王者英雄猜谜比赛结束!🎉",
479
+ gameEnd: "🎉 猜王者英雄比赛结束!🎉",
478
480
  rankTitle: "🏆 排行榜 🏆",
479
481
  rankEmpty: "暂无参与记录~",
480
- disabled: "王者英雄猜谜功能已关闭,请联系管理员开启",
482
+ disabled: "猜王者英雄功能已关闭,请联系管理员开启",
481
483
  autoStop: "游戏因长时间无人操作,已自动结束"
482
484
  },
483
485
  chengyuImage: {
@@ -555,8 +557,9 @@ function apply(ctx, cfg) {
555
557
  notStarted: "算24点游戏尚未开始,请输入 算24点 开始 开始游戏",
556
558
  generate: "📝 第 {0} 题:用 {1} 通过加减乘除算出24!",
557
559
  correct: "答对啦!你获得1分~",
558
- wrong: "答错啦~这组数可以算出24哦!",
559
- impossible: "这组数无法算出24!本轮作废~",
560
+ wrong: "答错啦~",
561
+ impossible: "这组数无法算出24!本题作废,换一组数字~",
562
+ solved: "这组数已经被答对啦,换一组数字~",
560
563
  roundEnd: "第 {0} 回合结束!剩余回合:{1}",
561
564
  gameEnd: "🎉 算24点游戏结束!🎉",
562
565
  rankTitle: "🏆 排行榜 🏆",
@@ -565,18 +568,19 @@ function apply(ctx, cfg) {
565
568
  autoStop: "游戏因长时间无人操作,已自动结束"
566
569
  },
567
570
  passwordLock: {
568
- start: "密码锁破解游戏开始!密码为4位数字,你有 {0} 次猜测机会~",
569
- stop: "密码锁破解游戏已停止",
570
- notStarted: "密码锁破解游戏尚未开始,请输入 密码锁 开始 开始游戏",
571
+ start: "猜密码游戏开始!密码为4位数字,你有 {0} 次猜测机会~",
572
+ stop: "猜密码游戏已停止",
573
+ notStarted: "猜密码游戏尚未开始,请输入 猜密码 开始 开始游戏",
571
574
  guess: "你猜测的密码是:{0},这是第 {1} 次猜测",
572
575
  correct: "🎉 恭喜!你猜对了密码 {0}!总共猜测了 {1} 次,获得10分~",
573
576
  wrong: "密码错误!{0}",
577
+ solved: "密码已经被猜出来啦,游戏结束~",
574
578
  noChance: "❌ 没有猜测机会了!正确密码是:{0}~",
575
579
  invalidPassword: "无效的密码!请输入4位数字",
576
- gameEnd: "🎉 密码锁破解游戏结束!🎉",
580
+ gameEnd: "🎉 猜密码游戏结束!🎉",
577
581
  rankTitle: "🏆 排行榜 🏆",
578
582
  rankEmpty: "暂无参与记录~",
579
- disabled: "密码锁破解功能已关闭,请联系管理员开启",
583
+ disabled: "猜密码功能已关闭,请联系管理员开启",
580
584
  autoStop: "游戏因长时间无人操作,已自动结束"
581
585
  },
582
586
  common: {
@@ -879,6 +883,12 @@ function apply(ctx, cfg) {
879
883
  st.wzHero.players[playerKey] = getPlayerData(session);
880
884
  st.wzHero.participants.push(playerKey);
881
885
  }
886
+ if (content === '结束') {
887
+ clearGameData(st.wzHero);
888
+ await session.send(d.wzHero.stop);
889
+ gameStates.set(key, st);
890
+ return;
891
+ }
882
892
  try {
883
893
  const r = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
884
894
  params: { id: getIntUserId(session), msg: content }, timeout: cfg.apiConfig.timeout
@@ -941,6 +951,12 @@ function apply(ctx, cfg) {
941
951
  st.guessNumber.players[playerKey] = getPlayerData(session);
942
952
  st.guessNumber.participants.push(playerKey);
943
953
  }
954
+ if (content === '结束') {
955
+ clearGameData(st.guessNumber);
956
+ await session.send(d.guessNumber.stop);
957
+ gameStates.set(key, st);
958
+ return;
959
+ }
944
960
  const num = parseInt(content);
945
961
  if (isNaN(num)) {
946
962
  setupAutoStop(session, st.guessNumber, cfg, d.guessNumber.autoStop, cfg.guessNumber.showRank);
@@ -984,29 +1000,29 @@ function apply(ctx, cfg) {
984
1000
  st.dice.players[playerKey] = getPlayerData(session);
985
1001
  st.dice.participants.push(playerKey);
986
1002
  }
1003
+ if (content === '结束') {
1004
+ clearGameData(st.dice);
1005
+ await session.send(d.dice.stop);
1006
+ gameStates.set(key, st);
1007
+ return;
1008
+ }
987
1009
  if (content !== '掷骰子') {
988
1010
  setupAutoStop(session, st.dice, cfg, d.dice.autoStop, cfg.dice.showRank);
989
1011
  return next();
990
1012
  }
991
1013
  st.dice.playerDice = koishi_1.Random.int(1, 6);
992
- st.dice.botDice = cfg.dice.botParticipate ? koishi_1.Random.int(1, 6) : 0;
1014
+ st.dice.botDice = koishi_1.Random.int(1, 6);
993
1015
  let resultMsg = d.dice.roll.replace('{0}', st.dice.playerDice.toString()).replace('{1}', st.dice.botDice.toString());
994
- if (cfg.dice.botParticipate) {
995
- if (st.dice.playerDice > st.dice.botDice) {
996
- resultMsg += '\n' + d.dice.win;
997
- st.dice.players[playerKey].score += 1;
998
- st.dice.players[playerKey].correctCount += 1;
999
- }
1000
- else if (st.dice.playerDice < st.dice.botDice) {
1001
- resultMsg += '\n' + d.dice.lose;
1002
- }
1003
- else {
1004
- resultMsg += '\n' + d.dice.draw;
1005
- }
1016
+ if (st.dice.playerDice > st.dice.botDice) {
1017
+ resultMsg += '\n' + d.dice.win;
1018
+ st.dice.players[playerKey].score += 1;
1019
+ st.dice.players[playerKey].correctCount += 1;
1020
+ }
1021
+ else if (st.dice.playerDice < st.dice.botDice) {
1022
+ resultMsg += '\n' + d.dice.lose;
1006
1023
  }
1007
1024
  else {
1008
- resultMsg += '\n你掷出了 ' + st.dice.playerDice + ' 点!';
1009
- st.dice.players[playerKey].score += 1;
1025
+ resultMsg += '\n' + d.dice.draw;
1010
1026
  }
1011
1027
  await session.send(resultMsg);
1012
1028
  st.dice.currentRound += 1;
@@ -1033,32 +1049,32 @@ function apply(ctx, cfg) {
1033
1049
  st.rps.players[playerKey] = getPlayerData(session);
1034
1050
  st.rps.participants.push(playerKey);
1035
1051
  }
1052
+ if (content === '结束') {
1053
+ clearGameData(st.rps);
1054
+ await session.send(d.rps.stop);
1055
+ gameStates.set(key, st);
1056
+ return;
1057
+ }
1036
1058
  if (!st.rps.choices.includes(content)) {
1037
1059
  await session.send(d.rps.invalidChoice);
1038
1060
  setupAutoStop(session, st.rps, cfg, d.rps.autoStop, cfg.rps.showRank);
1039
- return next();
1061
+ return;
1040
1062
  }
1041
1063
  st.rps.playerChoice = content;
1042
- st.rps.botChoice = cfg.rps.botParticipate ? st.rps.choices[koishi_1.Random.int(0, 2)] : '';
1064
+ st.rps.botChoice = st.rps.choices[koishi_1.Random.int(0, 2)];
1043
1065
  let resultMsg = d.rps.choice.replace('{0}', st.rps.playerChoice).replace('{1}', st.rps.botChoice);
1044
- if (cfg.rps.botParticipate) {
1045
- if ((st.rps.playerChoice === '石头' && st.rps.botChoice === '剪刀') ||
1046
- (st.rps.playerChoice === '剪刀' && st.rps.botChoice === '') ||
1047
- (st.rps.playerChoice === '' && st.rps.botChoice === '石头')) {
1048
- resultMsg += '\n' + d.rps.win;
1049
- st.rps.players[playerKey].score += 1;
1050
- st.rps.players[playerKey].correctCount += 1;
1051
- }
1052
- else if (st.rps.playerChoice === st.rps.botChoice) {
1053
- resultMsg += '\n' + d.rps.draw;
1054
- }
1055
- else {
1056
- resultMsg += '\n' + d.rps.lose;
1057
- }
1066
+ if ((st.rps.playerChoice === '石头' && st.rps.botChoice === '剪刀') ||
1067
+ (st.rps.playerChoice === '剪刀' && st.rps.botChoice === '') ||
1068
+ (st.rps.playerChoice === '' && st.rps.botChoice === '石头')) {
1069
+ resultMsg += '\n' + d.rps.win;
1070
+ st.rps.players[playerKey].score += 1;
1071
+ st.rps.players[playerKey].correctCount += 1;
1072
+ }
1073
+ else if (st.rps.playerChoice === st.rps.botChoice) {
1074
+ resultMsg += '\n' + d.rps.draw;
1058
1075
  }
1059
1076
  else {
1060
- resultMsg += '\n你选择了 ' + st.rps.playerChoice + '!';
1061
- st.rps.players[playerKey].score += 1;
1077
+ resultMsg += '\n' + d.rps.lose;
1062
1078
  }
1063
1079
  await session.send(resultMsg);
1064
1080
  st.rps.currentRound += 1;
@@ -1085,19 +1101,44 @@ function apply(ctx, cfg) {
1085
1101
  st.calc24.players[playerKey] = getPlayerData(session);
1086
1102
  st.calc24.participants.push(playerKey);
1087
1103
  }
1104
+ if (content === '结束') {
1105
+ clearGameData(st.calc24);
1106
+ await session.send(d.calc24.stop);
1107
+ gameStates.set(key, st);
1108
+ return;
1109
+ }
1088
1110
  if (content === '换题') {
1089
- st.calc24.numbers = [];
1090
- for (let i = 0; i < 4; i++) {
1091
- st.calc24.numbers.push(koishi_1.Random.int(cfg.calc24.numberRange[0], cfg.calc24.numberRange[1]));
1111
+ if (!st.calc24.solved) {
1112
+ st.calc24.numbers = [];
1113
+ for (let i = 0; i < 4; i++) {
1114
+ st.calc24.numbers.push(koishi_1.Random.int(cfg.calc24.numberRange[0], cfg.calc24.numberRange[1]));
1115
+ }
1116
+ st.calc24.solved = false;
1117
+ const canCalculate = calculate24([...st.calc24.numbers]);
1118
+ if (!canCalculate) {
1119
+ await session.send(d.calc24.impossible);
1120
+ }
1121
+ else {
1122
+ await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1123
+ }
1092
1124
  }
1093
- await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1094
1125
  setupAutoStop(session, st.calc24, cfg, d.calc24.autoStop, cfg.calc24.showRank);
1095
- return next();
1126
+ return;
1127
+ }
1128
+ if (st.calc24.solved) {
1129
+ await session.send(d.calc24.solved);
1130
+ setupAutoStop(session, st.calc24, cfg, d.calc24.autoStop, cfg.calc24.showRank);
1131
+ return;
1096
1132
  }
1097
1133
  st.calc24.playerAnswer = content;
1098
1134
  const canCalculate = calculate24([...st.calc24.numbers]);
1099
1135
  if (!canCalculate) {
1100
1136
  await session.send(d.calc24.impossible);
1137
+ st.calc24.numbers = [];
1138
+ for (let i = 0; i < 4; i++) {
1139
+ st.calc24.numbers.push(koishi_1.Random.int(cfg.calc24.numberRange[0], cfg.calc24.numberRange[1]));
1140
+ }
1141
+ await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1101
1142
  }
1102
1143
  else {
1103
1144
  try {
@@ -1106,6 +1147,33 @@ function apply(ctx, cfg) {
1106
1147
  await session.send(d.calc24.correct);
1107
1148
  st.calc24.players[playerKey].score += 1;
1108
1149
  st.calc24.players[playerKey].correctCount += 1;
1150
+ st.calc24.solved = true;
1151
+ st.calc24.currentRound += 1;
1152
+ if (st.calc24.currentRound > st.calc24.totalRounds) {
1153
+ st.calc24.started = false;
1154
+ clearGameTimer(st.calc24);
1155
+ await session.send(d.calc24.gameEnd);
1156
+ if (cfg.calc24.showRank && !isPrivate(session)) {
1157
+ const rankText = generateRankText(st.calc24.players);
1158
+ await session.send(rankText);
1159
+ }
1160
+ clearGameData(st.calc24);
1161
+ }
1162
+ else {
1163
+ await session.send(d.calc24.roundEnd.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', (st.calc24.totalRounds - st.calc24.currentRound).toString()));
1164
+ st.calc24.numbers = [];
1165
+ for (let i = 0; i < 4; i++) {
1166
+ st.calc24.numbers.push(koishi_1.Random.int(cfg.calc24.numberRange[0], cfg.calc24.numberRange[1]));
1167
+ }
1168
+ st.calc24.solved = false;
1169
+ const nextCanCalculate = calculate24([...st.calc24.numbers]);
1170
+ if (!nextCanCalculate) {
1171
+ await session.send(d.calc24.impossible);
1172
+ }
1173
+ else {
1174
+ await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1175
+ }
1176
+ }
1109
1177
  }
1110
1178
  else {
1111
1179
  await session.send(d.calc24.wrong);
@@ -1115,25 +1183,6 @@ function apply(ctx, cfg) {
1115
1183
  await session.send(d.calc24.wrong);
1116
1184
  }
1117
1185
  }
1118
- st.calc24.currentRound += 1;
1119
- if (st.calc24.currentRound > st.calc24.totalRounds) {
1120
- st.calc24.started = false;
1121
- clearGameTimer(st.calc24);
1122
- await session.send(d.calc24.gameEnd);
1123
- if (cfg.calc24.showRank && !isPrivate(session)) {
1124
- const rankText = generateRankText(st.calc24.players);
1125
- await session.send(rankText);
1126
- }
1127
- clearGameData(st.calc24);
1128
- }
1129
- else {
1130
- st.calc24.numbers = [];
1131
- for (let i = 0; i < 4; i++) {
1132
- st.calc24.numbers.push(koishi_1.Random.int(cfg.calc24.numberRange[0], cfg.calc24.numberRange[1]));
1133
- }
1134
- await session.send(d.calc24.roundEnd.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', (st.calc24.totalRounds - st.calc24.currentRound).toString()));
1135
- await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1136
- }
1137
1186
  setupAutoStop(session, st.calc24, cfg, d.calc24.autoStop, cfg.calc24.showRank);
1138
1187
  gameStates.set(key, st);
1139
1188
  return;
@@ -1144,10 +1193,21 @@ function apply(ctx, cfg) {
1144
1193
  st.passwordLock.players[playerKey] = getPlayerData(session);
1145
1194
  st.passwordLock.participants.push(playerKey);
1146
1195
  }
1196
+ if (content === '结束') {
1197
+ clearGameData(st.passwordLock);
1198
+ await session.send(d.passwordLock.stop);
1199
+ gameStates.set(key, st);
1200
+ return;
1201
+ }
1202
+ if (st.passwordLock.solved) {
1203
+ await session.send(d.passwordLock.solved);
1204
+ setupAutoStop(session, st.passwordLock, cfg, d.passwordLock.autoStop, cfg.passwordLock.showRank);
1205
+ return;
1206
+ }
1147
1207
  if (!/^\d{4}$/.test(content)) {
1148
1208
  await session.send(d.passwordLock.invalidPassword);
1149
1209
  setupAutoStop(session, st.passwordLock, cfg, d.passwordLock.autoStop, cfg.passwordLock.showRank);
1150
- return next();
1210
+ return;
1151
1211
  }
1152
1212
  st.passwordLock.playerGuess = content;
1153
1213
  st.passwordLock.guessTimes += 1;
@@ -1156,6 +1216,7 @@ function apply(ctx, cfg) {
1156
1216
  await session.send(d.passwordLock.correct.replace('{0}', content).replace('{1}', st.passwordLock.guessTimes.toString()));
1157
1217
  st.passwordLock.players[playerKey].score += 10 - (st.passwordLock.guessTimes - 1);
1158
1218
  st.passwordLock.players[playerKey].correctCount += 1;
1219
+ st.passwordLock.solved = true;
1159
1220
  st.passwordLock.started = false;
1160
1221
  clearGameTimer(st.passwordLock);
1161
1222
  await session.send(d.passwordLock.gameEnd);
@@ -1199,7 +1260,7 @@ function apply(ctx, cfg) {
1199
1260
  return;
1200
1261
  const key = getSessionKey(session);
1201
1262
  const st = gameStates.get(key) || initState(key, cfg);
1202
- if (checkGameRunning(st)) {
1263
+ if (checkGameRunning(st, 'guessNumber')) {
1203
1264
  await session.send(d.common.gameRunning);
1204
1265
  return;
1205
1266
  }
@@ -1223,14 +1284,14 @@ function apply(ctx, cfg) {
1223
1284
  await session.send(d.guessNumber.usage);
1224
1285
  }
1225
1286
  });
1226
- ctx.command('王者英雄 <action> [param]', '王者英雄猜谜')
1287
+ ctx.command('猜王者英雄 <action> [param]', '猜王者英雄猜谜')
1227
1288
  .action(async (argv, action, param) => {
1228
1289
  const session = argv.session;
1229
1290
  if (!session)
1230
1291
  return;
1231
1292
  const key = getSessionKey(session);
1232
1293
  const st = gameStates.get(key) || initState(key, cfg);
1233
- if (checkGameRunning(st)) {
1294
+ if (checkGameRunning(st, 'wzHero')) {
1234
1295
  await session.send(d.common.gameRunning);
1235
1296
  return;
1236
1297
  }
@@ -1272,7 +1333,7 @@ function apply(ctx, cfg) {
1272
1333
  return;
1273
1334
  const key = getSessionKey(session);
1274
1335
  const st = gameStates.get(key) || initState(key, cfg);
1275
- if (checkGameRunning(st)) {
1336
+ if (checkGameRunning(st, 'chengyuImage')) {
1276
1337
  await session.send(d.common.gameRunning);
1277
1338
  return;
1278
1339
  }
@@ -1320,7 +1381,7 @@ function apply(ctx, cfg) {
1320
1381
  return;
1321
1382
  const key = getSessionKey(session);
1322
1383
  const st = gameStates.get(key) || initState(key, cfg);
1323
- if (checkGameRunning(st)) {
1384
+ if (checkGameRunning(st, 'chengyuJielong')) {
1324
1385
  await session.send(d.common.gameRunning);
1325
1386
  return;
1326
1387
  }
@@ -1350,7 +1411,7 @@ function apply(ctx, cfg) {
1350
1411
  return;
1351
1412
  const key = getSessionKey(session);
1352
1413
  const st = gameStates.get(key) || initState(key, cfg);
1353
- if (checkGameRunning(st)) {
1414
+ if (checkGameRunning(st, 'dice')) {
1354
1415
  await session.send(d.common.gameRunning);
1355
1416
  return;
1356
1417
  }
@@ -1366,6 +1427,9 @@ function apply(ctx, cfg) {
1366
1427
  await session.send(d.dice.stop);
1367
1428
  gameStates.set(key, st);
1368
1429
  }
1430
+ else {
1431
+ await session.send('请输入:掷骰子 开始 或 掷骰子 结束');
1432
+ }
1369
1433
  });
1370
1434
  ctx.command('石头剪刀布 <action>', '石头剪刀布')
1371
1435
  .action(async (argv, action) => {
@@ -1374,7 +1438,7 @@ function apply(ctx, cfg) {
1374
1438
  return;
1375
1439
  const key = getSessionKey(session);
1376
1440
  const st = gameStates.get(key) || initState(key, cfg);
1377
- if (checkGameRunning(st)) {
1441
+ if (checkGameRunning(st, 'rps')) {
1378
1442
  await session.send(d.common.gameRunning);
1379
1443
  return;
1380
1444
  }
@@ -1390,6 +1454,9 @@ function apply(ctx, cfg) {
1390
1454
  await session.send(d.rps.stop);
1391
1455
  gameStates.set(key, st);
1392
1456
  }
1457
+ else {
1458
+ await session.send('请输入:石头剪刀布 开始 或 石头剪刀布 结束');
1459
+ }
1393
1460
  });
1394
1461
  ctx.command('算24点 <action>', '算24点游戏')
1395
1462
  .action(async (argv, action) => {
@@ -1398,19 +1465,26 @@ function apply(ctx, cfg) {
1398
1465
  return;
1399
1466
  const key = getSessionKey(session);
1400
1467
  const st = gameStates.get(key) || initState(key, cfg);
1401
- if (checkGameRunning(st)) {
1468
+ if (checkGameRunning(st, 'calc24')) {
1402
1469
  await session.send(d.common.gameRunning);
1403
1470
  return;
1404
1471
  }
1405
1472
  if (action === '开始') {
1406
1473
  st.calc24.started = true;
1407
1474
  st.calc24.currentRound = 1;
1475
+ st.calc24.solved = false;
1408
1476
  st.calc24.numbers = [];
1409
1477
  for (let i = 0; i < 4; i++) {
1410
1478
  st.calc24.numbers.push(koishi_1.Random.int(cfg.calc24.numberRange[0], cfg.calc24.numberRange[1]));
1411
1479
  }
1412
1480
  await session.send(d.calc24.start.replace('{0}', st.calc24.totalRounds.toString()));
1413
- await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1481
+ const canCalculate = calculate24([...st.calc24.numbers]);
1482
+ if (!canCalculate) {
1483
+ await session.send(d.calc24.impossible);
1484
+ }
1485
+ else {
1486
+ await session.send(d.calc24.generate.replace('{0}', st.calc24.currentRound.toString()).replace('{1}', st.calc24.numbers.join('、')));
1487
+ }
1414
1488
  gameStates.set(key, st);
1415
1489
  setupAutoStop(session, st.calc24, cfg, d.calc24.autoStop, cfg.calc24.showRank);
1416
1490
  }
@@ -1419,15 +1493,18 @@ function apply(ctx, cfg) {
1419
1493
  await session.send(d.calc24.stop);
1420
1494
  gameStates.set(key, st);
1421
1495
  }
1496
+ else {
1497
+ await session.send('请输入:算24点 开始 或 算24点 结束');
1498
+ }
1422
1499
  });
1423
- ctx.command('密码锁 <action>', '密码锁破解')
1500
+ ctx.command('猜密码 <action>', '猜密码游戏')
1424
1501
  .action(async (argv, action) => {
1425
1502
  const session = argv.session;
1426
1503
  if (!session)
1427
1504
  return;
1428
1505
  const key = getSessionKey(session);
1429
1506
  const st = gameStates.get(key) || initState(key, cfg);
1430
- if (checkGameRunning(st)) {
1507
+ if (checkGameRunning(st, 'passwordLock')) {
1431
1508
  await session.send(d.common.gameRunning);
1432
1509
  return;
1433
1510
  }
@@ -1435,6 +1512,7 @@ function apply(ctx, cfg) {
1435
1512
  st.passwordLock.started = true;
1436
1513
  st.passwordLock.currentRound = 1;
1437
1514
  st.passwordLock.guessTimes = 0;
1515
+ st.passwordLock.solved = false;
1438
1516
  st.passwordLock.password = koishi_1.Random.int(1000, 9999).toString();
1439
1517
  await session.send(d.passwordLock.start.replace('{0}', st.passwordLock.maxGuessTimes.toString()));
1440
1518
  gameStates.set(key, st);
@@ -1445,5 +1523,8 @@ function apply(ctx, cfg) {
1445
1523
  await session.send(d.passwordLock.stop);
1446
1524
  gameStates.set(key, st);
1447
1525
  }
1526
+ else {
1527
+ await session.send('请输入:猜密码 开始 或 猜密码 结束');
1528
+ }
1448
1529
  });
1449
1530
  }
@@ -14,19 +14,19 @@ guessNumber:
14
14
  autoStop: "游戏因长时间无人操作,已自动结束"
15
15
 
16
16
  wzHero:
17
- start: "王者英雄猜谜开始!本次共 {0} 回合~"
18
- startUsage: "用法错误!正确用法:王者英雄 开始 [难度] | 王者英雄 [答案] | 王者英雄 提示 | 王者英雄 结束"
19
- stop: "王者英雄猜谜比赛已停止"
20
- notStarted: "王者英雄猜谜比赛尚未开始,请输入 王者英雄 开始 [难度] 开始游戏"
17
+ start: "猜王者英雄开始!本次共 {0} 回合~"
18
+ startUsage: "用法错误!正确用法:猜王者英雄 开始 [难度] | 猜王者英雄 [答案] | 猜王者英雄 提示 | 猜王者英雄 结束"
19
+ stop: "猜王者英雄比赛已停止"
20
+ notStarted: "猜王者英雄比赛尚未开始,请输入 猜王者英雄 开始 [难度] 开始游戏"
21
21
  hint: "提示"
22
22
  apiError: "API请求失败,请稍后再试"
23
23
  correct: "答对啦!你获得1分~"
24
24
  wrong: "答错啦~正确答案是:{0},你不得分"
25
25
  roundEnd: "第 {0} 回合结束!剩余回合:{1}"
26
- gameEnd: "🎉 王者英雄猜谜比赛结束!🎉"
26
+ gameEnd: "🎉 猜王者英雄比赛结束!🎉"
27
27
  rankTitle: "🏆 排行榜 🏆"
28
28
  rankEmpty: "暂无参与记录~"
29
- disabled: "王者英雄猜谜功能已关闭,请联系管理员开启"
29
+ disabled: "猜王者英雄功能已关闭,请联系管理员开启"
30
30
  autoStop: "游戏因长时间无人操作,已自动结束"
31
31
 
32
32
  chengyuImage:
@@ -104,8 +104,9 @@ calc24:
104
104
  notStarted: "算24点游戏尚未开始,请输入 算24点 开始 开始游戏"
105
105
  generate: "📝 第 {0} 题:用 {1} 通过加减乘除算出24!"
106
106
  correct: "答对啦!你获得1分~"
107
- wrong: "答错啦~这组数可以算出24哦!"
108
- impossible: "这组数无法算出24!本轮作废~"
107
+ wrong: "答错啦~"
108
+ impossible: "这组数无法算出24!本题作废,换一组数字~"
109
+ solved: "这组数已经被答对啦,换一组数字~"
109
110
  roundEnd: "第 {0} 回合结束!剩余回合:{1}"
110
111
  gameEnd: "🎉 算24点游戏结束!🎉"
111
112
  rankTitle: "🏆 排行榜 🏆"
@@ -114,18 +115,19 @@ calc24:
114
115
  autoStop: "游戏因长时间无人操作,已自动结束"
115
116
 
116
117
  passwordLock:
117
- start: "密码锁破解游戏开始!密码为4位数字,你有 {0} 次猜测机会~"
118
- stop: "密码锁破解游戏已停止"
119
- notStarted: "密码锁破解游戏尚未开始,请输入 密码锁 开始 开始游戏"
118
+ start: "猜密码游戏开始!密码为4位数字,你有 {0} 次猜测机会~"
119
+ stop: "猜密码游戏已停止"
120
+ notStarted: "猜密码游戏尚未开始,请输入 猜密码 开始 开始游戏"
120
121
  guess: "你猜测的密码是:{0},这是第 {1} 次猜测"
121
122
  correct: "🎉 恭喜!你猜对了密码 {0}!总共猜测了 {1} 次,获得10分~"
122
123
  wrong: "密码错误!{0}"
124
+ solved: "密码已经被猜出来啦,游戏结束~"
123
125
  noChance: "❌ 没有猜测机会了!正确密码是:{0}~"
124
126
  invalidPassword: "无效的密码!请输入4位数字"
125
- gameEnd: "🎉 密码锁破解游戏结束!🎉"
127
+ gameEnd: "🎉 猜密码游戏结束!🎉"
126
128
  rankTitle: "🏆 排行榜 🏆"
127
129
  rankEmpty: "暂无参与记录~"
128
- disabled: "密码锁破解功能已关闭,请联系管理员开启"
130
+ disabled: "猜密码功能已关闭,请联系管理员开启"
129
131
  autoStop: "游戏因长时间无人操作,已自动结束"
130
132
 
131
133
  common:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-game-mini",
3
- "version": "0.2.3",
4
- "description": "一款包含猜数字、猜王者英雄、看图猜成语、成语接龙的多功能小游戏插件",
3
+ "version": "0.2.4",
4
+ "description": "多功能小游戏合集:猜数字、猜王者英雄、看图猜成语、成语接龙、掷骰子、石头剪刀布、算24点、猜密码",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -12,12 +12,21 @@
12
12
  },
13
13
  "keywords": [
14
14
  "koishi",
15
- "plugin",
15
+ "koishi-plugin",
16
16
  "game",
17
+ "mini-game",
17
18
  "猜数字",
19
+ "猜王者英雄",
18
20
  "王者荣耀",
19
- "猜成语",
20
- "成语接龙"
21
+ "看图猜成语",
22
+ "成语接龙",
23
+ "掷骰子",
24
+ "石头剪刀布",
25
+ "算24点",
26
+ "24点",
27
+ "猜密码",
28
+ "密码锁",
29
+ "小游戏"
21
30
  ],
22
31
  "author": "Minecraft-1314",
23
32
  "license": "MIT",