aboutsummaryrefslogtreecommitdiff
path: root/go/game/action_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/action_test.go')
-rw-r--r--go/game/action_test.go28
1 files changed, 10 insertions, 18 deletions
diff --git a/go/game/action_test.go b/go/game/action_test.go
index f72193ad..d00b5d56 100644
--- a/go/game/action_test.go
+++ b/go/game/action_test.go
@@ -8,17 +8,10 @@ import (
"muhq.space/muhqs-game/go/utils"
)
-const PASS_STRING = "muhq\u00A0pass"
-
-var (
- s *LocalState = NewLocalState()
- p *Player = s.AddNewPlayer("muhq", NewDeck())
-)
+const PASS_STRING = "p\u00A0pass"
func TestUpkeepAction(t *testing.T) {
- s := NewLocalState()
- p := s.AddNewPlayer("muhq", NewDeck())
- o := s.AddNewPlayer("opponent", NewDeck())
+ s, _, p, o := newMockState()
m, _ := GetMap("2P-ring-street")
s.SetMap(m)
@@ -56,6 +49,7 @@ func TestUpkeepAction(t *testing.T) {
}
func TestMarshalPass(t *testing.T) {
+ _, _, p, _ := newMockState()
exp := PASS_STRING
a := NewPassPriority(p)
is := string(MarshalAction(a))
@@ -65,6 +59,7 @@ func TestMarshalPass(t *testing.T) {
}
func TestUnmarshalPass(t *testing.T) {
+ s, _, _, _ := newMockState()
in := PASS_STRING
a, err := UnmarshalAction(s, []byte(in))
if err != nil {
@@ -75,9 +70,10 @@ func TestUnmarshalPass(t *testing.T) {
}
}
-const PICK_ACTION_STRING = "muhq\u00A0pick\u00A0base/archer:[base/archer, magic/more!]"
+const PICK_ACTION_STRING = "p\u00A0pick\u00A0base/archer:[base/archer, magic/more!]"
func TestMarshalPickAction(t *testing.T) {
+ _, _, p, _ := newMockState()
exp := PICK_ACTION_STRING
poc := NewPileOfCards()
c := NewCard("base/archer")
@@ -91,6 +87,7 @@ func TestMarshalPickAction(t *testing.T) {
}
func TestUnmarshalPickAction(t *testing.T) {
+ s, _, _, _ := newMockState()
in := PICK_ACTION_STRING
a, err := UnmarshalAction(s, []byte(in))
if err != nil {
@@ -119,14 +116,10 @@ symbols:
H: house
S: street
`
- s := NewLocalState()
- r := strings.NewReader(mapDef)
- m, _ := readMap(r)
+ s, _, p, o := newMockState()
+ m, _ := readMap(strings.NewReader(mapDef))
s.SetMap(m)
- p := s.AddNewPlayer("player", NewDeck())
- o := s.AddNewPlayer("opponent", NewDeck())
-
t1 := s.addNewUnit(NewCard("base/fighter"), Position{0, 0}, o)
t2 := s.addNewUnit(NewCard("base/fighter"), Position{0, 1}, o)
t3 := s.addNewUnit(NewCard("base/fighter"), Position{0, 2}, o)
@@ -195,8 +188,7 @@ symbols:
S: street
`
s := NewLocalState()
- r := strings.NewReader(mapDef)
- m, _ := readMap(r)
+ m, _ := readMap(strings.NewReader(mapDef))
s.SetMap(m)
p := s.AddNewPlayer("player", NewDeck())