Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(drops): give every collection a legendary, and stop the rarity pill reading "LEGE"

nirholas81b44a01f35e
diff --git a/api/_lib/drops.js b/api/_lib/drops.js
index 7ffbcf0c7..0b7d370b7 100644
--- a/api/_lib/drops.js
+++ b/api/_lib/drops.js
@@ -234,13 +234,24 @@ export function scoreRarity(items, supply = items.length) {
*/
export function tierForRank(rank, supply) {
if (!(supply > 0)) return 'common';
- const percentile = rank / supply;
for (const { tier, maxPercentile } of RARITY_TIERS) {
- if (percentile <= maxPercentile) return tier;
+ if (rank <= tierCutoff(supply, maxPercentile)) return tier;
}
return 'common';
}
+/**
+ * How many items a tier's band holds, counted from the top of the ranking.
+ *
+ * The `max(1, ...)` is what stops a small collection from having no legendary
+ * at all: a raw percentile test leaves every supply under 100 with an empty
+ * scarcest tier, which reads as a bug to anyone looking at the top of the
+ * ranking and quietly punishes creators for launching something small.
+ */
+export function tierCutoff(supply, maxPercentile) {
+ return Math.max(1, Math.ceil(supply * maxPercentile));
+}
+
/**
* Per-layer trait frequency table for the rarity panel on a drop page.
*
diff --git a/src/drop-collection.js b/src/drop-collection.js
index 60751e11a..e849cae38 100644
--- a/src/drop-collection.js
+++ b/src/drop-collection.js
@@ -17,6 +17,11 @@ const PAGE_SIZE = 48;
const POLL_MS = 4000;
const TIERS = ['legendary', 'epic', 'rare', 'common'];
+// Grid cells are ~132px wide, so the footer pill gets an abbreviation rather
+// than the full tier name. These are explicit because slicing the word to a
+// fixed length renders "legendary" as the meaningless "LEGE".
+const TIER_SHORT = { legendary: 'LEG', epic: 'EPIC', rare: 'RARE', common: 'COM' };
+
const el = {
page: document.getElementById('dr-page'),
pageState: document.getElementById('dr-page-state'),
@@ -256,7 +261,7 @@ function itemButton(item) {
rank.textContent = `#${item.rarity_rank}`;
const pill = document.createElement('span');
pill.className = `dr-pill dr-pill--${item.rarity_tier}`;
- pill.textContent = item.rarity_tier.slice(0, 4);
+ pill.textContent = TIER_SHORT[item.rarity_tier] || item.rarity_tier;
foot.append(rank, pill);
b.append(art, foot);
diff --git a/tests/drops-engine.test.js b/tests/drops-engine.test.js
index c11284faf..2e165c913 100644
--- a/tests/drops-engine.test.js
+++ b/tests/drops-engine.test.js
@@ -23,6 +23,7 @@ import {
rollSupply,
scoreRarity,
slugify,
+ tierCutoff,
tierForRank,
traitDistribution,
verifyItem,
@@ -246,6 +247,30 @@ describe('tierForRank', () => {
it('degrades safely on an empty supply', () => {
expect(tierForRank(1, 0)).toBe('common');
});
+
+ // A raw percentile test gives every collection under 100 an empty legendary
+ // tier, so the top of a 60-item ranking would read as merely "epic".
+ it('always gives the scarcest tier at least one item', () => {
+ for (const supply of [1, 7, 60, 99, 100]) {
+ expect(tierForRank(1, supply)).toBe('legendary');
+ }
+ });
+
+ it('keeps the bands ordered as supply shrinks', () => {
+ expect(tierForRank(1, 60)).toBe('legendary');
+ expect(tierForRank(2, 60)).toBe('epic');
+ expect(tierForRank(6, 60)).toBe('epic');
+ expect(tierForRank(7, 60)).toBe('rare');
+ expect(tierForRank(21, 60)).toBe('rare');
+ expect(tierForRank(22, 60)).toBe('common');
+ expect(tierForRank(60, 60)).toBe('common');
+ });
+
+ it('exposes the cutoff it uses, floored at one item', () => {
+ expect(tierCutoff(1000, 0.01)).toBe(10);
+ expect(tierCutoff(60, 0.01)).toBe(1);
+ expect(tierCutoff(60, 1)).toBe(60);
+ });
});
describe('scoreRarity', () => {