-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbiomes_test.go
More file actions
44 lines (40 loc) · 1.29 KB
/
Copy pathbiomes_test.go
File metadata and controls
44 lines (40 loc) · 1.29 KB
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
package idlerpg
import "testing"
func TestBiomeOfNearestTown(t *testing.T) {
// A point sitting on a town takes that town's terrain.
for _, tn := range towns {
if got := biomeOf(int64(tn.X), int64(tn.Y)); got != tn.Terrain {
t.Errorf("biomeOf(%s) = %q; want %q", tn.Name, got, tn.Terrain)
}
}
}
func TestPickMonsterRespectsBiome(t *testing.T) {
m, _, _ := newMgr()
// In coastal terrain at a high level, every foe must be either anywhere-roaming
// ("") or coast-themed — never a forest/swamp/mountain/plains specialist.
sawCoast := false
for i := 0; i < 400; i++ {
mon := m.pickMonster(30, "coast")
if mon.Biome != "" && mon.Biome != "coast" {
t.Fatalf("coast picked an off-biome foe: %q (%s)", mon.Name, mon.Biome)
}
if mon.Biome == "coast" {
sawCoast = true
}
}
if !sawCoast {
t.Fatal("expected at least one coast-specific foe across many picks")
}
}
func TestPickBossRespectsBiome(t *testing.T) {
m, _, _ := newMgr()
// The Kraken is coast-only; in the mountains a high-level idler should never
// draw it, but Tiamat (mountain) or an anywhere-boss is fair game.
for i := 0; i < 400; i++ {
if b, ok := m.pickBoss(40, "mountain"); ok {
if b.Biome != "" && b.Biome != "mountain" {
t.Fatalf("mountain drew an off-biome boss: %q (%s)", b.Name, b.Biome)
}
}
}
}