From c14c2e403c75a913e1a6d962fb6fe64f013adae5 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 1 Jul 2026 22:30:31 -0400 Subject: fix: combat formulas and mob attack types (mobs switch attack styles if safespotting) --- internal/game/combat_mob_test.go | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 internal/game/combat_mob_test.go (limited to 'internal/game/combat_mob_test.go') diff --git a/internal/game/combat_mob_test.go b/internal/game/combat_mob_test.go new file mode 100644 index 0000000..28427b7 --- /dev/null +++ b/internal/game/combat_mob_test.go @@ -0,0 +1,61 @@ +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) + } + }) + } +} -- cgit v1.2.3