import { describe, it, expect } from 'vitest';
import { degreeOfSuccess } from './check';

describe('degreeOfSuccess — pf2e', () => {
  it('meets DC = success, +10 = critical success', () => {
    expect(degreeOfSuccess({ total: 15, dc: 15, system: 'pf2e' })).toBe('success');
    expect(degreeOfSuccess({ total: 25, dc: 15, system: 'pf2e' })).toBe('critical-success');
  });
  it('below DC = failure, -10 = critical failure', () => {
    expect(degreeOfSuccess({ total: 14, dc: 15, system: 'pf2e' })).toBe('failure');
    expect(degreeOfSuccess({ total: 5, dc: 15, system: 'pf2e' })).toBe('critical-failure');
  });
  it('natural 20 bumps the degree up one step', () => {
    expect(degreeOfSuccess({ total: 14, dc: 15, system: 'pf2e', natural: 20 })).toBe('success'); // failure -> success
    expect(degreeOfSuccess({ total: 16, dc: 15, system: 'pf2e', natural: 20 })).toBe('critical-success');
  });
  it('natural 1 drops the degree one step', () => {
    expect(degreeOfSuccess({ total: 16, dc: 15, system: 'pf2e', natural: 1 })).toBe('failure'); // success -> failure
  });
});

describe('degreeOfSuccess — 5e', () => {
  it('success/failure vs DC', () => {
    expect(degreeOfSuccess({ total: 15, dc: 15, system: '5e' })).toBe('success');
    expect(degreeOfSuccess({ total: 14, dc: 15, system: '5e' })).toBe('failure');
  });
  it('nat 20/1 are critical regardless of DC', () => {
    expect(degreeOfSuccess({ total: 3, dc: 30, system: '5e', natural: 20 })).toBe('critical-success');
    expect(degreeOfSuccess({ total: 40, dc: 5, system: '5e', natural: 1 })).toBe('critical-failure');
  });
});
