package formula

import "testing"

func TestApplyArmor(t *testing.T) {
	dmg := ApplyArmor(100, 50)
	if dmg >= 100 || dmg < 1 {
		t.Fatalf("expected reduced damage, got %d", dmg)
	}
}

func TestApplyArmorCap(t *testing.T) {
	dmg := ApplyArmor(100, 10000)
	reduction := DamageReduction(10000)
	if reduction*100 > ArmorCapPercent+0.01 {
		t.Fatalf("armor cap exceeded: %f", reduction*100)
	}
	if dmg < 15 {
		t.Fatalf("expected at least 15%% damage through cap, got %d", dmg)
	}
}

func TestPhysicalDamageMinimum(t *testing.T) {
	if PhysicalDamage(0, 0) != 1 {
		t.Fatal("minimum damage should be 1")
	}
}

func TestHitChanceBounds(t *testing.T) {
	low := HitChance(1, 100)
	high := HitChance(100, 1)
	if low < 0.1 || high > 0.95 {
		t.Fatalf("hit chance out of bounds: low=%f high=%f", low, high)
	}
}

func TestMaxHP(t *testing.T) {
	hp := MaxHP(10, 10)
	if hp != 120 {
		t.Fatalf("expected 120, got %d", hp)
	}
}
