added methods for getting options from type utils

This commit is contained in:
Justin Edmund 2025-09-17 21:51:26 -07:00
parent 94a3227632
commit be09e67d42
5 changed files with 53 additions and 10 deletions

View file

@ -1,4 +1,5 @@
export const ELEMENT_LABELS: Record<number, string> = {
0: 'Null',
1: 'Wind',
2: 'Fire',
3: 'Water',
@ -20,8 +21,15 @@ export function getElementClass(element?: number): string {
export function getElementIcon(element?: number): string {
const label = getElementLabel(element)
if (label === '—') return ''
if (label === '—' || label === 'Null') return ''
// Capitalize first letter for filename
const capitalizedLabel = label.charAt(0).toUpperCase() + label.slice(1)
return `/images/labels/element/Label_Element_${capitalizedLabel}.png`
}
export function getElementOptions() {
return Object.entries(ELEMENT_LABELS).map(([value, label]) => ({
value: Number(value),
label
}))
}

View file

@ -6,7 +6,7 @@ export const GENDER_LABELS: Record<number, string> = {
0: 'Unknown',
1: 'Male',
2: 'Female',
3: 'Male/Female'
3: 'Other'
}
export function getGenderLabel(gender?: number | null): string {
@ -19,4 +19,11 @@ export function getGenderIcon(gender?: number | null): string {
if (label === '—' || label === 'Unknown') return ''
// Gender icons may use different naming convention
return `/images/labels/gender/Label_Gender_${label.replace('/', '_')}.png`
}
export function getGenderOptions() {
return Object.entries(GENDER_LABELS).map(([value, label]) => ({
value: Number(value),
label
}))
}

View file

@ -1,13 +1,14 @@
export const PROFICIENCY_LABELS: Record<number, string> = {
0: 'None',
1: 'Sabre',
2: 'Dagger',
3: 'Axe',
4: 'Spear',
5: 'Bow',
6: 'Staff',
3: 'Spear',
4: 'Axe',
5: 'Staff',
6: 'Gun',
7: 'Melee',
8: 'Harp',
9: 'Gun',
8: 'Bow',
9: 'Harp',
10: 'Katana'
}
@ -17,8 +18,15 @@ export function getProficiencyLabel(proficiency: number): string {
export function getProficiencyIcon(proficiency: number): string {
const label = PROFICIENCY_LABELS[proficiency]
if (!label) return ''
if (!label || label === 'None') return ''
// Capitalize first letter for filename
const capitalizedLabel = label.charAt(0).toUpperCase() + label.slice(1)
return `/images/labels/proficiency/Label_Weapon_${capitalizedLabel}.png`
}
export function getProficiencyOptions() {
return Object.entries(PROFICIENCY_LABELS).map(([value, label]) => ({
value: Number(value),
label
}))
}

View file

@ -8,7 +8,8 @@ export const RACE_LABELS: Record<number, string> = {
2: 'Erune',
3: 'Draph',
4: 'Harvin',
5: 'Primal'
5: 'Primal',
6: 'Other'
}
export function getRaceLabel(race?: number | null): string {
@ -20,4 +21,16 @@ export function getRaceIcon(race?: number | null): string {
const label = getRaceLabel(race)
if (label === '—' || label === 'Unknown') return ''
return `/images/labels/race/Label_Race_${label}.png`
}
export function getRaceOptions() {
// Add "None" option for empty selection
const options = [
{ value: null as any, label: 'None' },
...Object.entries(RACE_LABELS).map(([value, label]) => ({
value: Number(value),
label
}))
]
return options
}

View file

@ -8,6 +8,13 @@ export function getRarityLabel(rarity: number): string {
return RARITY_LABELS[rarity] || '—'
}
export function getRarityOptions() {
return Object.entries(RARITY_LABELS).map(([value, label]) => ({
value: Number(value),
label
}))
}
export function getRarityClass(rarity: number): string {
switch (rarity) {
case 1: