add ruleset data to the calls made by the cli (name and version) (#32)
* add ruleset data to the cli (name and version) * remove double ruleset tracking with royale mode
This commit is contained in:
parent
d750b08317
commit
f31bdff4b8
11 changed files with 86 additions and 29 deletions
22
cli/commands/play_test.go
Normal file
22
cli/commands/play_test.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"github.com/BattlesnakeOfficial/rules"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetIndividualBoardStateForSnake(t *testing.T) {
|
||||
s1 := rules.Snake{ID: "one", Body: []rules.Point{{X: 3, Y: 3}}}
|
||||
s2 := rules.Snake{ID: "two", Body: []rules.Point{{X: 4, Y: 3}}}
|
||||
state := &rules.BoardState{
|
||||
Height: 11,
|
||||
Width: 11,
|
||||
Snakes: []rules.Snake{s1, s2},
|
||||
}
|
||||
bs := Battlesnake{Name: "one", URL: "", ID: "one"}
|
||||
requestBody := getIndividualBoardStateForSnake(state, bs, nil, &rules.StandardRuleset{})
|
||||
|
||||
expected := "{\"game\":{\"id\":\"\",\"timeout\":500,\"ruleset\":{\"name\":\"standard\",\"version\":\"1.0.0\"}},\"turn\":0,\"board\":{\"height\":11,\"width\":11,\"food\":[],\"hazards\":[],\"snakes\":[{\"id\":\"one\",\"name\":\"\",\"health\":0,\"body\":[{\"x\":3,\"y\":3}],\"latency\":0,\"head\":{\"x\":3,\"y\":3},\"length\":1,\"shout\":\"\",\"squad\":\"\"},{\"id\":\"two\",\"name\":\"\",\"health\":0,\"body\":[{\"x\":4,\"y\":3}],\"latency\":0,\"head\":{\"x\":4,\"y\":3},\"length\":1,\"shout\":\"\",\"squad\":\"\"}]},\"you\":{\"id\":\"one\",\"name\":\"\",\"health\":0,\"body\":[{\"x\":3,\"y\":3}],\"latency\":0,\"head\":{\"x\":3,\"y\":3},\"length\":1,\"shout\":\"\",\"squad\":\"\"}}"
|
||||
require.Equal(t, expected, string(requestBody))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue