import { BREEDING_RECIPES, BREEDING_BY_PARENTS, COMPATIBLE_PARTNERS, RACE_GEN } from '@domain/value-objects/Race';

export interface PartnerInfo {
  readonly partner: string;
  readonly baby: string;
  readonly gen: number;
}

export class BreedingService {
  deduceBaby(parent1: string, parent2: string): string | null {
    return BREEDING_BY_PARENTS[`${parent1}|${parent2}`]
      ?? BREEDING_BY_PARENTS[`${parent2}|${parent1}`]
      ?? null;
  }

  getCompatiblePartners(race: string): readonly PartnerInfo[] {
    return (COMPATIBLE_PARTNERS[race] as PartnerInfo[] | undefined) ?? [];
  }

  getParents(babyRace: string): readonly [string, string] | null {
    const recipe = BREEDING_RECIPES[babyRace];
    return recipe ? [recipe[0], recipe[1]] : null;
  }

  getGeneration(race: string): number {
    return RACE_GEN[race] ?? 0;
  }
}
