koishi-plugin-wordle-game 2.4.0 → 2.4.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 +10 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3015,12 +3015,12 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
3015
3015
|
async function updatePlayerRecordsLose(channelId, gameInfo) {
|
|
3016
3016
|
const gamingPlayers = await ctx.database.get('wordle_gaming_player_records', { channelId });
|
|
3017
3017
|
for (const player of gamingPlayers) {
|
|
3018
|
+
const gameMode = gameInfo.gameMode;
|
|
3018
3019
|
const [playerInfo] = await ctx.database.get('wordle_player_records', { userId: player.userId });
|
|
3019
|
-
if (!playerInfo) {
|
|
3020
|
+
if (!playerInfo || !playerInfo.stats.hasOwnProperty(gameMode)) {
|
|
3020
3021
|
continue;
|
|
3021
3022
|
}
|
|
3022
3023
|
const updatedLose = playerInfo.lose + 1;
|
|
3023
|
-
const gameMode = gameInfo.gameMode;
|
|
3024
3024
|
playerInfo.stats[gameMode].lose += 1;
|
|
3025
3025
|
if (gameInfo.gameMode === '词影') {
|
|
3026
3026
|
if (gameInfo.wordlesNum === 1) {
|
|
@@ -3049,12 +3049,12 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
3049
3049
|
async function updatePlayerRecordsWin(channelId, gameInfo) {
|
|
3050
3050
|
const gamingPlayers = await ctx.database.get('wordle_gaming_player_records', { channelId });
|
|
3051
3051
|
for (const player of gamingPlayers) {
|
|
3052
|
+
const gameMode = gameInfo.gameMode;
|
|
3052
3053
|
const [playerInfo] = await ctx.database.get('wordle_player_records', { userId: player.userId });
|
|
3053
|
-
if (!playerInfo) {
|
|
3054
|
+
if (!playerInfo || !playerInfo.stats.hasOwnProperty(gameMode)) {
|
|
3054
3055
|
continue;
|
|
3055
3056
|
}
|
|
3056
3057
|
const updatedWin = playerInfo.win + 1;
|
|
3057
|
-
const gameMode = gameInfo.gameMode;
|
|
3058
3058
|
playerInfo.stats[gameMode].win += 1;
|
|
3059
3059
|
if (gameInfo.gameMode === '词影') {
|
|
3060
3060
|
if (gameInfo.wordlesNum === 1) {
|
|
@@ -3246,6 +3246,7 @@ ${gridHtml}
|
|
|
3246
3246
|
}
|
|
3247
3247
|
async function updateNameInPlayerRecord(session, userId, username) {
|
|
3248
3248
|
const userRecord = await ctx.database.get('wordle_player_records', { userId });
|
|
3249
|
+
let isChange = false;
|
|
3249
3250
|
if (userRecord.length === 0) {
|
|
3250
3251
|
await ctx.database.create('wordle_player_records', {
|
|
3251
3252
|
userId,
|
|
@@ -3254,25 +3255,21 @@ ${gridHtml}
|
|
|
3254
3255
|
return;
|
|
3255
3256
|
}
|
|
3256
3257
|
const existingRecord = userRecord[0];
|
|
3257
|
-
let isChange = false;
|
|
3258
3258
|
if (username !== existingRecord.username && !(isQQOfficialRobotMarkdownTemplateEnabled && session.platform === 'qq')) {
|
|
3259
3259
|
existingRecord.username = username;
|
|
3260
3260
|
isChange = true;
|
|
3261
3261
|
}
|
|
3262
|
-
const
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
if (!existingRecord.stats.hasOwnProperty(key)) {
|
|
3262
|
+
const keys = ['Lewdle', '汉兜', 'Numberle', 'Math', '词影'];
|
|
3263
|
+
keys.forEach((key) => {
|
|
3264
|
+
if (!existingRecord.stats[key] || !existingRecord.stats.hasOwnProperty(key)) {
|
|
3266
3265
|
existingRecord.stats[key] = { win: 0, lose: 0 };
|
|
3267
3266
|
isChange = true;
|
|
3268
3267
|
}
|
|
3269
|
-
|
|
3270
|
-
for (const key of timeKeys) {
|
|
3271
|
-
if (!existingRecord.fastestGuessTime.hasOwnProperty(key)) {
|
|
3268
|
+
if (!existingRecord.fastestGuessTime[key]) {
|
|
3272
3269
|
existingRecord.fastestGuessTime[key] = 0;
|
|
3273
3270
|
isChange = true;
|
|
3274
3271
|
}
|
|
3275
|
-
}
|
|
3272
|
+
});
|
|
3276
3273
|
if (isChange) {
|
|
3277
3274
|
await ctx.database.set('wordle_player_records', { userId }, {
|
|
3278
3275
|
username: existingRecord.username,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-wordle-game",
|
|
3
3
|
"description": "欢迎来到 [Wordle](https://www.nytimes.com/games/wordle/index.html) | [汉兜](https://handle.antfu.me/) | [词影](https://cy.surprising.studio/) |... 猜单词|猜成语|猜数字|猜数学方程式|... 的小游戏,支持QQ官方MD模板,且包含多种词库、主题、游戏设置和排行榜系统等。",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|