koishi-plugin-ggcevo-game 1.0.5 → 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.
Files changed (2) hide show
  1. package/lib/index.js +27 -9
  2. 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 [record] = await ctx.database.get("ggcevo_records", { handle });
197
- const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 2 });
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
- await ctx.database.upsert("ggcevo_backpack", [{
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: 2,
203
- quantity: (backpack?.quantity || 0) + 3
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 * 3} 张兑换券!`] : []
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 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 3 张兑换券!`] : []
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 * 3} 张兑换券!`] : []
367
+ ...hiddenWinCount > 0 ? [`🎉 恭喜你抽中隐藏奖励,额外获得 ${hiddenWinCount * 100} 枚咕咕币, ${hiddenWinCount} 张兑换券,以及 ${hiddenWinCount} 枚扭蛋币!`] : []
350
368
  ].join("\n");
351
369
  });
352
370
  ctx.command("ggcevo/抽奖记录").action(async (argv) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ggcevo-game",
3
3
  "description": "星际争霸2游戏大厅咕咕虫-Evo地图专属插件",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [