Files
tactical-shooter/tests/economy.gd
T
shawn 8c790357d3 Add automated test framework and 21 regression tests
- tests/runner.gd: lightweight headless test runner (TAP format output)
- tests/weapons.gd: 6 tests for weapon registry and stats
- tests/team.gd: 5 tests for team assignment and balancing
- tests/economy.gd: 6 tests for economy constants and loss streaks
- tests/bootstrapper.gd: 4 tests for LAN bootstrapper input parsing

Run with: godot --headless -s tests/runner.gd --path .

All 21 tests pass on Linux and Windows.
2026-07-03 01:29:08 -04:00

59 lines
2.2 KiB
GDScript

extends RefCounted
## Economy system tests — verifies constants, money clamping, loss streaks.
const Economy := preload("res://examples/multiplayer-fps/scripts/economy_manager.gd")
func test_economy_constants() -> String:
var e := ""
if Economy.START_MONEY != 800: e += " START_MONEY should be 800"
if Economy.MAX_MONEY != 16000: e += " MAX_MONEY should be 16000"
if Economy.WIN_REWARD != 3250: e += " WIN_REWARD should be 3250"
if Economy.LOSS_BASE != 1400: e += " LOSS_BASE should be 1400"
if Economy.LOSS_INCREMENT != 500: e += " LOSS_INCREMENT should be 500"
if Economy.LOSS_MAX != 3400: e += " LOSS_MAX should be 3400"
return e
func test_equipment_prices() -> String:
var e := ""
if Economy.KEVLAR_PRICE != 650: e += " Kevlar price wrong"
if Economy.DEFUSE_KIT_PRICE != 400: e += " Defuse kit price wrong"
if Economy.FLASH_PRICE != 200: e += " Flash price wrong"
if Economy.SMOKE_PRICE != 300: e += " Smoke price wrong"
return e
func test_grenade_limits() -> String:
var e := ""
if Economy.FLASH_MAX != 2: e += " MAX flashbangs should be 2"
if Economy.SMOKE_MAX != 1: e += " MAX smokes should be 1"
return e
func test_money_clamp_to_max() -> String:
var em := EconomyManager.new()
em._money[1] = 0
# Simulate add_money bypassing multiplayer check
em._money[1] = clampi(em._money.get(1, 0) + 99999, 0, 16000)
if em._money[1] != 16000:
return "Money should clamp at 16000, got %d" % em._money[1]
return ""
func test_money_clamp_to_zero() -> String:
var em := EconomyManager.new()
em._money[1] = 500
em._money[1] = clampi(em._money.get(1, 0) - 99999, 0, 16000)
if em._money[1] != 0:
return "Money should clamp at 0, got %d" % em._money[1]
return ""
func test_loss_streak_formula() -> String:
var e := ""
var streak_0 := mini(1400 + 0 * 500, 3400)
if streak_0 != 1400: e += " 0-loss streak should be 1400"
var streak_1 := mini(1400 + 1 * 500, 3400)
if streak_1 != 1900: e += " 1-loss streak should be 1900"
var streak_4 := mini(1400 + 4 * 500, 3400)
if streak_4 != 3400: e += " 4-loss streak should be 3400 (capped)"
var streak_10 := mini(1400 + 10 * 500, 3400)
if streak_10 != 3400: e += " 10-loss streak should be 3400 (capped)"
return e