"""Tests for features/pricing.py.""" from __future__ import annotations from werewolftown.features.pricing import ( buy_discount, buyer_penalty_ratio, cap_card_price, dead_zone_adjust, max_buy, min_card_price, snap_price, ) class TestSnapPrice: def test_round_to_500(self, cfg): assert snap_price(12345, cfg) == 12500 def test_exact_multiple(self, cfg): assert snap_price(10000, cfg) == 10000 def test_zero(self, cfg): assert snap_price(0, cfg) == 0 def test_round_down(self, cfg): assert snap_price(12499, cfg) == 12500 class TestDeadZoneAdjust: def test_below_midpoint_snaps_down(self, cfg): assert dead_zone_adjust(11000, cfg) == 9000 def test_above_midpoint_snaps_up(self, cfg): assert dead_zone_adjust(14000, cfg) == 15000 def test_outside_dead_zone(self, cfg): assert dead_zone_adjust(5000, cfg) == 5000 assert dead_zone_adjust(20000, cfg) == 20000 class TestBuyDiscount: def test_r1(self, cfg): assert buy_discount(1, cfg) == 0.50 def test_r4(self, cfg): assert buy_discount(4, cfg) == 0.35 def test_r3(self, cfg): assert buy_discount(3, cfg) == 0.35 class TestMaxBuy: def test_r1_25000(self, cfg): assert max_buy(1, cfg) == 25000 def test_r4_10000(self, cfg): assert max_buy(4, cfg) == 10000 class TestBuyerPenaltyRatio: def test_r1_04(self, cfg): assert buyer_penalty_ratio(1, cfg) == 0.40 def test_r4_06(self, cfg): assert buyer_penalty_ratio(4, cfg) == 0.60 def test_r3_05(self, cfg): assert buyer_penalty_ratio(3, cfg) == 0.50 class TestMinCardPrice: def test_r4_1000(self, cfg): assert min_card_price(4, cfg) == 1000 def test_r1_5000(self, cfg): assert min_card_price(1, cfg) == 5000 class TestCapCardPrice: def test_capped_by_max(self, cfg): assert cap_card_price(50000, 100000, cfg) == 40000 def test_capped_by_cash(self, cfg): assert cap_card_price(50000, 40000, cfg) == 32000 # 40000 * 0.8 def test_no_cap_needed(self, cfg): assert cap_card_price(10000, 100000, cfg) == 10000