package game import ( "testing" "thehouseoficarus/internal/world" ) func TestMobMeleeType(t *testing.T) { cases := []struct { name string types []string want string }{ {"single crush", []string{"crush"}, "crush"}, {"melee plus ranged", []string{"stab", "ranged"}, "stab"}, {"ranged first", []string{"ranged", "slash"}, "slash"}, {"no melee defaults crush", []string{"ranged"}, "crush"}, {"empty defaults crush", nil, "crush"}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { mob := &world.MobInstance{AttackTypes: c.types} if got := mobMeleeType(mob); got != c.want { t.Errorf("mobMeleeType(%v) = %q, want %q", c.types, got, c.want) } }) } } func TestMobStrongestRangedScience(t *testing.T) { cases := []struct { name string types []string maxRanged int maxScience int sciencePct int want string }{ {"melee only", []string{"crush"}, 0, 0, 0, ""}, {"ranged only", []string{"crush", "ranged"}, 5, 0, 0, "ranged"}, {"science only", []string{"crush", "science"}, 0, 7, 0, "science"}, {"both science higher", []string{"crush", "ranged", "science"}, 5, 8, 0, "science"}, {"both ranged higher", []string{"crush", "ranged", "science"}, 10, 8, 0, "ranged"}, {"both tie prefers ranged", []string{"crush", "ranged", "science"}, 8, 8, 0, "ranged"}, {"science percent tips it", []string{"crush", "ranged", "science"}, 10, 8, 50, "science"}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { mob := &world.MobInstance{ AttackTypes: c.types, MaxRangedHit: c.maxRanged, MaxScienceHit: c.maxScience, SciencePercentBonus: c.sciencePct, } if got := mobStrongestRangedScience(mob); got != c.want { t.Errorf("mobStrongestRangedScience() = %q, want %q", got, c.want) } }) } }