import { describe, it, expect } from 'vitest'; import { coinValue, hazardValue, recommendedLevel, trapValue, xpValue } from '$lib/game/levelValues'; describe('level values (GameMethods port)', () => { it('trap = 2 + level', () => { expect(trapValue(1)).toBe(3); expect(trapValue(10)).toBe(12); }); it('hazard = 1 + ceil(level / 3)', () => { expect(hazardValue(1, false, false)).toBe(2); expect(hazardValue(3, false, false)).toBe(2); expect(hazardValue(4, false, false)).toBe(3); }); it('OGGloom hazard halves the trap value by default', () => { // floor((2 + level) / 2) expect(hazardValue(1, true, false)).toBe(1); expect(hazardValue(5, true, false)).toBe(3); }); it('OGGloom with the FH setting uses the regular formula', () => { expect(hazardValue(5, true, true)).toBe(3); // 1 + ceil(5/3) expect(hazardValue(4, true, true)).toBe(3); // 1 + ceil(4/3) }); it('xp = 4 + 2 * level', () => { expect(xpValue(1)).toBe(6); expect(xpValue(4)).toBe(12); }); it('coin = 2 + floor(level / 2), capped at 6 on level 7', () => { expect(coinValue(1)).toBe(2); expect(coinValue(2)).toBe(3); expect(coinValue(6)).toBe(5); expect(coinValue(7)).toBe(6); expect(coinValue(8)).toBe(6); // 2 + floor(8/2) = 6, same }); }); describe('recommendedLevel (GameMethods port)', () => { it('defaults to 1 with no characters', () => { expect(recommendedLevel([], false)).toBe(1); }); it('party: average level divided by 2, rounded up', () => { expect(recommendedLevel([2, 2, 2, 2], false)).toBe(1); expect(recommendedLevel([4, 4, 4, 4], false)).toBe(2); expect(recommendedLevel([3, 3, 3, 3], false)).toBe(2); }); it('solo: (average + 1) / 2, rounded up', () => { expect(recommendedLevel([1], true)).toBe(1); expect(recommendedLevel([4], true)).toBe(3); }); });