import { describe, it, expect } from 'vitest';
import { multiclassCasterLevel, multiclassSlots } from './dnd5e/progression';

describe('multiclass spell slots (5e PHB)', () => {
  it('combines caster levels: full ×1, half ÷2, third ÷3 (floored)', () => {
    expect(multiclassCasterLevel({ full: 5 })).toBe(5);
    expect(multiclassCasterLevel({ full: 1, half: 6 })).toBe(1 + 3); // Sorc1/Pal6 = 4
    expect(multiclassCasterLevel({ half: 5, third: 4 })).toBe(2 + 1); // Pal5/EK4 = 3
  });

  it('reads the full-caster table at the combined level', () => {
    // caster level 4 → [4,3] (four 1st, three 2nd)
    expect(multiclassSlots({ full: 1, half: 6 })).toEqual([
      { level: 1, max: 4, current: 4 },
      { level: 2, max: 3, current: 3 },
    ]);
  });

  it('grants no slots at combined caster level 0 (a single half-caster level)', () => {
    expect(multiclassSlots({ half: 1 })).toEqual([]); // Paladin 1 alone — no slots
    expect(multiclassSlots({ third: 2 })).toEqual([]); // EK 2 — no slots yet
    expect(multiclassSlots({})).toEqual([]);
  });

  it('caps at character level 20', () => {
    const s = multiclassSlots({ full: 25 });
    expect(s.length).toBe(9); // 9 spell levels at the cap
  });
});
