koishi-plugin-wordle-game 2.4.0 → 2.4.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 +14 -15
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1562,11 +1562,13 @@ ${settlementResult}
|
|
|
1562
1562
|
userId = match?.[1] ?? userId;
|
|
1563
1563
|
username = match?.[2] ?? username;
|
|
1564
1564
|
targetUserRecord = await ctx.database.get('wordle_player_records', { userId });
|
|
1565
|
+
if (targetUserRecord.length === 0) {
|
|
1566
|
+
targetUserRecord = await ctx.database.get('wordle_player_records', { userId: targetUser });
|
|
1567
|
+
}
|
|
1565
1568
|
}
|
|
1566
1569
|
}
|
|
1567
1570
|
if (targetUserRecord.length === 0) {
|
|
1568
|
-
|
|
1569
|
-
return sendMessage(session, `查询对象:${username} 无任何游戏记录。`, `改名 查询玩家记录 开始游戏`, 2);
|
|
1571
|
+
return sendMessage(session, `被查询对象无任何游戏记录。`, `改名 查询玩家记录 开始游戏`, 2);
|
|
1570
1572
|
}
|
|
1571
1573
|
const { win, lose, moneyChange, wordGuessCount, stats, fastestGuessTime } = targetUserRecord[0];
|
|
1572
1574
|
const queryInfo = `【@${sessionUserName}】
|
|
@@ -3015,12 +3017,12 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
3015
3017
|
async function updatePlayerRecordsLose(channelId, gameInfo) {
|
|
3016
3018
|
const gamingPlayers = await ctx.database.get('wordle_gaming_player_records', { channelId });
|
|
3017
3019
|
for (const player of gamingPlayers) {
|
|
3020
|
+
const gameMode = gameInfo.gameMode;
|
|
3018
3021
|
const [playerInfo] = await ctx.database.get('wordle_player_records', { userId: player.userId });
|
|
3019
|
-
if (!playerInfo) {
|
|
3022
|
+
if (!playerInfo || !playerInfo.stats.hasOwnProperty(gameMode)) {
|
|
3020
3023
|
continue;
|
|
3021
3024
|
}
|
|
3022
3025
|
const updatedLose = playerInfo.lose + 1;
|
|
3023
|
-
const gameMode = gameInfo.gameMode;
|
|
3024
3026
|
playerInfo.stats[gameMode].lose += 1;
|
|
3025
3027
|
if (gameInfo.gameMode === '词影') {
|
|
3026
3028
|
if (gameInfo.wordlesNum === 1) {
|
|
@@ -3049,12 +3051,12 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
3049
3051
|
async function updatePlayerRecordsWin(channelId, gameInfo) {
|
|
3050
3052
|
const gamingPlayers = await ctx.database.get('wordle_gaming_player_records', { channelId });
|
|
3051
3053
|
for (const player of gamingPlayers) {
|
|
3054
|
+
const gameMode = gameInfo.gameMode;
|
|
3052
3055
|
const [playerInfo] = await ctx.database.get('wordle_player_records', { userId: player.userId });
|
|
3053
|
-
if (!playerInfo) {
|
|
3056
|
+
if (!playerInfo || !playerInfo.stats.hasOwnProperty(gameMode)) {
|
|
3054
3057
|
continue;
|
|
3055
3058
|
}
|
|
3056
3059
|
const updatedWin = playerInfo.win + 1;
|
|
3057
|
-
const gameMode = gameInfo.gameMode;
|
|
3058
3060
|
playerInfo.stats[gameMode].win += 1;
|
|
3059
3061
|
if (gameInfo.gameMode === '词影') {
|
|
3060
3062
|
if (gameInfo.wordlesNum === 1) {
|
|
@@ -3246,6 +3248,7 @@ ${gridHtml}
|
|
|
3246
3248
|
}
|
|
3247
3249
|
async function updateNameInPlayerRecord(session, userId, username) {
|
|
3248
3250
|
const userRecord = await ctx.database.get('wordle_player_records', { userId });
|
|
3251
|
+
let isChange = false;
|
|
3249
3252
|
if (userRecord.length === 0) {
|
|
3250
3253
|
await ctx.database.create('wordle_player_records', {
|
|
3251
3254
|
userId,
|
|
@@ -3254,25 +3257,21 @@ ${gridHtml}
|
|
|
3254
3257
|
return;
|
|
3255
3258
|
}
|
|
3256
3259
|
const existingRecord = userRecord[0];
|
|
3257
|
-
let isChange = false;
|
|
3258
3260
|
if (username !== existingRecord.username && !(isQQOfficialRobotMarkdownTemplateEnabled && session.platform === 'qq')) {
|
|
3259
3261
|
existingRecord.username = username;
|
|
3260
3262
|
isChange = true;
|
|
3261
3263
|
}
|
|
3262
|
-
const
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
if (!existingRecord.stats.hasOwnProperty(key)) {
|
|
3264
|
+
const keys = ['Lewdle', '汉兜', 'Numberle', 'Math', '词影'];
|
|
3265
|
+
keys.forEach((key) => {
|
|
3266
|
+
if (!existingRecord.stats[key] || !existingRecord.stats.hasOwnProperty(key)) {
|
|
3266
3267
|
existingRecord.stats[key] = { win: 0, lose: 0 };
|
|
3267
3268
|
isChange = true;
|
|
3268
3269
|
}
|
|
3269
|
-
|
|
3270
|
-
for (const key of timeKeys) {
|
|
3271
|
-
if (!existingRecord.fastestGuessTime.hasOwnProperty(key)) {
|
|
3270
|
+
if (!existingRecord.fastestGuessTime[key]) {
|
|
3272
3271
|
existingRecord.fastestGuessTime[key] = 0;
|
|
3273
3272
|
isChange = true;
|
|
3274
3273
|
}
|
|
3275
|
-
}
|
|
3274
|
+
});
|
|
3276
3275
|
if (isChange) {
|
|
3277
3276
|
await ctx.database.set('wordle_player_records', { userId }, {
|
|
3278
3277
|
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.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|