koishi-plugin-xxck-1 0.3.6 → 0.3.8

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 CHANGED
@@ -80,6 +80,8 @@ var zh_CN_default = {
80
80
  "tip.draw.upgrade": "✅ 原有卡片升级成功\n",
81
81
  "tip.draw.vapor": "💧 水汽 +{vapor}\n",
82
82
  "tip.draw.disturb": "🌪️ 热带扰动 +{disturbanceTotal}",
83
+ "tip.draw.left": "🔢 剩余普通抽数:{left}抽",
84
+ "tip.eventDraw.left": "🔢 剩余{star}星限时抽数:{left}抽",
83
85
  "tip.eventDraw.pityReset": "✨ 已获得当期限时{star}星卡,保底进度重置;",
84
86
  "tip.eventDraw.pityProgress": "📊 限时{star}星保底进度:{current}/{threshold}抽(再抽{left}抽必出);",
85
87
  // ==============================================
@@ -140,7 +142,7 @@ var zh_CN_default = {
140
142
  "image.warehouse.empty": "你的仓库暂无任何卡片,快去抽卡吧!",
141
143
  "image.shop.title": "WWC每日商店({date})",
142
144
  "image.shop.userInfo": "玩家:{name}",
143
- "image.shop.asset": "热带扰动: {disturb} | 水汽:{vapor}",
145
+ "image.shop.asset": "热带扰动: {disturb} | 水汽:{vapor} | 剩余抽数:{draw}",
144
146
  "image.shop.exchangeCount": "今日普通兑换:{used}/{limit}抽(单次最多40)",
145
147
  "image.shop.header.card": "卡片信息",
146
148
  "image.shop.header.price": "升格价格",
@@ -203,6 +205,23 @@ async function getNextId(ctx, table) {
203
205
  return list.length ? list[0].id + 1 : 1;
204
206
  }
205
207
  __name(getNextId, "getNextId");
208
+ async function getShopRowsByDate(ctx, shopDate) {
209
+ const rows = await ctx.database.get("gacha_shop_daily", { shop_date: shopDate });
210
+ const merged = /* @__PURE__ */ new Map();
211
+ for (const row of rows) {
212
+ const key = String(row.card_id);
213
+ const exist = merged.get(key);
214
+ if (!exist) {
215
+ merged.set(key, { ...row });
216
+ continue;
217
+ }
218
+ if ((row.server_bought ?? 0) > (exist.server_bought ?? 0)) {
219
+ exist.server_bought = row.server_bought ?? 0;
220
+ }
221
+ }
222
+ return Array.from(merged.values());
223
+ }
224
+ __name(getShopRowsByDate, "getShopRowsByDate");
206
225
  function unescapeHtml(str) {
207
226
  if (!str || typeof str !== "string") return "";
208
227
  return str.replace(/&/gi, "&");
@@ -342,7 +361,7 @@ async function _warehouse_draw_image(ctx, user_cards, show_name, titleText, empt
342
361
  }
343
362
  }
344
363
  __name(_warehouse_draw_image, "_warehouse_draw_image");
345
- async function _shop_draw_image(ctx, session, userName, date, disturbance, vapor, usedExchange, limitExchange, shopCards) {
364
+ async function _shop_draw_image(ctx, session, userName, date, disturbance, vapor, drawLeft, usedExchange, limitExchange, shopCards) {
346
365
  ctx.logger.info("开始绘制店铺图片(最终稳定版)");
347
366
  try {
348
367
  if (!ctx.canvas) return null;
@@ -365,6 +384,7 @@ async function _shop_draw_image(ctx, session, userName, date, disturbance, vapor
365
384
  ctx2d.textAlign = "left";
366
385
  const distStr = String(disturbance ?? 0);
367
386
  const vaporStr = String(vapor ?? 0);
387
+ const drawStr = String(drawLeft ?? 0);
368
388
  ctx2d.save();
369
389
  ctx2d.textAlign = "center";
370
390
  ctx2d.fillStyle = "#E53E3E";
@@ -374,7 +394,7 @@ async function _shop_draw_image(ctx, session, userName, date, disturbance, vapor
374
394
  ctx2d.fillStyle = "#222";
375
395
  ctx2d.font = `20px ${FONT_FAMILY}`;
376
396
  ctx2d.fillText(`玩家:${userName}`, BASE_X, BASE_Y + 80);
377
- ctx2d.fillText(`热带扰动:${distStr}|水汽:${vaporStr}`, BASE_X, BASE_Y + 120);
397
+ ctx2d.fillText(`热带扰动:${distStr}|水汽:${vaporStr}|剩余抽数:${drawStr}`, BASE_X, BASE_Y + 120);
378
398
  const headerY = BASE_Y + 200;
379
399
  ctx2d.save();
380
400
  ctx2d.fillStyle = "#000";
@@ -966,6 +986,7 @@ async function _do_draw(ctx, session, draw_times, star7Threshold, star6Threshold
966
986
  if (isUpgrade) info += session.text("tip.draw.upgrade");
967
987
  info += session.text("tip.draw.vapor", { vapor: waterVaporTotal });
968
988
  info += session.text("tip.draw.disturb", { disturbanceTotal });
989
+ info += "\n" + session.text("tip.draw.left", { left: haveDraw - draw_times });
969
990
  if (info) msg += "\n" + info.replace(/;$/, "");
970
991
  await session.send(build_msg(session, msg));
971
992
  }
@@ -1023,7 +1044,7 @@ async function _do_upgrade(ctx, session, card_ids, signResetHour, signResetMinut
1023
1044
  let total_cost = 0;
1024
1045
  const shop_card_info = [];
1025
1046
  const [shopCards, cardPool] = await Promise.all([
1026
- ctx.database.get("gacha_shop_daily", { shop_date: today }),
1047
+ getShopRowsByDate(ctx, today),
1027
1048
  ctx.database.get("gacha_card_pool", {})
1028
1049
  ]);
1029
1050
  ctx.logger.info(`[升格] 当前店铺卡片:`, shopCards.map((s) => s.card_id));
@@ -1043,6 +1064,7 @@ async function _do_upgrade(ctx, session, card_ids, signResetHour, signResetMinut
1043
1064
  }
1044
1065
  for (let i = 0; i < num; i++) {
1045
1066
  shop_card_info.push({
1067
+ id: shopCard.id,
1046
1068
  card_id: shopCard.card_id,
1047
1069
  card_name: cardInfo.card_name,
1048
1070
  card_star: shopCard.card_star,
@@ -1085,14 +1107,17 @@ async function _do_upgrade(ctx, session, card_ids, signResetHour, signResetMinut
1085
1107
  if (d > 0) disturbance_total += d;
1086
1108
  }
1087
1109
  }
1088
- await ctx.database.upsert("gacha_shop_daily", [{
1110
+ const shopRow = {
1089
1111
  shop_date: today,
1090
1112
  card_id: card.card_id,
1091
1113
  card_star: card.card_star,
1092
1114
  price: card.price,
1093
1115
  server_limit: card.server_limit,
1094
1116
  server_bought: card.server_bought + 1
1095
- }]);
1117
+ };
1118
+ await ctx.database.upsert("gacha_shop_daily", [
1119
+ card.id != null ? { id: card.id, ...shopRow } : { ...shopRow }
1120
+ ]);
1096
1121
  }
1097
1122
  await ctx.database.upsert("gacha_user_draw_count", [{
1098
1123
  qq,
@@ -1296,7 +1321,7 @@ async function _do_shop(ctx, session, signResetHour, signResetMinute) {
1296
1321
  todayDate.setDate(todayDate.getDate() - 1);
1297
1322
  }
1298
1323
  const today = `${todayDate.getFullYear()}${String(todayDate.getMonth() + 1).padStart(2, "0")}${String(todayDate.getDate()).padStart(2, "0")}`;
1299
- let todayShop = await ctx.database.get("gacha_shop_daily", { shop_date: today });
1324
+ let todayShop = await getShopRowsByDate(ctx, today);
1300
1325
  if (todayShop.length === 0) {
1301
1326
  const [sevenStarCards, sixStarCards, fiveStarCards] = await Promise.all([
1302
1327
  ctx.database.get("gacha_card_pool", { card_star: 7 }),
@@ -1309,7 +1334,9 @@ async function _do_shop(ctx, session, signResetHour, signResetMinute) {
1309
1334
  const selected7 = sevenStarCards.sort(() => Math.random() - 0.5).slice(0, 4);
1310
1335
  const selected6 = sixStarCards.sort(() => Math.random() - 0.5).slice(0, 6);
1311
1336
  const selected5 = fiveStarCards.sort(() => Math.random() - 0.5).slice(0, 10);
1312
- const allCards = [...selected7, ...selected6, ...selected5];
1337
+ const allCards = Array.from(
1338
+ new Map([...selected7, ...selected6, ...selected5].map((c) => [String(c.card_id), c])).values()
1339
+ );
1313
1340
  const SHOP_PRICE_BASE = { 7: 800, 6: 200, 5: 20 };
1314
1341
  const SHOP_PRICE_RANGE = { 7: 80, 6: 30, 5: 0 };
1315
1342
  for (const card of allCards) {
@@ -1335,7 +1362,7 @@ async function _do_shop(ctx, session, signResetHour, signResetMinute) {
1335
1362
  });
1336
1363
  }
1337
1364
  }
1338
- todayShop = await ctx.database.get("gacha_shop_daily", { shop_date: today });
1365
+ todayShop = await getShopRowsByDate(ctx, today);
1339
1366
  }
1340
1367
  const pool = await ctx.database.get("gacha_card_pool", {});
1341
1368
  const poolMap = new Map(pool.map((p) => [p.card_id, p]));
@@ -1361,6 +1388,7 @@ async function _do_shop(ctx, session, signResetHour, signResetMinute) {
1361
1388
  const userAsset = await ctx.database.get("gacha_user_draw_count", { qq });
1362
1389
  const dist = userAsset[0]?.tropical_disturbance ?? 0;
1363
1390
  const vapor = userAsset[0]?.water_vapor ?? 0;
1391
+ const drawLeft = userAsset[0]?.draw_count ?? 0;
1364
1392
  const img = await _shop_draw_image(
1365
1393
  ctx,
1366
1394
  session,
@@ -1368,6 +1396,7 @@ async function _do_shop(ctx, session, signResetHour, signResetMinute) {
1368
1396
  today,
1369
1397
  dist,
1370
1398
  vapor,
1399
+ drawLeft,
1371
1400
  0,
1372
1401
  0,
1373
1402
  shopCardList
@@ -1894,6 +1923,7 @@ async function _do_event_draw(ctx, session, data, event6Threshold, event7Thresho
1894
1923
  } else {
1895
1924
  info += session.text("tip.eventDraw.pityReset", { star: limitStar });
1896
1925
  }
1926
+ info += "\n" + session.text("tip.eventDraw.left", { star: limitStar, left: have - count });
1897
1927
  if (info) msg += "\n" + info.replace(/;$/, "");
1898
1928
  await session.send(build_msg(session, msg));
1899
1929
  if (true) {
@@ -41,6 +41,8 @@ declare const _default: {
41
41
  "tip.draw.upgrade": string;
42
42
  "tip.draw.vapor": string;
43
43
  "tip.draw.disturb": string;
44
+ "tip.draw.left": string;
45
+ "tip.eventDraw.left": string;
44
46
  "tip.eventDraw.pityReset": string;
45
47
  "tip.eventDraw.pityProgress": string;
46
48
  "error.common.noPermission": string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-xxck-1",
3
3
  "description": "抽卡系统|完整指令说明见readme|建议使用skia-canvas",
4
- "version": "0.3.6",
4
+ "version": "0.3.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [