koishi-plugin-ggcevo-game 1.0.4 → 1.0.6
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 +28 -9
- 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) => {
|
|
@@ -935,6 +953,7 @@ ID:${activity.id}
|
|
|
935
953
|
句柄:${user.handle}
|
|
936
954
|
当前积分:${user.rank}
|
|
937
955
|
参赛次数:${user.matches} 次
|
|
956
|
+
胜率: ${user.matches === 0 ? "0.00%" : (user.wins / user.matches * 100).toFixed(2) + "%"}
|
|
938
957
|
全服排名:第 ${userRank} 位
|
|
939
958
|
------------------------------`;
|
|
940
959
|
}
|