aboutsummaryrefslogtreecommitdiff
path: root/go/game/card_test.go
blob: 3e9c8f6f3155bd2e08277f71e6a7af94e5db51bc (plain)
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
package game

import (
	"errors"
	"reflect"
	"testing"
)

func TestLoadingAllCards(t *testing.T) {
	v := reflect.ValueOf(Sets)
	for i := range v.NumField() {
		set := v.Field(i).Interface().(SetIdentifier)
		NewDeckFromCardPaths(set.CardPaths()).Cards()
	}
}

func TestLoadingUnknownCard(t *testing.T) {
	_, err := NewCardSafe("foo/bar")
	if !errors.Is(err, ErrUnknownCardPath) {
		t.Fatal("expected urlErr:", err)
	}
}

func TestCardReporters(t *testing.T) {
	archer := NewCard("base/archer")
	recruit := NewCard("base/recruit")
	ritual := NewCard("magic/ritual!")
	sword := NewCard("base/sword")

	if !archer.IsBuyable() || !ritual.IsBuyable() || recruit.IsBuyable() || !sword.IsBuyable() {
		t.Fatal("unexpected buyability result")
	}

	if !archer.IsPermanent() || ritual.IsPermanent() || !recruit.IsPermanent() || !sword.IsPermanent() {
		t.Fatal("unexpected permanent result")
	}

	if archer.Type.IsArtifact() || !sword.Type.IsArtifact() {
		t.Fatal("unexpected IsArtifact result")
	}

	if archer.IsToken() || !recruit.IsToken() {
		t.Fatal("unexpected IsToken result")
	}

	if archer.hasEffect("crew") {
		t.Fatal("archer has no crew effect")
	}

	if archer.hasPlacementConstrain("swimmming") {
		t.Fatal("archer is not swimming")
	}
}