import { expect, test } from "bun:test"; import { award, CREDIT_CAP, lossBonus, roundReward, spend, START_CREDITS } from "./economy.ts"; test("a round starts on 800 and nothing goes past 9000", () => { expect(START_CREDITS).toBe(800); expect(award(8900, 200)).toBe(CREDIT_CAP); expect(award(100, -500)).toBe(0); }); test("the loss bonus rises 1900 / 2400 / 2900 and stops", () => { expect(lossBonus(1)).toBe(1900); expect(lossBonus(2)).toBe(2400); expect(lossBonus(3)).toBe(2900); expect(lossBonus(7)).toBe(2900); }); test("a losing attack that planted keeps the plant bonus on top", () => { expect(roundReward(false, 1, false)).toBe(1900); expect(roundReward(false, 1, true)).toBe(1900 + 300); expect(roundReward(true, 3, false)).toBe(3000); }); test("a buy you cannot afford is refused, never a debt", () => { expect(spend(800, 2900)).toEqual({ ok: false, credits: 800 }); expect(spend(2900, 2900)).toEqual({ ok: true, credits: 0 }); expect(spend(800, -100).ok).toBe(false); expect(spend(800, Number.NaN).ok).toBe(false); });