koishi-plugin-game-mini 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -707,7 +707,7 @@ async function apply(ctx, cfg) {
707
707
  id: userId,
708
708
  };
709
709
  if (st.chengyuJielong.jielongCount === 0) {
710
- params.msg = '开始游戏';
710
+ params.msg = '开始成语接龙';
711
711
  }
712
712
  else {
713
713
  params.msg = '我接';
@@ -862,6 +862,7 @@ async function apply(ctx, cfg) {
862
862
  }
863
863
  if (content === '提示') {
864
864
  try {
865
+ logDebug(`[看图猜成语] 开始调用获取提示API,题目ID: ${st.chengyuImage.currentId}, 提示级别: ${cfg.chengyuImage.defaultHintLevel}`);
865
866
  const r = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
866
867
  params: {
867
868
  action: 'get_hint',
@@ -870,15 +871,21 @@ async function apply(ctx, cfg) {
870
871
  },
871
872
  timeout: cfg.apiConfig.timeout
872
873
  });
874
+ logDebug(`[看图猜成语] 获取提示API返回状态码: ${r.status}`);
875
+ logDebug(`[看图猜成语] 获取提示API返回数据:`, r.data);
873
876
  const dt = r.data;
874
877
  if (dt.success) {
878
+ logDebug(`[看图猜成语] 成功获取提示: ${dt.data.hint}`);
875
879
  await session.send(d.chengyuImage.hintGet.replace('{0}', dt.data.hint));
876
880
  }
877
881
  else {
882
+ logWarn(`[看图猜成语] 获取提示失败: ${dt.message}`);
878
883
  await session.send(d.chengyuImage.hintError);
879
884
  }
880
885
  }
881
886
  catch (error) {
887
+ const err = error;
888
+ logError(`[看图猜成语] 获取提示API调用失败: ${err.message}`, err);
882
889
  await session.send(d.chengyuImage.hintError);
883
890
  }
884
891
  setupAutoStop(session, st.chengyuImage, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
@@ -890,6 +897,7 @@ async function apply(ctx, cfg) {
890
897
  return;
891
898
  }
892
899
  try {
900
+ logDebug(`[看图猜成语] 开始调用提交答案API,题目ID: ${st.chengyuImage.currentId}, 答案: ${content}`);
893
901
  const r = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
894
902
  params: {
895
903
  action: 'submit_answer',
@@ -898,6 +906,8 @@ async function apply(ctx, cfg) {
898
906
  },
899
907
  timeout: cfg.apiConfig.timeout
900
908
  });
909
+ logDebug(`[看图猜成语] 提交答案API返回状态码: ${r.status}`);
910
+ logDebug(`[看图猜成语] 提交答案API返回数据:`, r.data);
901
911
  const dt = r.data;
902
912
  if (dt.success) {
903
913
  let reply = '';
@@ -906,6 +916,7 @@ async function apply(ctx, cfg) {
906
916
  st.chengyuImage.players[playerKey].correctCount += 1;
907
917
  await savePlayerData(session, st.chengyuImage.players[playerKey]);
908
918
  reply = d.chengyuImage.correct.replace('{0}', st.chengyuImage.players[playerKey].score.toString());
919
+ logDebug(`[看图猜成语] 回答正确,当前得分: ${st.chengyuImage.players[playerKey].score}`);
909
920
  st.chengyuImage.currentRound += 1;
910
921
  if (st.chengyuImage.currentRound > st.chengyuImage.totalRounds) {
911
922
  st.chengyuImage.started = false;
@@ -921,6 +932,7 @@ async function apply(ctx, cfg) {
921
932
  else {
922
933
  await session.send(reply);
923
934
  await session.send(d.chengyuImage.roundEnd.replace('{0}', st.chengyuImage.currentRound.toString()).replace('{1}', (st.chengyuImage.totalRounds - st.chengyuImage.currentRound).toString()));
935
+ logDebug(`[看图猜成语] 开始调用下一题API,页码: ${st.chengyuImage.currentPage + 1}`);
924
936
  const nextR = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
925
937
  params: {
926
938
  action: 'next_question',
@@ -928,17 +940,21 @@ async function apply(ctx, cfg) {
928
940
  },
929
941
  timeout: cfg.apiConfig.timeout
930
942
  });
943
+ logDebug(`[看图猜成语] 下一题API返回状态码: ${nextR.status}`);
944
+ logDebug(`[看图猜成语] 下一题API返回数据:`, nextR.data);
931
945
  const nextDt = nextR.data;
932
946
  if (nextDt.success) {
933
947
  st.chengyuImage.currentId = nextDt.data.question.id;
934
948
  st.chengyuImage.currentPage = nextDt.data.question.page;
935
949
  st.chengyuImage.options = nextDt.data.question.options;
936
950
  st.chengyuImage.answer = nextDt.data.question.answer || '';
951
+ logDebug(`[看图猜成语] 获取到新题目,ID: ${st.chengyuImage.currentId}, 答案: ${st.chengyuImage.answer}`);
937
952
  await session.send(d.chengyuImage.next.replace('{0}', st.chengyuImage.currentRound.toString()));
938
953
  await session.send(`请从选项中选择4个字组成成语\n选项:${nextDt.data.question.options.join('、')}`);
939
954
  await session.send(koishi_1.segment.image(nextDt.data.question.image_url));
940
955
  }
941
956
  else {
957
+ logWarn(`[看图猜成语] 获取下一题失败: ${nextDt.message}`);
942
958
  await session.send('获取下一题失败,比赛结束!');
943
959
  st.chengyuImage.started = false;
944
960
  clearGameTimer(st.chengyuImage);
@@ -953,14 +969,18 @@ async function apply(ctx, cfg) {
953
969
  else {
954
970
  const correctAnswer = dt.data?.correct_answer || st.chengyuImage.answer;
955
971
  reply = d.chengyuImage.wrong.replace('{0}', correctAnswer).replace('{1}', st.chengyuImage.players[playerKey].score.toString());
972
+ logDebug(`[看图猜成语] 回答错误,正确答案: ${correctAnswer}`);
956
973
  await session.send(reply);
957
974
  }
958
975
  }
959
976
  else {
977
+ logWarn(`[看图猜成语] 提交答案失败: ${dt.message}`);
960
978
  await session.send('提交答案失败,请稍后再试');
961
979
  }
962
980
  }
963
981
  catch (error) {
982
+ const err = error;
983
+ logError(`[看图猜成语] 提交答案API调用失败: ${err.message}`, err);
964
984
  await session.send(d.chengyuImage.apiError);
965
985
  }
966
986
  setupAutoStop(session, st.chengyuImage, 'chengyuImage', d.chengyuImage.autoStop, cfg.chengyuImage.showRank, d.chengyuImage.rankTitle, d.chengyuImage.rankEmpty);
@@ -982,9 +1002,12 @@ async function apply(ctx, cfg) {
982
1002
  return;
983
1003
  }
984
1004
  try {
1005
+ logDebug(`[王者英雄] 开始调用API,用户ID: ${getUserId(session)}, 内容: ${content}`);
985
1006
  const r = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
986
1007
  params: { id: getUserId(session), msg: content }, timeout: cfg.apiConfig.timeout
987
1008
  });
1009
+ logDebug(`[王者英雄] API返回状态码: ${r.status}`);
1010
+ logDebug(`[王者英雄] API返回数据:`, r.data);
988
1011
  const dt = r.data;
989
1012
  if (dt.status === 'success') {
990
1013
  let text = `${dt.message || ''}\n${dt.hint || ''}\n剩余提示次数:${dt.remaining_hints}\n${dt.guide || ''}`;
@@ -994,6 +1017,7 @@ async function apply(ctx, cfg) {
994
1017
  st.wzHero.players[playerKey].correctCount += 1;
995
1018
  await savePlayerData(session, st.wzHero.players[playerKey]);
996
1019
  text += '\n' + d.wzHero.correct.replace('{0}', st.wzHero.players[playerKey].score.toString());
1020
+ logDebug(`[王者英雄] 回答正确,当前得分: ${st.wzHero.players[playerKey].score}`);
997
1021
  st.wzHero.currentRound += 1;
998
1022
  if (st.wzHero.currentRound > st.wzHero.totalRounds) {
999
1023
  st.wzHero.started = false;
@@ -1010,28 +1034,36 @@ async function apply(ctx, cfg) {
1010
1034
  }
1011
1035
  else {
1012
1036
  text += '\n' + d.wzHero.roundEnd.replace('{0}', st.wzHero.currentRound.toString()).replace('{1}', (st.wzHero.totalRounds - st.wzHero.currentRound).toString());
1037
+ logDebug(`[王者英雄] 开始调用下一题API`);
1013
1038
  const nextR = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
1014
1039
  params: { id: getUserId(session), msg: `开始游戏${st.wzHero.difficulty}` }, timeout: cfg.apiConfig.timeout
1015
1040
  });
1041
+ logDebug(`[王者英雄] 下一题API返回状态码: ${nextR.status}`);
1042
+ logDebug(`[王者英雄] 下一题API返回数据:`, nextR.data);
1016
1043
  const nextDt = nextR.data;
1017
1044
  if (nextDt.status === 'success') {
1018
1045
  let nextText = `${nextDt.message || ''}\n${nextDt.hint || ''}\n剩余提示次数:${nextDt.remaining_hints}\n${nextDt.guide || ''}`;
1019
1046
  nextText = nextText.replace(/\\n/g, '\n');
1020
1047
  text += '\n' + nextText;
1021
1048
  st.wzHero.currentAnswer = nextDt.hint || '';
1049
+ logDebug(`[王者英雄] 获取到新题目,答案提示: ${st.wzHero.currentAnswer}`);
1022
1050
  }
1023
1051
  }
1024
1052
  }
1025
1053
  else if (content !== '提示' && dt.message.includes('错误')) {
1026
1054
  text += '\n' + d.wzHero.wrong.replace('{0}', st.wzHero.currentAnswer).replace('{1}', st.wzHero.players[playerKey].score.toString());
1055
+ logDebug(`[王者英雄] 回答错误,正确答案: ${st.wzHero.currentAnswer}`);
1027
1056
  }
1028
1057
  await session.send(text);
1029
1058
  }
1030
1059
  else {
1060
+ logWarn(`[王者英雄] API返回异常:`, dt);
1031
1061
  await session.send((dt.message || '出错').replace(/\\n/g, '\n'));
1032
1062
  }
1033
1063
  }
1034
1064
  catch (error) {
1065
+ const err = error;
1066
+ logError(`[王者英雄] API调用失败: ${err.message}`, err);
1035
1067
  await session.send(d.wzHero.apiError);
1036
1068
  }
1037
1069
  setupAutoStop(session, st.wzHero, 'wzHero', d.wzHero.autoStop, cfg.wzHero.showRank, d.wzHero.rankTitle, d.wzHero.rankEmpty);
@@ -1230,18 +1262,24 @@ async function apply(ctx, cfg) {
1230
1262
  st.wzHero.difficulty = cfg.wzHero.defaultDifficulty;
1231
1263
  st.wzHero.currentRound = 1;
1232
1264
  try {
1265
+ logDebug(`[王者英雄] 开始游戏,难度: ${st.wzHero.difficulty}`);
1233
1266
  const r = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
1234
1267
  params: { id: getUserId(session), msg: `开始游戏${st.wzHero.difficulty}` },
1235
1268
  timeout: cfg.apiConfig.timeout
1236
1269
  });
1270
+ logDebug(`[王者英雄] 开始游戏API返回状态码: ${r.status}`);
1271
+ logDebug(`[王者英雄] 开始游戏API返回数据:`, r.data);
1237
1272
  const dt = r.data;
1238
1273
  let text = `${dt.message || ''}\n${dt.hint || ''}\n剩余提示次数:${dt.remaining_hints}\n${dt.guide || ''}`;
1239
1274
  text = text.replace(/\\n/g, '\n');
1240
1275
  await session.send(d.wzHero.start.replace('{0}', st.wzHero.totalRounds.toString()).replace('{1}', st.wzHero.difficulty));
1241
1276
  await session.send(text);
1242
1277
  st.wzHero.currentAnswer = dt.hint || '';
1278
+ logDebug(`[王者英雄] 获取到题目,答案提示: ${st.wzHero.currentAnswer}`);
1243
1279
  }
1244
1280
  catch (e) {
1281
+ const err = e;
1282
+ logError(`[王者英雄] 开始游戏API调用失败: ${err.message}`, err);
1245
1283
  await session.send(d.wzHero.apiError);
1246
1284
  }
1247
1285
  gameStates.set(key, st);
@@ -1275,25 +1313,32 @@ async function apply(ctx, cfg) {
1275
1313
  st.chengyuImage.started = true;
1276
1314
  st.chengyuImage.currentRound = 1;
1277
1315
  try {
1316
+ logDebug(`[看图猜成语] 开始游戏,获取第一题`);
1278
1317
  const r = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
1279
1318
  params: { action: 'next_question', page: 1 },
1280
1319
  timeout: cfg.apiConfig.timeout
1281
1320
  });
1321
+ logDebug(`[看图猜成语] 获取题目API返回状态码: ${r.status}`);
1322
+ logDebug(`[看图猜成语] 获取题目API返回数据:`, r.data);
1282
1323
  const dt = r.data;
1283
1324
  if (dt.success) {
1284
1325
  st.chengyuImage.currentId = dt.data.question.id;
1285
1326
  st.chengyuImage.currentPage = dt.data.question.page;
1286
1327
  st.chengyuImage.options = dt.data.question.options;
1287
1328
  st.chengyuImage.answer = dt.data.question.answer || '';
1329
+ logDebug(`[看图猜成语] 获取到题目,ID: ${st.chengyuImage.currentId}, 答案: ${st.chengyuImage.answer}`);
1288
1330
  await session.send(d.chengyuImage.start.replace('{0}', st.chengyuImage.totalRounds.toString()).replace('{1}', cfg.chengyuImage.defaultHintLevel.toString()));
1289
1331
  await session.send(`请从选项中选择4个字组成成语\n选项:${dt.data.question.options.join('、')}`);
1290
1332
  await session.send(koishi_1.segment.image(dt.data.question.image_url));
1291
1333
  }
1292
1334
  else {
1335
+ logWarn(`[看图猜成语] 获取题目失败: ${dt.message}`);
1293
1336
  await session.send(d.chengyuImage.apiError);
1294
1337
  }
1295
1338
  }
1296
1339
  catch (e) {
1340
+ const err = e;
1341
+ logError(`[看图猜成语] 获取题目API调用失败: ${err.message}`, err);
1297
1342
  await session.send(d.chengyuImage.apiError);
1298
1343
  }
1299
1344
  gameStates.set(key, st);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-game-mini",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Koishi多功能小游戏合集:猜数字、猜王者英雄、看图猜成语、成语接龙、算24点",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
package/readme.md CHANGED
@@ -114,7 +114,7 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
114
114
  | `chengyuImage.rewardScore` | 答对奖励分数 | 1 |
115
115
  | **🐉 成语接龙配置** | | |
116
116
  | `chengyuJielong.totalRounds` | 总回合数 | 10 |
117
- | `chengyuJielong.showRank` | 游戏结束后显示本局排行榜 | true |
117
+ | `chengyuJielong.showRank` | 游戏结束后显示本局排行榜 | false |
118
118
  | `chengyuJielong.autoPlayDelay` | 机器人自动操作延迟(秒) | 10 |
119
119
  | `chengyuJielong.autoPlayMaxCount` | 机器人最大自动操作次数 | 5 |
120
120
  | `chengyuJielong.autoStopInactiveTime` | 游戏无操作自动停止时间(秒) | 60 |
@@ -184,7 +184,7 @@ This is a lightweight, multi-functional mini-game plugin developed for the Koish
184
184
  | `chengyuImage.rewardScore` | Reward score for correct answer | 1 |
185
185
  | **🐉 Idiom Solitaire Configuration** | | |
186
186
  | `chengyuJielong.totalRounds` | Total rounds | 10 |
187
- | `chengyuJielong.showRank` | Show rank after game ends | true |
187
+ | `chengyuJielong.showRank` | Show rank after game ends | false |
188
188
  | `chengyuJielong.autoPlayDelay` | Bot auto operation delay (seconds) | 10 |
189
189
  | `chengyuJielong.autoPlayMaxCount` | Bot maximum auto operation count | 5 |
190
190
  | `chengyuJielong.autoStopInactiveTime` | Auto stop time due to inactivity (seconds) | 60 |