diff options
| author | historia <[not public]> | 2026-07-01 22:30:31 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-01 22:30:31 -0400 |
| commit | c14c2e403c75a913e1a6d962fb6fe64f013adae5 (patch) | |
| tree | 75070293fe2535b594ac72e501cbf08a3f1146e0 /internal/game/combat_mob_test.go | |
| parent | 8eec7b75ff9c8c368b252373db45fb891732d2ca (diff) | |
| download | thehouseoficarus-c14c2e403c75a913e1a6d962fb6fe64f013adae5.tar.gz | |
fix: combat formulas and mob attack types (mobs switch attack styles if safespotting)
Diffstat (limited to 'internal/game/combat_mob_test.go')
| -rw-r--r-- | internal/game/combat_mob_test.go | 61 |
1 files changed, 61 insertions, 0 deletions
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) + } + }) + } +} |
