diff --git a/public/card b/public/card new file mode 120000 index 0000000..4ee7751 --- /dev/null +++ b/public/card @@ -0,0 +1 @@ +/Users/syui/ai/card/assets \ No newline at end of file diff --git a/src/web/components/card.ts b/src/web/components/card.ts new file mode 100644 index 0000000..a56a1e2 --- /dev/null +++ b/src/web/components/card.ts @@ -0,0 +1,167 @@ +// Card display component for ai.syui.card.user collection + +export interface UserCard { + id: number + cp: number + rare: number + cid: string +} + +export interface CardCollection { + card: UserCard[] + createdAt: string + updatedAt: string +} + +// Get rarity class name +function getRarityClass(rare: number): string { + switch (rare) { + case 1: return 'rare' + case 2: return 'shiny' + case 3: return 'unique' + default: return '' + } +} + + +// Render single card with optional count badge +export function renderCard(card: UserCard, baseUrl: string = '/card', count?: number): string { + const rarityClass = getRarityClass(card.rare) + const imageUrl = `${baseUrl}/${card.id}.webp` + + const effectsHtml = rarityClass ? ` +
+ + ` : '' + + const countBadge = count && count > 1 ? `x${count}` : '' + + return ` +No cards found for @${handle}
+${handleHtml}
${description ? `${escapeHtml(description)}
` : ''}