koishi-plugin-ggcevo-game 1.0.5 → 1.0.7
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 +82 -21
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -193,15 +193,33 @@ function apply(ctx, config) {
|
|
|
193
193
|
}
|
|
194
194
|
__name(gachaWithPity, "gachaWithPity");
|
|
195
195
|
async function gachaWithHiddenAward(handle) {
|
|
196
|
-
const
|
|
197
|
-
|
|
196
|
+
const backpackItems = await ctx.database.get("ggcevo_backpack", {
|
|
197
|
+
handle,
|
|
198
|
+
itemId: { $in: [1, 2, 3] }
|
|
199
|
+
});
|
|
200
|
+
const itemMap = new Map(backpackItems.map((item) => [item.itemId, item]));
|
|
198
201
|
const isWin = HiddenAward();
|
|
199
202
|
if (isWin) {
|
|
200
|
-
|
|
203
|
+
const updates = [
|
|
204
|
+
{
|
|
205
|
+
itemId: 1,
|
|
206
|
+
addAmount: 100
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
itemId: 2,
|
|
210
|
+
addAmount: 1
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
itemId: 3,
|
|
214
|
+
addAmount: 1
|
|
215
|
+
}
|
|
216
|
+
].map(({ itemId, addAmount }) => ({
|
|
201
217
|
handle,
|
|
202
|
-
itemId
|
|
203
|
-
quantity: (
|
|
204
|
-
}
|
|
218
|
+
itemId,
|
|
219
|
+
quantity: (itemMap.get(itemId)?.quantity || 0) + addAmount
|
|
220
|
+
}));
|
|
221
|
+
await ctx.database.upsert("ggcevo_backpack", updates, ["handle", "itemId"]);
|
|
222
|
+
const [record] = await ctx.database.get("ggcevo_records", { handle });
|
|
205
223
|
await ctx.database.upsert("ggcevo_records", [{
|
|
206
224
|
handle,
|
|
207
225
|
hiddenawards: (record?.hiddenawards || 0) + 1
|
|
@@ -275,7 +293,7 @@ function apply(ctx, config) {
|
|
|
275
293
|
`🎰 您使用了 ${quantity} 枚咕咕币`,
|
|
276
294
|
winCount > 0 ? `🎉 其中获得 ${winCount} 张兑换券!` : "💔 本次未获得任何兑换券",
|
|
277
295
|
`📊 当前保底进度:${record.pityCounter}/90`,
|
|
278
|
-
...hiddenWinCount > 0 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 ${hiddenWinCount *
|
|
296
|
+
...hiddenWinCount > 0 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 ${hiddenWinCount * 100} 枚咕咕币, ${hiddenWinCount} 张兑换券,以及 ${hiddenWinCount} 枚扭蛋币!`] : []
|
|
279
297
|
].join("\n");
|
|
280
298
|
});
|
|
281
299
|
ctx.command("ggcevo/单抽").action(async (argv) => {
|
|
@@ -307,7 +325,7 @@ function apply(ctx, config) {
|
|
|
307
325
|
const [record] = await ctx.database.get("ggcevo_records", { handle });
|
|
308
326
|
return [
|
|
309
327
|
`${result ? "🎉 获得兑换券!" : "❌ 未中奖"} 保底进度:${record.pityCounter}/90`,
|
|
310
|
-
...HiddenAward2 ? [`🎉 恭喜你抽中隐藏奖励,额外获得
|
|
328
|
+
...HiddenAward2 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 100 枚咕咕币, 1 张兑换券,以及 1 枚扭蛋币!`] : []
|
|
311
329
|
].join("\n");
|
|
312
330
|
});
|
|
313
331
|
ctx.command("ggcevo/十连抽").action(async (argv) => {
|
|
@@ -346,7 +364,7 @@ function apply(ctx, config) {
|
|
|
346
364
|
"十连抽结果:",
|
|
347
365
|
...results.map((r) => r ? "⭐获得兑换券" : "❌未中奖"),
|
|
348
366
|
`保底进度:${record.pityCounter}/90`,
|
|
349
|
-
...hiddenWinCount > 0 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 ${hiddenWinCount *
|
|
367
|
+
...hiddenWinCount > 0 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 ${hiddenWinCount * 100} 枚咕咕币, ${hiddenWinCount} 张兑换券,以及 ${hiddenWinCount} 枚扭蛋币!`] : []
|
|
350
368
|
].join("\n");
|
|
351
369
|
});
|
|
352
370
|
ctx.command("ggcevo/抽奖记录").action(async (argv) => {
|
|
@@ -863,16 +881,27 @@ ID:${activity.id}
|
|
|
863
881
|
displayName: await checkSensitiveWord(item.name) ? item.name : (item.name[0] || "") + "***"
|
|
864
882
|
}))
|
|
865
883
|
);
|
|
884
|
+
const ggcmap = await ctx.database.get("sc2arcade_map", { guildId: config.ggcqun });
|
|
885
|
+
const lastdate = ggcmap[0].lastdate;
|
|
866
886
|
const rankingText = processedRecords.map(
|
|
867
887
|
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} | 胜率: ${item.matches === 0 ? "0.00%" : (item.wins / item.matches * 100).toFixed(2) + "%"}`
|
|
868
888
|
).join("\n");
|
|
869
889
|
return [
|
|
870
890
|
`🏆 GGCEvo S1赛季胜点榜 🏆`,
|
|
871
|
-
`本赛季从4月1日至5月15日23
|
|
872
|
-
|
|
891
|
+
`本赛季从4月1日至5月15日23点`,
|
|
892
|
+
`数据同步时间: ${lastdate.toLocaleString("zh-CN", {
|
|
893
|
+
timeZone: "Asia/Shanghai",
|
|
894
|
+
year: "numeric",
|
|
895
|
+
month: "2-digit",
|
|
896
|
+
day: "2-digit",
|
|
897
|
+
hour: "2-digit",
|
|
898
|
+
minute: "2-digit",
|
|
899
|
+
hour12: false
|
|
900
|
+
})}`,
|
|
873
901
|
"------------------------------",
|
|
874
902
|
rankingText,
|
|
875
903
|
"------------------------------",
|
|
904
|
+
`第 ${pageNum} 页 / 共 ${totalPages} 页`,
|
|
876
905
|
pageNum < totalPages ? `输入 胜点榜 ${pageNum + 1} 查看下一页` : "已是最后一页"
|
|
877
906
|
].join("\n");
|
|
878
907
|
});
|
|
@@ -1293,7 +1322,7 @@ ${achievementList.join("\n")}`;
|
|
|
1293
1322
|
──────────────`);
|
|
1294
1323
|
const [sign] = await ctx.database.get("ggcevo_sign", { handle });
|
|
1295
1324
|
if (sign) {
|
|
1296
|
-
const chinaTime = sign.lastSign.toLocaleString("zh-CN", {
|
|
1325
|
+
const chinaTime = new Date(sign.lastSign).toLocaleString("zh-CN", {
|
|
1297
1326
|
timeZone: "Asia/Shanghai",
|
|
1298
1327
|
year: "numeric",
|
|
1299
1328
|
month: "2-digit",
|
|
@@ -1321,22 +1350,54 @@ ${achievementList.join("\n")}`;
|
|
|
1321
1350
|
"──────────────"
|
|
1322
1351
|
);
|
|
1323
1352
|
}
|
|
1324
|
-
const
|
|
1325
|
-
if (achievements) {
|
|
1326
|
-
output.push(
|
|
1327
|
-
|
|
1328
|
-
|
|
1353
|
+
const achievements = await ctx.database.get("ggcevo_achievements", { handle });
|
|
1354
|
+
if (achievements.length) {
|
|
1355
|
+
output.push("🏆 最近成就:");
|
|
1356
|
+
achievements.sort((a, b) => {
|
|
1357
|
+
const aTime = new Date(a.gaintime).getTime();
|
|
1358
|
+
const bTime = new Date(b.gaintime).getTime();
|
|
1359
|
+
return bTime - aTime;
|
|
1360
|
+
}).slice(0, 3).forEach((ach) => {
|
|
1361
|
+
const time = new Date(ach.gaintime).toLocaleDateString("zh-CN", {
|
|
1329
1362
|
timeZone: "Asia/Shanghai",
|
|
1330
1363
|
year: "numeric",
|
|
1331
1364
|
month: "2-digit",
|
|
1332
1365
|
day: "2-digit"
|
|
1333
|
-
})
|
|
1366
|
+
});
|
|
1367
|
+
output.push(`├ ${ach.achievementname} (${time})`);
|
|
1368
|
+
});
|
|
1369
|
+
output.push(
|
|
1370
|
+
`└ 共获得 ${achievements.length} 个成就`,
|
|
1334
1371
|
"──────────────"
|
|
1335
1372
|
);
|
|
1336
1373
|
}
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
|
|
1374
|
+
const exchanges = await ctx.database.get("ggcevo_exchange", { handle });
|
|
1375
|
+
if (exchanges.length) {
|
|
1376
|
+
output.push("📜 兑换记录:");
|
|
1377
|
+
exchanges.sort((a, b) => {
|
|
1378
|
+
const aTime = new Date(a.date).getTime();
|
|
1379
|
+
const bTime = new Date(b.date).getTime();
|
|
1380
|
+
return bTime - aTime;
|
|
1381
|
+
}).forEach((e, index) => {
|
|
1382
|
+
const date = new Date(e.date).toLocaleString("zh-CN", {
|
|
1383
|
+
timeZone: "Asia/Shanghai",
|
|
1384
|
+
year: "numeric",
|
|
1385
|
+
month: "2-digit",
|
|
1386
|
+
day: "2-digit"
|
|
1387
|
+
});
|
|
1388
|
+
const symbol = index === exchanges.length - 1 ? "└" : "├";
|
|
1389
|
+
output.push(`${symbol} [${e.type}] ${e.item} (${date})`);
|
|
1390
|
+
});
|
|
1391
|
+
output.push("──────────────");
|
|
1392
|
+
}
|
|
1393
|
+
const existModules = [
|
|
1394
|
+
sign && "签到",
|
|
1395
|
+
lottery && "抽奖",
|
|
1396
|
+
achievements.length && "成就",
|
|
1397
|
+
exchanges.length && "兑换"
|
|
1398
|
+
].filter(Boolean);
|
|
1399
|
+
output.push(`📊 共查询到 ${existModules.length} 类信息`);
|
|
1400
|
+
return output.join("\n");
|
|
1340
1401
|
});
|
|
1341
1402
|
}
|
|
1342
1403
|
__name(apply, "apply");
|