import { describe, it, expect } from 'vitest';
import { RACE_GEN, GEN_COLORS, BREEDING_RECIPES, RACES_DATA, isBaseRace, generationOf, raceColor } from '@domain/value-objects/Race';
import { Gender } from '@domain/value-objects/Gender';

describe('Race', () => {
  it('base races are gen 1', () => {
    expect(generationOf('Rousse')).toBe(1);
    expect(generationOf('Amande')).toBe(1);
    expect(generationOf('Dorée')).toBe(1);
    expect(isBaseRace('Rousse')).toBe(true);
  });

  it('gen 2 races are correctly mapped', () => {
    expect(generationOf('Dorée et Rousse')).toBe(2);
    expect(generationOf('Amande et Dorée')).toBe(2);
    expect(generationOf('Amande et Rousse')).toBe(2);
    expect(isBaseRace('Dorée et Rousse')).toBe(false);
  });

  it('GEN_COLORS has 10 entries', () => {
    expect(Object.keys(GEN_COLORS)).toHaveLength(10);
  });

  it('BREEDING_RECIPES maps baby to parents', () => {
    expect(BREEDING_RECIPES['Dorée et Rousse']).toEqual(['Rousse', 'Dorée']);
    expect(BREEDING_RECIPES['Amande et Dorée']).toEqual(['Amande', 'Dorée']);
  });

  it('Ebène = Amande et Dorée + Dorée et Rousse (pas Amande et Rousse)', () => {
    expect(BREEDING_RECIPES['Ebène']).toEqual(['Amande et Dorée', 'Dorée et Rousse']);
  });

  it('RACES_DATA has generations 2-10', () => {
    for (let g = 2; g <= 10; g++) {
      expect(RACES_DATA[g]).toBeDefined();
      expect(RACES_DATA[g]!.length).toBeGreaterThan(0);
    }
  });

  it('raceColor returns a color string', () => {
    expect(raceColor('Rousse')).toBe('#c8622a');
    expect(raceColor('Dorée')).toBe('#e8b820');
    expect(raceColor('Unknown')).toBe('#888');
  });

  it('all breeding recipes have valid parents in RACE_GEN', () => {
    for (const [baby, [pA, pB]] of Object.entries(BREEDING_RECIPES)) {
      expect(RACE_GEN[baby]).toBeDefined();
      expect(RACE_GEN[pA]).toBeDefined();
      expect(RACE_GEN[pB]).toBeDefined();
    }
  });
});

describe('Gender', () => {
  it('has male, female, neutral', () => {
    const values: Gender[] = ['m', 'f', 'n'];
    expect(values).toHaveLength(3);
  });
});
