koishi-plugin-dwrgbwiki 1.3.1 → 1.3.3

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 (3) hide show
  1. package/gacha.js +14 -19
  2. package/index.js +10 -2
  3. package/package.json +1 -1
package/gacha.js CHANGED
@@ -212,10 +212,11 @@ function itemKey(item) {
212
212
  return [item.name, item.type, item.rarity, item.img || ''].join('|')
213
213
  }
214
214
 
215
- // 记录已抽到物品(存储名称/稀有度/数量/图片,兼容旧版 true 数据)
215
+ // 记录已抽到物品(存储名称/稀有度/数量/图片,兼容旧版 true 数据),返回是否为重复
216
216
  function markOwned(user, item) {
217
217
  const key = itemKey(item)
218
218
  const prev = user.owned[key]
219
+ const isRepeat = !!prev
219
220
  user.owned[key] = {
220
221
  name: item.name,
221
222
  type: item.type,
@@ -223,7 +224,7 @@ function markOwned(user, item) {
223
224
  img: item.img || item.icon || '',
224
225
  count: (prev && typeof prev === 'object' ? prev.count || 0 : 0) + 1,
225
226
  }
226
- return key
227
+ return isRepeat
227
228
  }
228
229
 
229
230
  // 通用状态字段
@@ -309,8 +310,7 @@ function v1Draw(pool, prob, state, user) {
309
310
  else if (r === 'A') state.pityPurple = 0
310
311
  else if (r === 'B') state.pityBlue = 0
311
312
 
312
- const key = markOwned(user, item)
313
- const isRepeat = !!user.owned[key]
313
+ const isRepeat = markOwned(user, item)
314
314
  return { item, isRepeat, fragments: isRepeat ? (item.repeat || 0) : 0 }
315
315
  }
316
316
 
@@ -364,8 +364,7 @@ function v2Draw(pool, prob, state, user) {
364
364
  else if (r === 'B') state.pityBlue = 0
365
365
  else if (r === 'F') state.pityFrame = 0
366
366
 
367
- const key = markOwned(user, item)
368
- const isRepeat = !!user.owned[key]
367
+ const isRepeat = markOwned(user, item)
369
368
  return { item, isRepeat, fragments: isRepeat ? (item.repeat || 0) : 0 }
370
369
  }
371
370
 
@@ -411,8 +410,7 @@ function xingyunDraw(pool, prob, state, user) {
411
410
  if (name && pool.items[name]) {
412
411
  const it = pool.items[name]
413
412
  const final = { ...it, name, rarity: it.rarity }
414
- const key = markOwned(user, final)
415
- const isRepeat = !!user.owned[key]
413
+ const isRepeat = markOwned(user, final)
416
414
  return { item: final, isRepeat, fragments: isRepeat ? (it.repeat || 0) : 0 }
417
415
  }
418
416
  }
@@ -423,8 +421,7 @@ function xingyunDraw(pool, prob, state, user) {
423
421
  const name = names[Math.floor(Math.random() * names.length)]
424
422
  const it = pool.items[name] || { type: '未知', rarity: 'D' }
425
423
  const final = { ...it, name, rarity: it.rarity }
426
- const key = markOwned(user, final)
427
- const isRepeat = !!user.owned[key]
424
+ const isRepeat = markOwned(user, final)
428
425
  return { item: final, isRepeat, fragments: isRepeat ? (it.repeat || 0) : 0 }
429
426
  }
430
427
 
@@ -452,8 +449,7 @@ function jyxbDraw(pool, prob, state, user, isOld) {
452
449
  const items = pool.items[r] || []
453
450
  const item = items.length > 0 ? items[Math.floor(Math.random() * items.length)] : { name: '未知' + r + '级', type: '奖励', rarity: r }
454
451
  const final = { ...item, rarity: r }
455
- const key = markOwned(user, final)
456
- const isRepeat = !!user.owned[key]
452
+ const isRepeat = markOwned(user, final)
457
453
 
458
454
  let fragments = 0, clue = 0
459
455
  const match = String(item.name || '').match(/\*(\d+)/)
@@ -497,8 +493,7 @@ function hxmtDraw(pool, prob, state, user) {
497
493
  if (r === 'discount') {
498
494
  // 折扣不参与重复
499
495
  } else {
500
- const key = markOwned(user, final)
501
- const isRepeat = !!user.owned[key]
496
+ const isRepeat = markOwned(user, final)
502
497
  final.isRepeat = isRepeat
503
498
  if (isRepeat) {
504
499
  const reward = (pool.repeatRewards && pool.repeatRewards[r]) || 0
@@ -802,7 +797,7 @@ body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Microsoft YaHei'
802
797
  .card-img { width:100%; aspect-ratio:1/1; background:#111318; border-radius:10px; display:flex; align-items:center; justify-content:center; overflow:hidden; margin-bottom:10px; }
803
798
  .card-img img { max-width:100%; max-height:100%; object-fit:contain; filter:drop-shadow(0 0 10px var(--c)) drop-shadow(0 0 20px var(--c)); }
804
799
  .noimg { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:34px; font-weight:800; color:var(--c); }
805
- .card-name { font-size:14px; font-weight:700; color:#fff; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
800
+ .card-name { font-size:20px; font-weight:700; color:#fff; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
806
801
  .card-type { font-size:12px; }
807
802
  .empty { text-align:center; color:#8b949e; font-size:15px; padding:40px 0; }
808
803
  .foot { text-align:center; color:#8b949e; font-size:12px; margin-top:18px; opacity:.75; }
@@ -890,14 +885,14 @@ body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Microsoft YaHei'
890
885
  text-align:center; overflow:hidden; }
891
886
  .card-img { width:100%; aspect-ratio:1/1; background:#111318; border-radius:10px; display:flex; align-items:center; justify-content:center; overflow:hidden; margin-bottom:10px; }
892
887
  .card-img img { max-width:100%; max-height:100%; object-fit:contain; filter:drop-shadow(0 0 10px var(--c)) drop-shadow(0 0 20px var(--c)); }
893
- .card-name { font-size:14px; font-weight:700; color:#fff; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
888
+ .card-name { font-size:20px; font-weight:700; color:#fff; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
894
889
  .card-type { font-size:12px; }
895
- .repeat { margin-top:6px; font-size:11.5px; color:#f85149; background:rgba(248,81,73,.08); border:1px solid rgba(248,81,73,.2); border-radius:6px; padding:3px 6px; }
890
+ .repeat { margin-top:6px; font-size:15px; color:#f85149; background:rgba(248,81,73,.08); border:1px solid rgba(248,81,73,.2); border-radius:6px; padding:3px 6px; }
896
891
  .gains { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:20px; }
897
892
  .gains span { font-size:13px; font-weight:700; color:#3fb950; background:rgba(63,185,80,.08); border:1px solid rgba(63,185,80,.25); border-radius:8px; padding:5px 14px; }
898
893
  .foot { text-align:center; color:#8b949e; font-size:12px; margin-top:18px; opacity:.75; }
899
894
  .pity { text-align:center; color:#8b949e; font-size:12px; margin-top:8px; }
900
- .daily { display:inline-block; font-size:12.5px; color:#8b949e; background:rgba(139,148,158,.08); border:1px solid rgba(139,148,158,.25);
895
+ .daily { display:inline-block; font-size:25px; color:#8b949e; background:rgba(139,148,158,.08); border:1px solid rgba(139,148,158,.25);
901
896
  border-radius:8px; padding:4px 12px; margin-top:10px; }
902
897
  </style>
903
898
  </head>
@@ -1435,7 +1430,7 @@ body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Microsoft YaHei'
1435
1430
  .status { display:inline-block; font-size:14px; font-weight:700; border-radius:8px; padding:5px 16px; margin-top:10px; }
1436
1431
  .status.good { color:#3fb950; background:rgba(63,185,80,.1); border:1px solid rgba(63,185,80,.3); }
1437
1432
  .status.bad { color:#f85149; background:rgba(248,81,73,.1); border:1px solid rgba(248,81,73,.3); }
1438
- .daily { display:inline-block; font-size:12.5px; color:#8b949e; background:rgba(139,148,158,.08); border:1px solid rgba(139,148,158,.25);
1433
+ .daily { display:inline-block; font-size:25px; color:#8b949e; background:rgba(139,148,158,.08); border:1px solid rgba(139,148,158,.25);
1439
1434
  border-radius:8px; padding:4px 12px; margin-left:8px; }
1440
1435
  .log { background:rgba(22,27,34,.75); border:1px solid rgba(255,255,255,.09); border-radius:14px; padding:18px 20px; }
1441
1436
  .line { font-size:13px; line-height:1.9; color:#c9d1d9; }
package/index.js CHANGED
@@ -242,7 +242,11 @@ module.exports = {
242
242
  if (t === '加页探索' || t === '加页手记探索') {
243
243
  try {
244
244
  const result = await gacha.gachaExplore(config, gachaStore, uid, poolId)
245
- if (!result.ok) return errorImage(ctx, config, result.error, GACHA_HERO_SUB)
245
+ if (!result.ok) {
246
+ // 达到每日上限:纯文字提示
247
+ if (result.error && result.error.includes('上限')) return result.error
248
+ return errorImage(ctx, config, result.error, GACHA_HERO_SUB)
249
+ }
246
250
  const width = (config.gachaWidth && config.gachaWidth > 0) ? config.gachaWidth : config.width
247
251
  const html = gacha.buildExploreHtml(result, { ...config, width })
248
252
  const image = await capture(ctx, html, { ...config, width })
@@ -259,7 +263,11 @@ module.exports = {
259
263
  }
260
264
  try {
261
265
  const result = await gacha.gachaPull(config, gachaStore, uid, t, poolId, count)
262
- if (!result.ok) return errorImage(ctx, config, result.error, GACHA_HERO_SUB)
266
+ if (!result.ok) {
267
+ // 达到每日上限:纯文字提示
268
+ if (result.error && result.error.includes('上限')) return result.error
269
+ return errorImage(ctx, config, result.error, GACHA_HERO_SUB)
270
+ }
263
271
  const width = (config.gachaWidth && config.gachaWidth > 0) ? config.gachaWidth : config.width
264
272
  const html = gacha.buildGachaHtml(result, { ...config, width })
265
273
  const image = await capture(ctx, html, { ...config, width })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-dwrgbwiki",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "第五人格BWIKI编辑组测试用插件,所有代码由DeepSeek V4 Flash编写",
5
5
  "main": "index.js",
6
6
  "files": [