koishi-plugin-dwrgbwiki 1.3.1 → 1.3.2
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/gacha.js +27 -29
- package/index.js +2 -2
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
@@ -648,7 +643,7 @@ async function gachaPull(config, store, userId, poolType, poolQuery, count) {
|
|
|
648
643
|
const daily = user.daily[type] || { date: todayStr, count: 0 }
|
|
649
644
|
if (daily.date !== todayStr) { daily.date = todayStr; daily.count = 0 }
|
|
650
645
|
if (daily.count >= limit) {
|
|
651
|
-
return { ok: false, error: '今日' + (POOL_TYPES[type].label || type) + '抽卡次数已达上限(每种每天限 ' + limit + ' 次),明天再来吧' }
|
|
646
|
+
return { ok: false, limit: true, error: '今日' + (POOL_TYPES[type].label || type) + '抽卡次数已达上限(每种每天限 ' + limit + ' 次),明天再来吧' }
|
|
652
647
|
}
|
|
653
648
|
|
|
654
649
|
const results = []
|
|
@@ -772,7 +767,7 @@ function buildResourcesHtml(data, config) {
|
|
|
772
767
|
return '<div class="card" style="--c:' + color + '">' +
|
|
773
768
|
'<div class="card-img">' + imgHtml + '</div>' +
|
|
774
769
|
'<div class="card-name">' + esc(it.name) + '</div>' +
|
|
775
|
-
'<div class="card-type" style="color:' + color + '">' + esc(label) + (it.count > 1 ? '
|
|
770
|
+
'<div class="card-type" style="color:' + color + '">' + esc(label) + (it.count > 1 ? ' ×' + it.count : '') + '</div>' +
|
|
776
771
|
'</div>'
|
|
777
772
|
}).join('')
|
|
778
773
|
|
|
@@ -797,13 +792,13 @@ body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Microsoft YaHei'
|
|
|
797
792
|
.res { font-size:13px; color:#8b949e; background:rgba(139,148,158,.08); border:1px solid rgba(139,148,158,.25); border-radius:8px; padding:5px 14px; }
|
|
798
793
|
.res b { color:#e6edf3; margin-left:4px; }
|
|
799
794
|
.grid { display:grid; grid-template-columns:repeat(${colNum}, 1fr); gap:14px; }
|
|
800
|
-
.card { background:rgba(22,27,34,.75); border:1px solid rgba(255,255,255,.09); border-radius:14px; padding:
|
|
795
|
+
.card { background:rgba(22,27,34,.75); border:1px solid rgba(255,255,255,.09); border-radius:14px; padding:12px 8px;
|
|
801
796
|
text-align:center; overflow:hidden; }
|
|
802
|
-
.card-img { width:
|
|
797
|
+
.card-img { width:54px; height:54px; margin:0 auto 8px; background:#111318; border-radius:10px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
|
|
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
|
-
.noimg { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:
|
|
805
|
-
.card-name { font-size:
|
|
806
|
-
.card-type { font-size:
|
|
799
|
+
.noimg { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:22px; font-weight:800; color:var(--c); }
|
|
800
|
+
.card-name { font-size:14.5px; font-weight:700; color:#fff; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
801
|
+
.card-type { font-size:13px; }
|
|
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; }
|
|
809
804
|
</style>
|
|
@@ -850,7 +845,7 @@ function buildGachaHtml(data, config) {
|
|
|
850
845
|
senior: '稀世', intermediate: '奇珍', junior: '罕见', basic: '普通', discount: '折扣',
|
|
851
846
|
}
|
|
852
847
|
|
|
853
|
-
const colNum = data.items.length === 1 ? 1 : (data.items.length <= 3 ? data.items.length :
|
|
848
|
+
const colNum = data.items.length === 1 ? 1 : (data.items.length <= 3 ? data.items.length : 6)
|
|
854
849
|
const cardHtml = data.items.map((it, idx) => {
|
|
855
850
|
const color = colors[it.rarity] || '#9ca3af'
|
|
856
851
|
const label = labels[it.rarity] || it.rarityLabel || it.rarity
|
|
@@ -859,9 +854,11 @@ function buildGachaHtml(data, config) {
|
|
|
859
854
|
: ''
|
|
860
855
|
return '<div class="card" style="--c:' + color + '">' +
|
|
861
856
|
'<div class="card-img"><img src="' + esc(it.img || it.icon || '') + '" onerror="this.style.visibility=\'hidden\'"></div>' +
|
|
857
|
+
'<div class="card-body">' +
|
|
862
858
|
'<div class="card-name">' + esc(it.name) + '</div>' +
|
|
863
859
|
'<div class="card-type" style="color:' + color + '">' + esc(label) + (it.type ? ' · ' + esc(it.type) : '') + '</div>' +
|
|
864
860
|
repeatHtml +
|
|
861
|
+
'</div>' +
|
|
865
862
|
'</div>'
|
|
866
863
|
}).join('')
|
|
867
864
|
|
|
@@ -886,13 +883,14 @@ body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Microsoft YaHei'
|
|
|
886
883
|
background:linear-gradient(90deg, #79c0ff, #ffd76d); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }
|
|
887
884
|
.pool-sub { font-size:13px; color:#8b949e; margin-top:6px; }
|
|
888
885
|
.grid { display:grid; grid-template-columns:repeat(${colNum}, 1fr); gap:14px; }
|
|
889
|
-
.card { background:rgba(22,27,34,.75); border:1px solid rgba(255,255,255,.09); border-radius:14px; padding:14px
|
|
890
|
-
|
|
891
|
-
.card-img { width:
|
|
886
|
+
.card { background:rgba(22,27,34,.75); border:1px solid rgba(255,255,255,.09); border-radius:14px; padding:12px 14px;
|
|
887
|
+
display:flex; align-items:center; gap:14px; overflow:hidden; }
|
|
888
|
+
.card-img { width:62px; height:62px; flex-shrink:0; background:#111318; border-radius:10px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
|
|
892
889
|
.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-
|
|
894
|
-
.card-
|
|
895
|
-
.
|
|
890
|
+
.card-body { min-width:0; }
|
|
891
|
+
.card-name { font-size:17px; font-weight:700; color:#fff; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
892
|
+
.card-type { font-size:14px; }
|
|
893
|
+
.repeat { margin-top:6px; font-size:12.5px; color:#f85149; background:rgba(248,81,73,.08); border:1px solid rgba(248,81,73,.2); border-radius:6px; padding:3px 8px; display:inline-block; }
|
|
896
894
|
.gains { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:20px; }
|
|
897
895
|
.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
896
|
.foot { text-align:center; color:#8b949e; font-size:12px; margin-top:18px; opacity:.75; }
|
|
@@ -1370,7 +1368,7 @@ async function gachaExplore(config, store, userId, diffArg) {
|
|
|
1370
1368
|
const daily = user.daily['explore'] || { date: todayStr, count: 0 }
|
|
1371
1369
|
if (daily.date !== todayStr) { daily.date = todayStr; daily.count = 0 }
|
|
1372
1370
|
if (daily.count >= limit) {
|
|
1373
|
-
return { ok: false, error: '今日探索次数已达上限(每天限 ' + limit + ' 次),明天再来吧' }
|
|
1371
|
+
return { ok: false, limit: true, error: '今日探索次数已达上限(每天限 ' + limit + ' 次),明天再来吧' }
|
|
1374
1372
|
}
|
|
1375
1373
|
|
|
1376
1374
|
const src = await resolveSource(config)
|
package/index.js
CHANGED
|
@@ -242,7 +242,7 @@ 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) return result.limit ? result.error : errorImage(ctx, config, result.error, GACHA_HERO_SUB)
|
|
246
246
|
const width = (config.gachaWidth && config.gachaWidth > 0) ? config.gachaWidth : config.width
|
|
247
247
|
const html = gacha.buildExploreHtml(result, { ...config, width })
|
|
248
248
|
const image = await capture(ctx, html, { ...config, width })
|
|
@@ -259,7 +259,7 @@ module.exports = {
|
|
|
259
259
|
}
|
|
260
260
|
try {
|
|
261
261
|
const result = await gacha.gachaPull(config, gachaStore, uid, t, poolId, count)
|
|
262
|
-
if (!result.ok) return errorImage(ctx, config, result.error, GACHA_HERO_SUB)
|
|
262
|
+
if (!result.ok) return result.limit ? result.error : errorImage(ctx, config, result.error, GACHA_HERO_SUB)
|
|
263
263
|
const width = (config.gachaWidth && config.gachaWidth > 0) ? config.gachaWidth : config.width
|
|
264
264
|
const html = gacha.buildGachaHtml(result, { ...config, width })
|
|
265
265
|
const image = await capture(ctx, html, { ...config, width })
|