koishi-plugin-wordle-game 1.2.8 → 1.3.0
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 +15 -7
- 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);
|
|
@@ -1214,7 +1219,10 @@ async function findLongestMatchedWords(wordsList, lowercaseInputWord, targetWord
|
|
|
1214
1219
|
const maxLength = Math.max(...results.map(result => result.matchedWords.length));
|
|
1215
1220
|
let longestMatchedWords = results.filter(result => result.matchedWords.length === maxLength).map(result => result.matchedWords);
|
|
1216
1221
|
if (isChallengeMode && wordsList.includes(targetWord)) {
|
|
1217
|
-
|
|
1222
|
+
const filteredWords = longestMatchedWords.filter(words => words.includes(targetWord));
|
|
1223
|
+
if (filteredWords.length > 0) {
|
|
1224
|
+
longestMatchedWords = filteredWords;
|
|
1225
|
+
}
|
|
1218
1226
|
}
|
|
1219
1227
|
const randomIndex = Math.floor(Math.random() * longestMatchedWords.length);
|
|
1220
1228
|
return longestMatchedWords[randomIndex];
|