FEAT-4: pedigree data module - depth-limited ancestor traversal, lazy expand, cycle guard, rd3t conversion (15 tests)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
53
gerbil-manager-web/src/pedigree/chipColors.ts
Normal file
53
gerbil-manager-web/src/pedigree/chipColors.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* FEAT-4: Anzeigefarben der Farbschlag-Chips auf den Stammbaum-Karten.
|
||||
*
|
||||
* Reine Präsentation (angenäherte Fellfarben) — KEINE Genetik. Schlüssel sind
|
||||
* die Basisnamen aus dem GEN-1-Katalog (src/genetics/catalog.ts BASE_COLORS);
|
||||
* Modifikatoren („… Schecke“, „… Rex“) werden über den Basisnamen-Präfix
|
||||
* aufgelöst. Unbekannte Namen → null, die Karte nutzt dann den neutralen Chip.
|
||||
*/
|
||||
export interface ChipColor {
|
||||
readonly bg: string
|
||||
readonly fg: string
|
||||
}
|
||||
|
||||
const CHIP_COLORS: Record<string, ChipColor> = {
|
||||
// Colourpoint / C-Serie
|
||||
'Pink Eyed White (PEW)': { bg: '#f7f3ec', fg: '#8a7d6b' },
|
||||
Hermelin: { bg: '#f3ede2', fg: '#8a7d6b' },
|
||||
Himalaya: { bg: '#efe6d8', fg: '#8a7d6b' },
|
||||
Zobel: { bg: '#6b4f3a', fg: '#ffffff' },
|
||||
// Schimmel
|
||||
Schwarzschimmel: { bg: '#7a7470', fg: '#ffffff' },
|
||||
Rotaugenschimmel: { bg: '#c0a99a', fg: '#3b3026' },
|
||||
// Schwarzäugige Vollfarben
|
||||
Agouti: { bg: '#b3854d', fg: '#ffffff' },
|
||||
Schwarz: { bg: '#2f2a26', fg: '#ffffff' },
|
||||
Silberagouti: { bg: '#b9b3a8', fg: '#3b3026' },
|
||||
Anthrazit: { bg: '#5a5550', fg: '#ffffff' },
|
||||
Algierfuchs: { bg: '#c98a3d', fg: '#ffffff' },
|
||||
Blau: { bg: '#8a93a5', fg: '#ffffff' },
|
||||
// Rotäugige Vollfarben
|
||||
Gold: { bg: '#d9a441', fg: '#3b3026' },
|
||||
Platin: { bg: '#c8c2bd', fg: '#3b3026' },
|
||||
Goldfuchs: { bg: '#e0b15e', fg: '#3b3026' },
|
||||
Rotfuchs: { bg: '#b56a3c', fg: '#ffffff' },
|
||||
'dd Gold': { bg: '#e3c98f', fg: '#3b3026' },
|
||||
'dd Platin': { bg: '#d9d4cf', fg: '#3b3026' },
|
||||
}
|
||||
|
||||
/** Chipfarbe für einen Farbschlag-Namen (inkl. Modifikator-Suffixen). */
|
||||
export function chipColorFor(farbschlag: string): ChipColor | null {
|
||||
const exact = CHIP_COLORS[farbschlag]
|
||||
if (exact) return exact
|
||||
// Modifikatoren abgetrennt: längster passender Basisname gewinnt.
|
||||
let best: ChipColor | null = null
|
||||
let bestLength = 0
|
||||
for (const [name, color] of Object.entries(CHIP_COLORS)) {
|
||||
if (farbschlag.startsWith(name + ' ') && name.length > bestLength) {
|
||||
best = color
|
||||
bestLength = name.length
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
Reference in New Issue
Block a user