fix: collapse double find() and add <0.1% guard for tiny drop rates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -106,8 +106,8 @@ export function getShopListingMessage(
|
||||
.setEmoji("🛒");
|
||||
|
||||
// 2. Loot Table (if applicable) — separate Container with blurple accent
|
||||
if (item.usageData?.effects?.find((e: any) => e.type === EffectType.LOOTBOX)) {
|
||||
const lootboxEffect = item.usageData.effects.find((e: any) => e.type === EffectType.LOOTBOX);
|
||||
const lootboxEffect = item.usageData?.effects?.find((e: any) => e.type === EffectType.LOOTBOX);
|
||||
if (lootboxEffect) {
|
||||
const pool = lootboxEffect.pool as LootTableItem[];
|
||||
const totalWeight = pool.reduce((sum: number, i: LootTableItem) => sum + i.weight, 0);
|
||||
|
||||
@@ -181,7 +181,7 @@ export function getShopListingMessage(
|
||||
isFirst = false;
|
||||
|
||||
const config = getRarityConfig(rarity);
|
||||
const chanceStr = tier.totalChance.toFixed(1);
|
||||
const chanceStr = tier.totalChance < 0.1 ? "<0.1" : tier.totalChance.toFixed(1);
|
||||
lootContainer.addTextDisplayComponents(
|
||||
new TextDisplayBuilder().setContent(
|
||||
`${config.emoji} **${config.label}** — ${chanceStr}%`
|
||||
|
||||
Reference in New Issue
Block a user