Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 12x 68x 68x 68x 68x 68x 68x 68x 12x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 2x 2x 4x 4x 4x 4x 4x 136x 136x 136x 136x 4x 4x 4x 4x 4x 4x 4x 66x 66x 66x 66x 66x 66x 66x 66x 65x 65x 65x 4x 4x 4x 4x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 23x 23x 23x 1x 1x 1x 1x 1x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 6x 6x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 6x 6x 6x 6x | /**
* Skill Search Utilities
*
* Functions for searching and filtering skills by name.
*/
import {
SKILL_CATEGORIES,
getFullSkillId,
type SkillCategoryKey,
} from '@/constants/skillCategories'
/**
* Skill search result
*/
export interface SkillSearchResult {
/** Full skill ID (e.g., "fiveComplements.4=5-1") */
skillId: string
/** Display name (e.g., "+4 = +5 - 1") */
displayName: string
/** Category key */
category: SkillCategoryKey
/** Category display name */
categoryName: string
}
/**
* Build a flat list of all skills with their display information.
*/
function buildSkillList(): SkillSearchResult[] {
const results: SkillSearchResult[] = []
for (const [categoryKey, category] of Object.entries(SKILL_CATEGORIES)) {
for (const [shortKey, displayName] of Object.entries(category.skills)) {
results.push({
skillId: getFullSkillId(categoryKey as SkillCategoryKey, shortKey),
displayName,
category: categoryKey as SkillCategoryKey,
categoryName: category.name,
})
}
}
return results
}
// Pre-built skill list for performance
const allSkills = buildSkillList()
/**
* Search for skills matching a query string.
*
* Matches against:
* - Skill display name (e.g., "+4 = +5 - 1")
* - Category name (e.g., "Five Complements")
*
* @param query - Search query (case-insensitive)
* @returns Matching skills, sorted by relevance
*/
export function searchSkills(query: string): SkillSearchResult[] {
if (!query.trim()) {
return []
}
const lowerQuery = query.toLowerCase()
// Filter skills matching the query
const matches = allSkills.filter((skill) => {
const displayLower = skill.displayName.toLowerCase()
const categoryLower = skill.categoryName.toLowerCase()
return displayLower.includes(lowerQuery) || categoryLower.includes(lowerQuery)
})
// Sort by relevance:
// 1. Exact display name match (starts with)
// 2. Category name match
// 3. Partial match
matches.sort((a, b) => {
const aDisplayLower = a.displayName.toLowerCase()
const bDisplayLower = b.displayName.toLowerCase()
const aStartsWith = aDisplayLower.startsWith(lowerQuery)
const bStartsWith = bDisplayLower.startsWith(lowerQuery)
if (aStartsWith && !bStartsWith) return -1
if (bStartsWith && !aStartsWith) return 1
// Then sort by category name
return a.categoryName.localeCompare(b.categoryName)
})
return matches
}
/**
* Get all skills in a category.
*/
export function getSkillsInCategory(category: SkillCategoryKey): SkillSearchResult[] {
return allSkills.filter((skill) => skill.category === category)
}
/**
* Get all skills.
*/
export function getAllSkills(): SkillSearchResult[] {
return [...allSkills]
}
/**
* Get display name for a skill ID.
*
* @param skillId - Full skill ID (e.g., "fiveComplements.4=5-1")
* @returns Display name or the skillId if not found
*/
export function getSkillDisplayName(skillId: string): string {
const skill = allSkills.find((s) => s.skillId === skillId)
return skill?.displayName ?? skillId
}
/**
* Get category display name for a skill ID.
*/
export function getSkillCategoryDisplayName(skillId: string): string {
const skill = allSkills.find((s) => s.skillId === skillId)
return skill?.categoryName ?? 'Unknown'
}
/**
* Format a skill for display in filter pills.
*
* Returns a short name suitable for a chip/pill.
*/
export function formatSkillChipName(skillId: string): string {
const skill = allSkills.find((s) => s.skillId === skillId)
if (!skill) {
return skillId
}
// Use a shortened category name for the chip
const shortNames: Record<SkillCategoryKey, string> = {
basic: 'Basic',
fiveComplements: "5's Add",
fiveComplementsSub: "5's Sub",
tenComplements: "10's Add",
tenComplementsSub: "10's Sub",
advanced: 'Advanced',
}
const categoryShort = shortNames[skill.category]
// Extract the operation from the display name (e.g., "+4" from "+4 = +5 - 1")
const opMatch = skill.displayName.match(/^([+-]?\d+)/)
const op = opMatch ? opMatch[1] : ''
return op ? `${categoryShort}: ${op}` : categoryShort
}
|