1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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)
}
})
}
}
|