import { describe, it, expect } from 'vitest';
import { getFloorMaxHP, getFloorElement } from '../utils/floor-utils';

// ─── getFloorMaxHP ────────────────────────────────────────────────────────────

describe('getFloorMaxHP', () => {
  it('should return positive HP for floor 1', () => {
    expect(getFloorMaxHP(1)).toBeGreaterThan(0);
  });

  it('should return base HP of 100 + scaling for floor 1', () => {
    // baseHP=100 + floorScaling=50 + exponentialScaling=1 = 151
    expect(getFloorMaxHP(1)).toBe(151);
  });

  it('should scale with floor number', () => {
    const hp1 = getFloorMaxHP(1);
    const hp5 = getFloorMaxHP(5);
    const hp10 = getFloorMaxHP(10);
    expect(hp5).toBeGreaterThan(hp1);
    expect(hp10).toBeGreaterThan(hp5);
  });

  it('should return much higher HP for guardian floors', () => {
    const hp9 = getFloorMaxHP(9);
    const hp10 = getFloorMaxHP(10); // Ignis Prime guardian
    expect(hp10).toBeGreaterThan(hp9 * 2);
  });

  it('should handle high floors', () => {
    const hp100 = getFloorMaxHP(100);
    expect(hp100).toBeGreaterThan(0);
    expect(isFinite(hp100)).toBe(true);
  });

  it('should be monotonically increasing for non-guardian floors', () => {
    let prev = getFloorMaxHP(1);
    for (let f = 2; f <= 9; f++) {
      const curr = getFloorMaxHP(f);
      expect(curr).toBeGreaterThan(prev);
      prev = curr;
    }
  });
});

// ─── getFloorElement ──────────────────────────────────────────────────────────

describe('getFloorElement', () => {
  it('should return a string element', () => {
    expect(typeof getFloorElement(1)).toBe('string');
  });

  it('should return valid element names', () => {
    const validElements = ['fire', 'water', 'air', 'earth', 'light', 'dark', 'death'];
    for (let f = 1; f <= 20; f++) {
      expect(validElements).toContain(getFloorElement(f));
    }
  });

  it('should cycle through 7 elements', () => {
    // Floor 1 and floor 8 should have the same element (cycle of 7)
    expect(getFloorElement(1)).toBe(getFloorElement(8));
    expect(getFloorElement(2)).toBe(getFloorElement(9));
    expect(getFloorElement(7)).toBe(getFloorElement(14));
  });

  it('should return fire for floor 1', () => {
    expect(getFloorElement(1)).toBe('fire');
  });

  it('should return water for floor 2', () => {
    expect(getFloorElement(2)).toBe('water');
  });

  it('should return death for floor 7', () => {
    expect(getFloorElement(7)).toBe('death');
  });

  it('should handle high floor numbers', () => {
    const elem = getFloorElement(100);
    expect(typeof elem).toBe('string');
    expect(elem.length).toBeGreaterThan(0);
  });
});
