All files / web/src/components/toys/euclid/characters registry.ts

0% Statements 0/34
0% Branches 0/1
0% Functions 0/1
0% Lines 0/34

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                                                                     
/**
 * Registry of geometry voice configs, keyed by character ID.
 *
 * Supports a two-dimensional lookup: (characterId, attitudeId) → config.
 * Falls back to teacher attitude when attitude is omitted, and to Euclid
 * when characterId is unknown.
 */

import type { GeometryVoiceConfig, GeometryTeacherConfig } from '../GeometryTeacherConfig'
import type { AttitudeId } from '../agent/attitudes/types'
import { euclidConfig, getEuclidConfig } from './euclidConfig'
import { pappusConfig } from './pappusConfig'

/** Config resolvers keyed by character ID. */
const CONFIG_RESOLVERS: Record<string, (attitudeId?: AttitudeId) => GeometryVoiceConfig> = {
  euclid: getEuclidConfig,
  pappus: () => pappusConfig, // Pappus only has teacher for now
}

/** Flat map of default (teacher) configs for backward compat. */
export const GEOMETRY_TEACHER_CONFIGS: Record<string, GeometryTeacherConfig> = {
  euclid: euclidConfig,
  pappus: pappusConfig,
}

/** Look up a voice config by character ID and attitude, falling back to Euclid teacher. */
export function getTeacherConfig(
  characterId?: string,
  attitudeId?: AttitudeId
): GeometryVoiceConfig {
  const resolver = characterId ? CONFIG_RESOLVERS[characterId] : undefined
  if (resolver) return resolver(attitudeId)
  return getEuclidConfig(attitudeId)
}