koishi-plugin-wordle-game 1.2.0 → 1.2.2
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 +16 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -484,7 +484,7 @@ function apply(ctx, config) {
|
|
|
484
484
|
const usernameMention = `【@${username}】`;
|
|
485
485
|
const inputLengthMessage = `输入的单词长度不对哦!\n您的输入为:【${inputWord}】\n它的长度为:【${inputWord.length}】\n待猜单词的长度为:【${gameInfo.guessWordLength}】`;
|
|
486
486
|
const presentLettersWithoutAsterisk = uniqueSortedLowercaseLetters(presentLetters);
|
|
487
|
-
const progressMessage =
|
|
487
|
+
const progressMessage = `当前${calculateGameDuration(gameInfo.timestamp, timestamp)}\n当前进度:【${correctLetters.join('')}】${presentLettersWithoutAsterisk.length === 0 ? `` : `\n包含字母:【${presentLettersWithoutAsterisk}】`}${absentLetters.length === 0 ? '' : `\n不包含字母:【${absentLetters}】`}`;
|
|
488
488
|
return await sendMessage(session, `${usernameMention}\n${inputLengthMessage}\n${progressMessage}`);
|
|
489
489
|
}
|
|
490
490
|
// 小写化
|
|
@@ -553,14 +553,14 @@ function apply(ctx, config) {
|
|
|
553
553
|
const [playerRecord] = await ctx.database.get('wordle_player_records', { userId });
|
|
554
554
|
await ctx.database.set('wordle_player_records', { userId }, { wordGuessCount: playerRecord.wordGuessCount + 1 });
|
|
555
555
|
await endGame(channelId);
|
|
556
|
-
return await sendMessage(session, `【@${username}】\n太棒了,你猜出来了!\n${koishi_1.h.image(imageBuffer, `image/${config.imageType}`)}\n${generateGameEndMessage(gameInfo)}\n${finalSettlementString === '' ? '' : `最终结算结果如下:\n${finalSettlementString}`}`);
|
|
556
|
+
return await sendMessage(session, `【@${username}】\n太棒了,你猜出来了!\n${calculateGameDuration(gameInfo.timestamp, timestamp)}\n${koishi_1.h.image(imageBuffer, `image/${config.imageType}`)}\n${generateGameEndMessage(gameInfo)}\n${finalSettlementString === '' ? '' : `最终结算结果如下:\n${finalSettlementString}`}`);
|
|
557
557
|
}
|
|
558
558
|
// 处理输
|
|
559
559
|
if (isLose) {
|
|
560
560
|
// 玩家记录输
|
|
561
561
|
await updatePlayerRecordsLose(channelId, gameInfo);
|
|
562
562
|
await endGame(channelId);
|
|
563
|
-
return await sendMessage(session, `很遗憾,你们没有猜出来!\n但没关系~下次加油哇!\n${koishi_1.h.image(imageBuffer, `image/${config.imageType}`)}\n答案是:【${gameInfo.wordGuess}】${gameInfo.wordAnswerChineseDefinition !== '' ? `\n单词释义如下:\n${gameInfo.wordAnswerChineseDefinition}` : ''}`);
|
|
563
|
+
return await sendMessage(session, `很遗憾,你们没有猜出来!\n但没关系~下次加油哇!\n${koishi_1.h.image(imageBuffer, `image/${config.imageType}`)}\n${calculateGameDuration(gameInfo.timestamp, timestamp)}\n答案是:【${gameInfo.wordGuess}】${gameInfo.wordAnswerChineseDefinition !== '' ? `\n单词释义如下:\n${gameInfo.wordAnswerChineseDefinition}` : ''}`);
|
|
564
564
|
}
|
|
565
565
|
// 继续
|
|
566
566
|
await setGuessRunningStatus(channelId, false);
|
|
@@ -654,7 +654,7 @@ ALL - 胜: ${stats.ALL?.win}, 负: ${stats.ALL?.lose}
|
|
|
654
654
|
const { correctLetters, presentLetters, isHardMode, gameMode, guessWordLength, absentLetters } = gameInfo;
|
|
655
655
|
const usernameMention = `【@${username}】`;
|
|
656
656
|
const inputLengthMessage = `待猜单词的长度为:【${guessWordLength}】`;
|
|
657
|
-
const progressMessage =
|
|
657
|
+
const progressMessage = `当前${calculateGameDuration(gameInfo.timestamp, timestamp)}\n当前进度:【${correctLetters.join('')}】${presentLetters.length === 0 ? '' : `\n包含字母:【${presentLetters}】`}${absentLetters.length === 0 ? '' : `\n不包含字母:【${absentLetters}】`}`;
|
|
658
658
|
const timeDifferenceInSeconds = (timestamp - gameInfo.timestamp) / 1000;
|
|
659
659
|
let message = `${usernameMention}\n当前游戏模式为:【${gameMode}${isHardMode ? '(困难)' : ''}】`;
|
|
660
660
|
if (config.enableWordGuessTimeLimit) {
|
|
@@ -1077,6 +1077,18 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}
|
|
|
1077
1077
|
}
|
|
1078
1078
|
exports.apply = apply;
|
|
1079
1079
|
// hs*
|
|
1080
|
+
function calculateGameDuration(startTime, currentTime) {
|
|
1081
|
+
const elapsedMilliseconds = currentTime - startTime;
|
|
1082
|
+
const elapsedSeconds = Math.floor(elapsedMilliseconds / 1000);
|
|
1083
|
+
const minutes = Math.floor(elapsedSeconds / 60);
|
|
1084
|
+
const seconds = elapsedSeconds % 60;
|
|
1085
|
+
if (minutes > 0) {
|
|
1086
|
+
return `用时:【${minutes} 分 ${seconds} 秒】`;
|
|
1087
|
+
}
|
|
1088
|
+
else {
|
|
1089
|
+
return `用时:【${seconds} 秒】`;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1080
1092
|
function uniqueSortedLowercaseLetters(input) {
|
|
1081
1093
|
const uniqueLetters = Array.from(new Set(input.toLowerCase().match(/[a-z]/g)));
|
|
1082
1094
|
return uniqueLetters.sort().join('');
|