koishi-plugin-wordle-game 1.2.8 → 1.3.1
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 +17 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -156,7 +156,7 @@ function apply(ctx, config) {
|
|
|
156
156
|
id: 'unsigned',
|
|
157
157
|
channelId: 'string',
|
|
158
158
|
isStarted: 'boolean',
|
|
159
|
-
remainingGuessesCount: '
|
|
159
|
+
remainingGuessesCount: 'integer',
|
|
160
160
|
wordAnswerChineseDefinition: 'string',
|
|
161
161
|
wordGuess: 'string',
|
|
162
162
|
wordGuessHtmlCache: 'text',
|
|
@@ -571,12 +571,17 @@ function apply(ctx, config) {
|
|
|
571
571
|
wordsList = remainingWordsList;
|
|
572
572
|
}
|
|
573
573
|
let longestRemainingWordList = await findLongestMatchedWords(wordsList, lowercaseInputWord, targetWord, isChallengeMode);
|
|
574
|
-
|
|
575
|
-
longestRemainingWordList =
|
|
574
|
+
if (!longestRemainingWordList) {
|
|
575
|
+
longestRemainingWordList = [];
|
|
576
576
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
577
|
+
else {
|
|
578
|
+
while (isChallengeMode && wordsList.includes(targetWord) && longestRemainingWordList && longestRemainingWordList.length === 1 && longestRemainingWordList[0] !== targetWord) {
|
|
579
|
+
longestRemainingWordList = await findLongestMatchedWords(wordsList, lowercaseInputWord, targetWord, isChallengeMode);
|
|
580
|
+
}
|
|
581
|
+
// 变态挑战模式
|
|
582
|
+
if (isChallengeMode) {
|
|
583
|
+
isLose = !longestRemainingWordList.includes(targetWord);
|
|
584
|
+
}
|
|
580
585
|
}
|
|
581
586
|
let randomWord = longestRemainingWordList[Math.floor(Math.random() * longestRemainingWordList.length)];
|
|
582
587
|
const foundWord = findWord(randomWord);
|
|
@@ -651,9 +656,10 @@ function apply(ctx, config) {
|
|
|
651
656
|
const styledHtml = generateStyledHtml(gameInfo.guessWordLength + 1);
|
|
652
657
|
// 图
|
|
653
658
|
const imageBuffer = await generateImage(styledHtml, `${gameInfo.wordGuessHtmlCache}${letterTilesHtml}\n${emptyGridHtml}`);
|
|
659
|
+
const remainingGuessesCount = isAbsurd ? gameInfo.remainingGuessesCount : gameInfo.remainingGuessesCount - 1;
|
|
654
660
|
// 更新游戏记录
|
|
655
661
|
await ctx.database.set('wordle_game_records', { channelId }, {
|
|
656
|
-
remainingGuessesCount:
|
|
662
|
+
remainingGuessesCount: remainingGuessesCount,
|
|
657
663
|
wordGuessHtmlCache: `${gameInfo.wordGuessHtmlCache}${letterTilesHtml}\n`,
|
|
658
664
|
});
|
|
659
665
|
// 处理赢
|
|
@@ -1214,7 +1220,10 @@ async function findLongestMatchedWords(wordsList, lowercaseInputWord, targetWord
|
|
|
1214
1220
|
const maxLength = Math.max(...results.map(result => result.matchedWords.length));
|
|
1215
1221
|
let longestMatchedWords = results.filter(result => result.matchedWords.length === maxLength).map(result => result.matchedWords);
|
|
1216
1222
|
if (isChallengeMode && wordsList.includes(targetWord)) {
|
|
1217
|
-
|
|
1223
|
+
const filteredWords = longestMatchedWords.filter(words => words.includes(targetWord));
|
|
1224
|
+
if (filteredWords.length > 0) {
|
|
1225
|
+
longestMatchedWords = filteredWords;
|
|
1226
|
+
}
|
|
1218
1227
|
}
|
|
1219
1228
|
const randomIndex = Math.floor(Math.random() * longestMatchedWords.length);
|
|
1220
1229
|
return longestMatchedWords[randomIndex];
|