aboutsummaryrefslogtreecommitdiff
path: root/go/game/cardImplementations_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/cardImplementations_test.go')
-rw-r--r--go/game/cardImplementations_test.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/go/game/cardImplementations_test.go b/go/game/cardImplementations_test.go
index b962677c..5160816e 100644
--- a/go/game/cardImplementations_test.go
+++ b/go/game/cardImplementations_test.go
@@ -131,3 +131,62 @@ symbols:
t.Fatal("unexpected valid target")
}
}
+
+func TestMissionary(t *testing.T) {
+ mapDef := `map: |1-
+ SSS
+ SSS
+ SHS
+symbols:
+ S: street
+ H: house
+`
+ s := NewLocalState()
+
+ m, _ := readMap(strings.NewReader(mapDef))
+ s.SetMap(m)
+
+ player := s.AddNewPlayer("p", NewDeck())
+ opo := s.AddNewPlayer("o", NewDeck())
+
+ mis := s.addNewUnit(NewCard("base/missionary"), Position{0, 0}, player)
+ king := s.addNewUnit(NewCard("misc/king"), Position{0, 2}, opo)
+ k := s.addNewUnit(NewCard("base/knight"), Position{2, 0}, opo)
+ r := s.addNewUnit(NewCard("base/recruit"), Position{2, 1}, opo)
+
+ a := mis.FullActions[0]
+ err := a.Target().AddSelection(king)
+ if err != nil {
+ t.Fatal("invalid target:", err)
+ }
+
+ for range 20 {
+ a.resolve(s)
+ if king.controller != king.owner {
+ t.Fatal("king not controlled by its owner")
+ }
+ }
+
+ a.Target().ClearSelection()
+ _ = a.Target().AddSelection(k)
+
+ a.resolve(s)
+ if k.controller != k.owner {
+ t.Fatal("knight not controlled by its owner")
+ }
+
+ s.ResolveAction(a)
+ if k.controller != player {
+ t.Fatal("knight not controlled by player")
+ }
+
+ // recruit
+ a.Target().ClearSelection()
+ _ = a.Target().AddSelection(r)
+ s.ResolveAction(a)
+ if r.controller != player {
+ t.Fatal("recruit not controlled by player")
+ }
+
+ // TODO: test return to owner
+}