👁️
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

tag count grouping

+51
+1
src/components/deck/ViewControls.tsx
··· 10 10 11 11 const GROUP_BY_OPTIONS: Array<{ value: GroupBy; label: string }> = [ 12 12 { value: "typeAndTags", label: "Type & Tags" }, 13 + { value: "typeAndTagCount", label: "Type & Tag Count" }, 13 14 { value: "type", label: "Type" }, 14 15 { value: "subtype", label: "Subtype" }, 15 16 { value: "manaValue", label: "Mana Value" },
+49
src/lib/deck-grouping.ts
··· 266 266 break; 267 267 } 268 268 269 + case "typeAndTagCount": { 270 + // Group by type first, then by tag count within type 271 + // Format: "Type (N tags)" or "Type (no tags)" 272 + for (const card of cards) { 273 + const cardData = cardLookup(card); 274 + const face = cardData ? getPrimaryFace(cardData) : undefined; 275 + const type = extractPrimaryType(face?.type_line); 276 + const tagCount = card.tags?.length ?? 0; 277 + const countLabel = 278 + tagCount === 0 279 + ? "no tags" 280 + : tagCount === 1 281 + ? "1 tag" 282 + : `${tagCount} tags`; 283 + const groupName = `${type} (${countLabel})`; 284 + const group = groups.get(groupName) ?? { cards: [], forTag: false }; 285 + group.cards.push(card); 286 + groups.set(groupName, group); 287 + } 288 + break; 289 + } 290 + 269 291 case "subtype": { 270 292 for (const card of cards) { 271 293 const cardData = cardLookup(card); ··· 371 393 372 394 // Both tags, both types, or both special: sort alphabetically 373 395 return a.localeCompare(b); 396 + }); 397 + } 398 + 399 + case "typeAndTagCount": { 400 + // Sort by tag count ascending, then by type 401 + // Format: "Type (N tags)" or "Type (no tags)" 402 + const parseGroup = (name: string) => { 403 + const match = name.match(/^(.+) \((\d+|no) tags?\)$/); 404 + if (!match) return { type: name, count: 0 }; 405 + const countStr = match[2]; 406 + return { 407 + type: match[1], 408 + count: countStr === "no" ? 0 : parseInt(countStr, 10), 409 + }; 410 + }; 411 + 412 + return groupNames.sort((a, b) => { 413 + const parsedA = parseGroup(a); 414 + const parsedB = parseGroup(b); 415 + 416 + // Sort by tag count first (fewer tags = cut candidates at top) 417 + if (parsedA.count !== parsedB.count) { 418 + return parsedA.count - parsedB.count; 419 + } 420 + 421 + // Then by type alphabetically 422 + return parsedA.type.localeCompare(parsedB.type); 374 423 }); 375 424 } 376 425
+1
src/lib/deck-types.ts
··· 59 59 export type GroupBy = 60 60 | "type" 61 61 | "typeAndTags" 62 + | "typeAndTagCount" 62 63 | "subtype" 63 64 | "manaValue" 64 65 | "colorIdentity"